Snap for 7183507 from 1a641a11cc4e8093e6c6863ff3aa8ac2c8aa3cdd to sdk-release

Change-Id: I9e4b41e9365c062bbd683827d7d241290b1214cd
diff --git a/.Cargo.toml.swp b/.Cargo.toml.swp
deleted file mode 100644
index 48d9460..0000000
--- a/.Cargo.toml.swp
+++ /dev/null
Binary files differ
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
new file mode 100644
index 0000000..2a7bde4
--- /dev/null
+++ b/.cargo_vcs_info.json
@@ -0,0 +1,5 @@
+{
+  "git": {
+    "sha1": "618ad7a8bcbfbac1fdf1c473637a75e7f3055b2d"
+  }
+}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cd23ebe
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/target/
+Cargo.lock
+**/*.rs.bk
diff --git a/Android.bp b/Android.bp
index df09755..13c18d8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,42 @@
 // This file is generated by cargo2android.py --run --dependencies --tests.
 
+package {
+    default_applicable_licenses: ["external_rust_crates_shlex_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+//
+// large-scale-change included anything that looked like it might be a license
+// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
+//
+// Please consider removing redundant or irrelevant files from 'license_text:'.
+// See: http://go/android-license-faq
+license {
+    name: "external_rust_crates_shlex_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE",
+        "LICENSE-APACHE",
+        "LICENSE-MIT",
+    ],
+}
+
 rust_library_host {
     name: "libshlex",
     crate_name: "shlex",
@@ -13,5 +50,8 @@
     srcs: ["src/lib.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
     edition: "2015",
 }
diff --git a/Cargo.toml b/Cargo.toml
index 0928ee2..4ac947e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,19 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# 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
+#
+# 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)
+
 [package]
 name = "shlex"
-version = "0.1.1"
-authors = ["comex <comexk@gmail.com>"]
-license = "MIT/Apache-2.0"
+version = "1.0.0"
+authors = ["comex <comexk@gmail.com>", "Fenhl <fenhl@fenhl.net>"]
+description = "Split a string into shell words, like Python's shlex.\n"
+license = "MIT OR Apache-2.0"
 repository = "https://github.com/comex/rust-shlex"
-description = """
-Split a string into shell words, like Python's shlex.
-"""
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
new file mode 100644
index 0000000..0ca21e8
--- /dev/null
+++ b/Cargo.toml.orig
@@ -0,0 +1,16 @@
+[package]
+name = "shlex"
+version = "1.0.0"
+authors = [
+    "comex <comexk@gmail.com>",
+    "Fenhl <fenhl@fenhl.net>"
+]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/comex/rust-shlex"
+description = """
+Split a string into shell words, like Python's shlex.
+"""
+caegories = [
+    "command-line-interface",
+    "parser-implementations"
+]
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 0000000..3746504
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,13 @@
+Copyright 2015 Nicholas Allegra (comex).
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..5ec1fe1
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Nicholas Allegra (comex).
+
+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 ada5e8d..6c2b670 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/shlex/shlex-0.1.1.crate"
+    value: "https://static.crates.io/crates/shlex/shlex-1.0.0.crate"
   }
-  version: "0.1.1"
+  version: "1.0.0"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2020
-    month: 3
-    day: 31
+    year: 2021
+    month: 2
+    day: 9
   }
 }
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dad0ae1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+
+Same idea as (but implementation not directly based on) the Python shlex
+module. However, this implementation does not support any of the Python
+module's customization because it makes parsing slower and is fairly useless.
+You only get the default settings of shlex.split, which mimic the POSIX shell:
+http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
+
+This implementation also deviates from the Python version in not treating \r
+specially, which I believe is more compliant.
+
+The algorithms in this crate are oblivious to UTF-8 high bytes, so they iterate
+over the bytes directly as a micro-optimization.
+
+# LICENSE
+The source code in this repository is Licensed under either of
+- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
+  http://www.apache.org/licenses/LICENSE-2.0)
+- MIT license ([LICENSE-MIT](LICENSE-MIT) or
+  http://opensource.org/licenses/MIT)
+
+at your option.
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall
+be dual licensed as above, without any additional terms or conditions.
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 092edf5..58584f2 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,13 +1,8 @@
-// Generated by cargo2android.py for tests in Android.bp
+// Generated by update_crate_tests.py for tests that depend on this crate.
 {
   "presubmit": [
     {
-      "host": true,
-      "name": "shlex_host_test_src_lib"
-    },
-    {
-      "host": true,
-      "name": "libsqlite3-sys_host_test_src_lib"
+      "name": "keystore2_test"
     },
     {
       "name": "libsqlite3-sys_device_test_src_lib"
diff --git a/src/.lib.rs.swp b/src/.lib.rs.swp
deleted file mode 100644
index cced600..0000000
--- a/src/.lib.rs.swp
+++ /dev/null
Binary files differ
diff --git a/src/lib.rs b/src/lib.rs
index 6ff8c97..6e06395 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -96,17 +96,6 @@
         loop {
             if let Some(ch2) = self.next_char() {
                 match ch2 as char {
-                    '\\' => {
-                        if let Some(ch3) = self.next_char() {
-                            match ch3 as char {
-                                // for single quotes, only these can be escaped
-                                '\'' | '\\' => { result.push(ch3); },
-                                _ => { result.push('\\' as u8); result.push(ch3); }
-                            }
-                        } else {
-                            return Err(());
-                        }
-                    },
                     '\'' => { return Ok(()); },
                     _ => { result.push(ch2); },
                 }
@@ -181,6 +170,15 @@
     }
 }
 
+/// Convenience function that consumes an iterable of words and turns it into a single string,
+/// quoting words when necessary. Consecutive words will be separated by a single space.
+pub fn join<'a, I: IntoIterator<Item = &'a str>>(words: I) -> String {
+    words.into_iter()
+        .map(quote)
+        .collect::<Vec<_>>()
+        .join(" ")
+}
+
 #[cfg(test)]
 static SPLIT_TEST_ITEMS: &'static [(&'static str, Option<&'static [&'static str]>)] = &[
     ("foo$baz", Some(&["foo$baz"])),
@@ -191,7 +189,7 @@
     ("foo\\\nbar", Some(&["foobar"])),
     ("\"foo\\\nbar\"", Some(&["foobar"])),
     ("'baz\\$b'", Some(&["baz\\$b"])),
-    ("'baz\\\''", Some(&["baz\'"])),
+    ("'baz\\\''", None),
     ("\\", None),
     ("\"\\", None),
     ("'\\", None),
@@ -201,6 +199,8 @@
     ("foo #bar", Some(&["foo"])),
     ("foo#bar", Some(&["foo#bar"])),
     ("foo\"#bar", None),
+    ("'\\n'", Some(&["\\n"])),
+    ("'\\\\n'", Some(&["\\\\n"])),
 ];
 
 #[test]
@@ -227,3 +227,11 @@
     assert_eq!(quote("\""), "\"\\\"\"");
     assert_eq!(quote(""), "\"\"");
 }
+
+#[test]
+fn test_join() {
+    assert_eq!(join(vec![]), "");
+    assert_eq!(join(vec![""]), "\"\"");
+    assert_eq!(join(vec!["a", "b"]), "a b");
+    assert_eq!(join(vec!["foo bar", "baz"]), "\"foo bar\" baz");
+}