mirror of
https://github.com/openharmony/third_party_rust_shlex.git
synced 2026-07-01 21:34:03 -04:00
@@ -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
|
||||
@@ -1,3 +1,8 @@
|
||||
# [unreleased]
|
||||
|
||||
* 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.
|
||||
|
||||
+6
-4
@@ -7,10 +7,12 @@ authors = [
|
||||
]
|
||||
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"]
|
||||
|
||||
@@ -3,7 +3,7 @@ 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:
|
||||
https://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,7 +11,12 @@ 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.
|
||||
|
||||
# LICENSE
|
||||
|
||||
The source code in this repository is Licensed under either of
|
||||
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||
https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
+17
-5
@@ -7,20 +7,32 @@
|
||||
//! 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:
|
||||
//! https://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
|
||||
|
||||
Reference in New Issue
Block a user