aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2022-12-08 12:39:29 +0100
committerJeff Vander Stoep <jeffv@google.com>2022-12-08 14:50:39 +0100
commit8d75b009214193eeadd205ed56d252a8996a7e6f (patch)
treeea7b3edf74a63df4bfff0564b98b81f0f68d31ed
parent60c273cb2a2dcff6f53f5f4bb536d8940eadd285 (diff)
downloadcombine-8d75b009214193eeadd205ed56d252a8996a7e6f.tar.gz
Upgrade combine to 4.6.6
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/combine For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: I37570a8cfa0934a4772aecd0b28596e51d5cbf23
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--.github/workflows/rust.yml19
-rw-r--r--Android.bp3
-rw-r--r--CHANGELOG.md7
-rw-r--r--Cargo.lock.saved (renamed from Cargo.lock)2
-rw-r--r--Cargo.toml7
-rw-r--r--Cargo.toml.orig6
-rw-r--r--METADATA12
-rw-r--r--README.md10
-rwxr-xr-xci.sh31
-rw-r--r--src/parser/range.rs1
-rw-r--r--src/parser/sequence.rs73
-rw-r--r--src/stream/mod.rs10
-rw-r--r--tests/async.rs4
14 files changed, 113 insertions, 74 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 458621b..eacdbba 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "50a71afa1c88e8564e0220a6e0625dd16a2302a2"
+ "sha1": "cbc33e72627eac452806240d4bdb948465a4cbe1"
},
"path_in_vcs": ""
} \ No newline at end of file
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 94b0ed9..807ab87 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -22,7 +22,26 @@ jobs:
steps:
- uses: actions/checkout@v2
+
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust }}
+ override: true
+
- name: Build
run: cargo build
+
+ - name: Check 1.40
+ if: ${{ matrix.rust == '1.40.0' }}
+ run: |
+ cargo "$@" check
+ cargo "$@" check --no-default-features
+
- name: Run tests
+ if: ${{ matrix.rust != '1.40.0' }}
run: ./ci.sh
+
+ - name: Check docs
+ if: ${{ matrix.rust == 'stable' }}
+ run: cargo doc
diff --git a/Android.bp b/Android.bp
index 1f6df66..36a347e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -20,11 +20,10 @@ license {
rust_library {
name: "libcombine",
- // has rustc warnings
host_supported: true,
crate_name: "combine",
cargo_env_compat: true,
- cargo_pkg_version: "4.6.4",
+ cargo_pkg_version: "4.6.6",
srcs: ["src/lib.rs"],
edition: "2018",
features: [
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2beecf7..a2bf60d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+<a name="v4.6.5"></a>
+### v4.6.5 (2022-08-09)
+
+* memchr: use non deprecated feature `std` instead of `use_std`
+
+* refactor: Extract less-generic code from sequence's add_errors (-5%)
+
<a name="v4.6.4"></a>
### v4.6.4 (2022-04-25)
diff --git a/Cargo.lock b/Cargo.lock.saved
index b23775e..1900e9c 100644
--- a/Cargo.lock
+++ b/Cargo.lock.saved
@@ -257,7 +257,7 @@ dependencies = [
[[package]]
name = "combine"
-version = "4.6.4"
+version = "4.6.6"
dependencies = [
"async-std",
"bytes 0.5.6",
diff --git a/Cargo.toml b/Cargo.toml
index cc8ce00..b4e5996 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "combine"
-version = "4.6.4"
+version = "4.6.6"
authors = ["Markus Westerlind <marwes91@gmail.com>"]
description = "Fast parser combinators on arbitrary streams with zero-copy support."
documentation = "https://docs.rs/combine"
@@ -29,6 +29,7 @@ categories = [
]
license = "MIT"
repository = "https://github.com/Marwes/combine"
+resolver = "1"
[package.metadata.docs.rs]
all-features = true
@@ -108,7 +109,7 @@ default-features = false
package = "futures-io"
[dependencies.memchr]
-version = "2.2"
+version = "2.3"
default-features = false
[dependencies.pin-project-lite]
@@ -221,7 +222,7 @@ futures-03 = [
mp4 = []
pin-project = ["pin-project-lite"]
std = [
- "memchr/use_std",
+ "memchr/std",
"bytes",
"alloc",
]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 5d31969..c301500 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "combine"
-version = "4.6.4"
+version = "4.6.6"
authors = ["Markus Westerlind <marwes91@gmail.com>"]
description = "Fast parser combinators on arbitrary streams with zero-copy support."
@@ -28,7 +28,7 @@ path = "src/lib.rs"
[dependencies]
regex = { version = "1", optional = true }
-memchr = { version = "2.2", default-features = false }
+memchr = { version = "2.3", default-features = false }
pin-project-lite = { version = "0.2", optional = true }
# Future proofing so that tokio-0.3, tokio-0.1 etc can be supported
tokio-02-dep = { version = "0.2.3", package = "tokio", features = ["io-util"], default-features = false, optional = true }
@@ -64,7 +64,7 @@ tokio-02 = ["pin-project", "std", "tokio-02-dep", "futures-core-03", "pin-projec
tokio-03 = ["pin-project", "std", "tokio-03-dep", "futures-core-03", "pin-project-lite"]
tokio = ["tokio-dep", "tokio-util/io", "futures-core-03", "pin-project-lite"]
futures-03 = ["pin-project", "std", "futures-core-03", "futures-io-03", "pin-project-lite"]
-std = ["memchr/use_std", "bytes", "alloc"]
+std = ["memchr/std", "bytes", "alloc"]
alloc = []
[[test]]
diff --git a/METADATA b/METADATA
index d6be19b..6c436fc 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/combine
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
name: "combine"
description: "Fast parser combinators on arbitrary streams with zero-copy support."
third_party {
@@ -7,13 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/combine/combine-4.6.4.crate"
+ value: "https://static.crates.io/crates/combine/combine-4.6.6.crate"
}
- version: "4.6.4"
+ version: "4.6.6"
license_type: NOTICE
last_upgrade_date {
year: 2022
- month: 6
- day: 28
+ month: 12
+ day: 8
}
}
diff --git a/README.md b/README.md
index fa68ccf..5d67f1c 100644
--- a/README.md
+++ b/README.md
@@ -26,14 +26,20 @@ let result = parser.parse("Pick up that word!");
assert_eq!(result, Ok((Some("word".to_string()), "!")));
```
-A tutorial as well as explanations on what goes on inside combine can be found in [the wiki](https://github.com/Marwes/combine/wiki).
-
Larger examples can be found in the [examples][], [tests][] and [benches][] folders.
[examples]:https://github.com/Marwes/combine/tree/master/examples
[tests]:https://github.com/Marwes/combine/tree/master/tests
[benches]:https://github.com/Marwes/combine/tree/master/benches
+## Tutorial
+
+A tutorial as well as explanations on what goes on inside combine can be found in [the wiki](https://github.com/Marwes/combine/wiki).
+
+### Translation
+
+[Japanese](https://github.com/sadnessOjisan/combine-ja)
+
## Links
[Documentation and examples](https://docs.rs/crate/combine)
diff --git a/ci.sh b/ci.sh
index 6397319..c850263 100755
--- a/ci.sh
+++ b/ci.sh
@@ -1,27 +1,18 @@
#!/bin/bash -x
set -ex
-if [[ "$TRAVIS_RUST_VERSION" == "1.40.0" ]]; then
- cargo "$@" check
- cargo "$@" check --no-default-features
-else
- cargo "$@" build
- cargo "$@" test --all-features
- cargo "$@" test --all-features --examples
+cargo "$@" build
+cargo "$@" test --all-features
+cargo "$@" test --all-features --examples
- cargo "$@" test --bench json --bench http -- --test
- cargo "$@" check --bench mp4 --features mp4
-
- cargo "$@" build --no-default-features --features alloc
- cargo "$@" test --no-default-features --features alloc --examples
+cargo "$@" test --bench json --bench http -- --test
+cargo "$@" check --bench mp4 --features mp4
- cargo "$@" build --no-default-features
- cargo "$@" test --no-default-features --examples
+cargo "$@" build --no-default-features --features alloc
+cargo "$@" test --no-default-features --features alloc --examples
- cargo "$@" check --no-default-features --features tokio-02
- cargo "$@" check --no-default-features --features tokio-03
-fi
+cargo "$@" build --no-default-features
+cargo "$@" test --no-default-features --examples
-if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
- cargo doc
-fi
+cargo "$@" check --no-default-features --features tokio-02
+cargo "$@" check --no-default-features --features tokio-03
diff --git a/src/parser/range.rs b/src/parser/range.rs
index 7b53fe6..46353eb 100644
--- a/src/parser/range.rs
+++ b/src/parser/range.rs
@@ -85,7 +85,6 @@ parser! {
/// assert!(parser.parse("!").is_err());
/// # }
/// ```
- #[inline]
pub fn recognize[Input, P](parser: P)(Input) -> <Input as StreamOnce>::Range
where [
P: Parser<Input>,
diff --git a/src/parser/sequence.rs b/src/parser/sequence.rs
index 1c8bdcb..166b89d 100644
--- a/src/parser/sequence.rs
+++ b/src/parser/sequence.rs
@@ -14,17 +14,6 @@ use crate::{
ErrorOffset, Parser, Stream, StreamOnce,
};
-macro_rules! dispatch_on {
- ($i: expr, $f: expr;) => {
- };
- ($i: expr, $f: expr; $first: ident $(, $id: ident)*) => { {
- let b = $f($i, $first);
- if b {
- dispatch_on!($i + 1, $f; $($id),*);
- }
- } }
-}
-
macro_rules! count {
() => { 0 };
($f: ident) => { 1 };
@@ -63,6 +52,37 @@ macro_rules! last_ident {
($id: ident, $($rest: ident),+) => { last_ident!($($rest),+) };
}
+fn add_sequence_error<Input>(
+ i: &mut usize,
+ first_empty_parser: usize,
+ inner_offset: ErrorOffset,
+ err: &mut Tracked<Input::Error>,
+ parser: &mut impl Parser<Input>,
+) -> bool
+where
+ Input: Stream,
+{
+ if *i + 1 == first_empty_parser {
+ Parser::add_committed_expected_error(parser, err);
+ }
+ if *i >= first_empty_parser {
+ if err.offset <= ErrorOffset(1) {
+ // We reached the last parser we need to add errors to (and the
+ // parser that actually returned the error), use the returned
+ // offset for that parser.
+ err.offset = inner_offset;
+ }
+ Parser::add_error(parser, err);
+ if err.offset <= ErrorOffset(1) {
+ return false;
+ }
+ }
+ err.offset = ErrorOffset(err.offset.0.saturating_sub(Parser::parser_count(parser).0));
+
+ *i += 1;
+ true
+}
+
macro_rules! tuple_parser {
($partial_state: ident; $h: ident $(, $id: ident)*) => {
#[allow(non_snake_case)]
@@ -99,27 +119,20 @@ macro_rules! tuple_parser {
if let Ok(t) = input.uncons() {
err.error.add(StreamError::unexpected_token(t));
}
- dispatch_on!(0, |i, mut p| {
- if i + 1 == first_empty_parser {
- Parser::add_committed_expected_error(&mut p, &mut err);
+
+ #[allow(unused_assignments)]
+ let mut i = 0;
+ loop {
+ if !add_sequence_error(&mut i, first_empty_parser, inner_offset, &mut err, $h) {
+ break;
}
- if i >= first_empty_parser {
- if err.offset <= ErrorOffset(1) {
- // We reached the last parser we need to add errors to (and the
- // parser that actually returned the error), use the returned
- // offset for that parser.
- err.offset = inner_offset;
- }
- Parser::add_error(&mut p, &mut err);
- if err.offset <= ErrorOffset(1) {
- return false;
- }
+ $(
+ if !add_sequence_error(&mut i, first_empty_parser, inner_offset, &mut err, $id) {
+ break;
}
- err.offset = ErrorOffset(
- err.offset.0.saturating_sub(Parser::parser_count(&p).0)
- );
- true
- }; $h $(, $id)*);
+ )*
+ break;
+ }
CommitErr(err.error)
} else {
PeekErr(err)
diff --git a/src/stream/mod.rs b/src/stream/mod.rs
index ff9780e..b1f3d07 100644
--- a/src/stream/mod.rs
+++ b/src/stream/mod.rs
@@ -1401,7 +1401,7 @@ where
/// },
/// |input, _position| combine::easy::Stream::from(input),
/// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from),
-/// Ok(819),
+/// Ok(824),
/// );
/// ```
#[cfg(feature = "std")]
@@ -1497,7 +1497,7 @@ macro_rules! decode {
/// },
/// |input, _position| combine::easy::Stream::from(input),
/// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from),
-/// Ok(819),
+/// Ok(824),
/// );
/// }
/// ```
@@ -1591,7 +1591,7 @@ macro_rules! decode_futures_03 {
/// },
/// |input, _position| combine::easy::Stream::from(input),
/// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from),
-/// Ok(819),
+/// Ok(824),
/// );
/// }
/// ```
@@ -1687,7 +1687,7 @@ macro_rules! decode_tokio_02 {
/// },
/// |input, _position| combine::easy::Stream::from(input),
/// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from),
-/// Ok(819),
+/// Ok(824),
/// );
/// }
/// ```
@@ -1783,7 +1783,7 @@ macro_rules! decode_tokio_03 {
/// },
/// |input, _position| combine::easy::Stream::from(input),
/// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from),
-/// Ok(819),
+/// Ok(824),
/// );
/// }
/// ```
diff --git a/tests/async.rs b/tests/async.rs
index f5fb063..bedaa72 100644
--- a/tests/async.rs
+++ b/tests/async.rs
@@ -634,7 +634,7 @@ fn skip_count_min_max_test() {
assert_eq!(result.unwrap(), [""]);
}
-const WORDS_IN_README: usize = 819;
+const WORDS_IN_README: usize = 824;
#[test]
fn decode_std() {
@@ -850,5 +850,5 @@ async fn decode_loop() {
}
}
}
- assert_eq!(819, count);
+ assert_eq!(824, count);
}