Upgrade csv-core to 0.1.11 am: 13523ac1ad am: 127656de13

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/csv-core/+/2943666

Change-Id: Ib28dc1883f853404e69ac24de9ca944c19a14d1f
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 6de0194..a082222 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,6 @@
 {
   "git": {
-    "sha1": "70c8600b29349f9ee0501577284d8300ae9c8055"
-  }
-}
+    "sha1": "44b836cf9216a22bf150aecf7b7f0918fd96e680"
+  },
+  "path_in_vcs": "csv-core"
+}
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 5f6ea53..10c039f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -43,7 +43,7 @@
     host_supported: true,
     crate_name: "csv_core",
     cargo_env_compat: true,
-    cargo_pkg_version: "0.1.10",
+    cargo_pkg_version: "0.1.11",
     srcs: ["src/lib.rs"],
     edition: "2018",
     features: ["default"],
diff --git a/Cargo.toml b/Cargo.toml
index 0f43cb0..dad4126 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,32 +3,44 @@
 # When uploading crates to the registry Cargo will automatically
 # "normalize" Cargo.toml files for maximal compatibility
 # with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
 #
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
 
 [package]
 edition = "2018"
 name = "csv-core"
-version = "0.1.10"
+version = "0.1.11"
 authors = ["Andrew Gallant <[email protected]>"]
 description = "Bare bones CSV parsing with no_std support."
 homepage = "https://github.com/BurntSushi/rust-csv"
 documentation = "https://docs.rs/csv-core"
 readme = "README.md"
-keywords = ["csv", "comma", "parser", "delimited", "no_std"]
-categories = ["encoding", "no-std", "parser-implementations"]
+keywords = [
+    "csv",
+    "comma",
+    "parser",
+    "delimited",
+    "no_std",
+]
+categories = [
+    "encoding",
+    "no-std",
+    "parser-implementations",
+]
 license = "Unlicense/MIT"
 repository = "https://github.com/BurntSushi/rust-csv"
+resolver = "2"
 
 [lib]
 bench = false
+
 [dependencies.memchr]
 version = "2"
 default-features = false
+
 [dev-dependencies.arrayvec]
 version = "0.5"
 default-features = false
@@ -36,6 +48,7 @@
 [features]
 default = []
 libc = ["memchr/libc"]
+
 [badges.appveyor]
 repository = "BurntSushi/rust-csv"
 
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 110ee06..bf48f97 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "csv-core"
-version = "0.1.10"  #:version
+version = "0.1.11"  #:version
 authors = ["Andrew Gallant <[email protected]>"]
 description = "Bare bones CSV parsing with no_std support."
 documentation = "https://docs.rs/csv-core"
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..3b0a5dc
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Andrew Gallant
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/METADATA b/METADATA
index 2d47c56..8aaf5d1 100644
--- a/METADATA
+++ b/METADATA
@@ -1,19 +1,20 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update external/rust/crates/csv-core
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
+
 name: "csv-core"
 description: "Bare bones CSV parsing with no_std support."
 third_party {
-  url {
-    type: HOMEPAGE
-    value: "https://crates.io/crates/csv-core"
-  }
-  url {
-    type: ARCHIVE
-    value: "https://static.crates.io/crates/csv-core/csv-core-0.1.10.crate"
-  }
-  version: "0.1.10"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2020
-    month: 12
-    day: 21
+    year: 2024
+    month: 2
+    day: 1
+  }
+  homepage: "https://crates.io/crates/csv-core"
+  identifier {
+    type: "Archive"
+    value: "https://static.crates.io/crates/csv-core/csv-core-0.1.11.crate"
+    version: "0.1.11"
   }
 }
diff --git a/src/writer.rs b/src/writer.rs
index 4f94301..ba196b6 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -26,6 +26,7 @@
             quote: b'"',
             escape: b'\\',
             double_quote: true,
+            comment: None,
         };
         WriterBuilder { wtr: wtr }
     }
@@ -56,6 +57,13 @@
             }
             _ => unreachable!(),
         }
+        // If the first field of a row starts with a comment character,
+        // it needs to be quoted, or the row will not be readable later.
+        // As requires_quotes is calculated in advance, we force quotes
+        // when a comment character is encountered anywhere in the field.
+        if let Some(comment) = self.wtr.comment {
+            wtr.requires_quotes[comment as usize] = true;
+        }
         wtr
     }
 
@@ -119,6 +127,17 @@
         self.wtr.double_quote = yes;
         self
     }
+
+    /// The comment character that will be used when later reading the file.
+    ///
+    /// If `quote_style` is set to `QuoteStyle::Necessary`, a field will
+    /// be quoted if the comment character is detected anywhere in the field.
+    ///
+    /// The default value is None.
+    pub fn comment(&mut self, comment: Option<u8>) -> &mut WriterBuilder {
+        self.wtr.comment = comment;
+        self
+    }
 }
 
 impl Default for WriterBuilder {
@@ -166,6 +185,7 @@
     quote: u8,
     escape: u8,
     double_quote: bool,
+    comment: Option<u8>,
 }
 
 impl Clone for Writer {
@@ -183,6 +203,7 @@
             quote: self.quote,
             escape: self.escape,
             double_quote: self.double_quote,
+            comment: self.comment,
         }
     }
 }
@@ -1044,4 +1065,21 @@
         inp = &inp[1..];
         assert_quote!(inp, out, 1, 2, InputEmpty, r#""""#);
     }
+
+    #[test]
+    fn comment_char_is_automatically_quoted() {
+        let mut wtr = WriterBuilder::new().comment(Some(b'#')).build();
+        let out = &mut [0; 1024];
+
+        assert_field!(
+            wtr,
+            b("# abc"),
+            &mut out[..],
+            5,
+            6,
+            InputEmpty,
+            "\"# abc"
+        );
+        assert_write!(wtr, finish, &mut out[..], 1, InputEmpty, "\"");
+    }
 }