Snap for 8570526 from 6c8c682ec6b6207194f3c58612940eb8d0422fdd to mainline-networking-release

Change-Id: I2e5ed3e992869b9ab29534c1b45c3c251d984c62
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 2a7bde4..02eb82f 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
 {
   "git": {
-    "sha1": "618ad7a8bcbfbac1fdf1c473637a75e7f3055b2d"
+    "sha1": "8638f145d9356eed9c83e7b2f13c5209e72f0e27"
   }
 }
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..7f29991
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,36 @@
+name: Rust
+
+on:
+  pull_request:
+  push:
+
+jobs:
+  check:
+    name: Check
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: ATiltedTree/setup-rust@v1
+        with:
+          rust-version: stable
+      - run: cargo check
+
+  test:
+    name: Test
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: ATiltedTree/setup-rust@v1
+        with:
+          rust-version: stable
+      - run: cargo test
+  
+  test_no_default_features:
+    name: Test (no default features)
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: ATiltedTree/setup-rust@v1
+        with:
+          rust-version: stable
+      - run: cargo test --no-default-features
diff --git a/Android.bp b/Android.bp
index 13c18d8..1daa7a9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,5 @@
-// This file is generated by cargo2android.py --run --dependencies --tests.
+// This file is generated by cargo2android.py --config cargo2android.json.
+// Do not modify this file as changes will be overridden on upgrade.
 
 package {
     default_applicable_licenses: ["external_rust_crates_shlex_license"],
@@ -40,13 +41,21 @@
 rust_library_host {
     name: "libshlex",
     crate_name: "shlex",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.1.0",
     srcs: ["src/lib.rs"],
     edition: "2015",
+    features: [
+        "default",
+        "std",
+    ],
 }
 
 rust_test_host {
-    name: "shlex_host_test_src_lib",
+    name: "shlex_test_src_lib",
     crate_name: "shlex",
+    cargo_env_compat: true,
+    cargo_pkg_version: "1.1.0",
     srcs: ["src/lib.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
@@ -54,4 +63,8 @@
         unit_test: true,
     },
     edition: "2015",
+    features: [
+        "default",
+        "std",
+    ],
 }
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..50d2e6e
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,17 @@
+# 1.1.0
+
+* Adds the `std` feature (enabled by default)
+* Disabling the `std` feature makes the crate work in `#![no_std]` mode, assuming presence of the `alloc` crate
+
+# 1.0.0
+
+* Adds the `join` convenience function.
+* Fixes parsing of `'\\n'` to match the behavior of bash/Zsh/Python `shlex`. The result was previously `\n`, now it is `\\n`.
+
+# 0.1.1
+
+* Adds handling of `#` comments.
+
+# 0.1.0
+
+This is the initial release.
diff --git a/Cargo.toml b/Cargo.toml
index 4ac947e..2741ed8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,8 +12,13 @@
 
 [package]
 name = "shlex"
-version = "1.0.0"
+version = "1.1.0"
 authors = ["comex <comexk@gmail.com>", "Fenhl <fenhl@fenhl.net>"]
-description = "Split a string into shell words, like Python's shlex.\n"
+description = "Split a string into shell words, like Python's shlex."
+categories = ["command-line-interface", "parser-implementations"]
 license = "MIT OR Apache-2.0"
 repository = "https://github.com/comex/rust-shlex"
+
+[features]
+default = ["std"]
+std = []
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 0ca21e8..57fb62b 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,16 +1,18 @@
 [package]
 name = "shlex"
-version = "1.0.0"
+version = "1.1.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 = [
+description = "Split a string into shell words, like Python's shlex."
+categories = [
     "command-line-interface",
     "parser-implementations"
 ]
+
+[features]
+std = []
+default = ["std"]
diff --git a/METADATA b/METADATA
index 6c2b670..9ee61c1 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/shlex/shlex-1.0.0.crate"
+    value: "https://static.crates.io/crates/shlex/shlex-1.1.0.crate"
   }
-  version: "1.0.0"
+  version: "1.1.0"
   license_type: NOTICE
   last_upgrade_date {
     year: 2021
-    month: 2
-    day: 9
+    month: 9
+    day: 22
   }
 }
diff --git a/README.md b/README.md
index dad0ae1..6778828 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 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
+<https://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.
@@ -11,12 +11,17 @@
 The algorithms in this crate are oblivious to UTF-8 high bytes, so they iterate
 over the bytes directly as a micro-optimization.
 
+Disabling the `std` feature (which is enabled by default) will allow the crate
+to work in `no_std` environments, where the `alloc` crate, and a global
+allocator, are available.
+
 # 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)
+  https://www.apache.org/licenses/LICENSE-2.0)
 - MIT license ([LICENSE-MIT](LICENSE-MIT) or
-  http://opensource.org/licenses/MIT)
+  https://opensource.org/licenses/MIT)
 
 at your option.
 
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 58584f2..e4ec3b3 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,11 +1,24 @@
 // Generated by update_crate_tests.py for tests that depend on this crate.
 {
+  "imports": [
+    {
+      "path": "external/rust/crates/libsqlite3-sys"
+    }
+  ],
   "presubmit": [
     {
       "name": "keystore2_test"
     },
     {
-      "name": "libsqlite3-sys_device_test_src_lib"
+      "name": "legacykeystore_test"
+    }
+  ],
+  "presubmit-rust": [
+    {
+      "name": "keystore2_test"
+    },
+    {
+      "name": "legacykeystore_test"
     }
   ]
 }
diff --git a/cargo2android.json b/cargo2android.json
new file mode 100644
index 0000000..341300b
--- /dev/null
+++ b/cargo2android.json
@@ -0,0 +1,4 @@
+{
+  "run": true,
+  "tests": true
+}
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 6e06395..31b54bd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,26 +1,38 @@
 // Copyright 2015 Nicholas Allegra (comex).
-// Licensed under the Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> or
-// the MIT license <http://opensource.org/licenses/MIT>, at your option. This file may not be
+// Licensed under the Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> or
+// the MIT license <https://opensource.org/licenses/MIT>, at your option. This file may not be
 // copied, modified, or distributed except according to those terms.
 
 //! 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
+//! <https://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.
+//! 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.
+//!
+//! Disabling the `std` feature (which is enabled by default) will allow the crate to work in
+//! `no_std` environments, where the `alloc` crate, and a global allocator, are available.
 
-use std::borrow::Cow;
+#![cfg_attr(not(feature = "std"), no_std)]
+
+extern crate alloc;
+use alloc::vec::Vec;
+use alloc::borrow::Cow;
+use alloc::string::String;
+#[cfg(test)]
+use alloc::vec;
+#[cfg(test)]
+use alloc::borrow::ToOwned;
 
 /// An iterator that takes an input string and splits it into the words using the same syntax as
 /// the POSIX shell.
 pub struct Shlex<'a> {
-    in_iter: std::str::Bytes<'a>,
+    in_iter: core::str::Bytes<'a>,
     /// The number of newlines read so far, plus one.
     pub line_no: usize,
     /// An input string is erroneous if it ends while inside a quotation or right after an