Skip to content

Commit 5fc379d

Browse files
committed
Merge branch 'btoi'
2 parents b8def77 + c5c69bd commit 5fc379d

File tree

16 files changed

+432
-39
lines changed

16 files changed

+432
-39
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-actor/Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,24 @@ serde = ["dep:serde", "bstr/serde", "gix-date/serde"]
1919
[dependencies]
2020
gix-features = { version = "^0.38.0", path = "../gix-features", optional = true }
2121
gix-date = { version = "^0.8.3", path = "../gix-date" }
22+
gix-utils = { version = "^0.1.9", path = "../gix-utils" }
2223

2324
thiserror = "1.0.38"
24-
btoi = "0.4.2"
25-
bstr = { version = "1.3.0", default-features = false, features = ["std", "unicode"]}
25+
bstr = { version = "1.3.0", default-features = false, features = [
26+
"std",
27+
"unicode",
28+
] }
2629
winnow = { version = "0.6.0", features = ["simd"] }
2730
itoa = "1.0.1"
28-
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
31+
serde = { version = "1.0.114", optional = true, default-features = false, features = [
32+
"derive",
33+
] }
2934

3035
document-features = { version = "0.2.0", optional = true }
3136

3237
[dev-dependencies]
3338
pretty_assertions = "1.0.0"
34-
gix-testtools = { path = "../tests/tools"}
39+
gix-testtools = { path = "../tests/tools" }
3540
gix-hash = { path = "../gix-hash" }
3641

3742
[package.metadata.docs.rs]

gix-actor/src/signature/decode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub(crate) mod function {
22
use bstr::ByteSlice;
3-
use btoi::btoi;
43
use gix_date::{time::Sign, OffsetInSeconds, SecondsSinceUnixEpoch, Time};
4+
use gix_utils::btoi::to_signed;
55
use winnow::{
66
combinator::{alt, separated_pair, terminated},
77
error::{AddContext, ParserError, StrContext},
@@ -23,18 +23,18 @@ pub(crate) mod function {
2323
b" ",
2424
(
2525
terminated(take_until(0.., SPACE), take(1usize))
26-
.verify_map(|v| btoi::<SecondsSinceUnixEpoch>(v).ok())
26+
.verify_map(|v| to_signed::<SecondsSinceUnixEpoch>(v).ok())
2727
.context(StrContext::Expected("<timestamp>".into())),
2828
alt((
2929
take_while(1.., b'-').map(|_| Sign::Minus),
3030
take_while(1.., b'+').map(|_| Sign::Plus),
3131
))
3232
.context(StrContext::Expected("+|-".into())),
3333
take_while(2, AsChar::is_dec_digit)
34-
.verify_map(|v| btoi::<OffsetInSeconds>(v).ok())
34+
.verify_map(|v| to_signed::<OffsetInSeconds>(v).ok())
3535
.context(StrContext::Expected("HH".into())),
3636
take_while(1..=2, AsChar::is_dec_digit)
37-
.verify_map(|v| btoi::<OffsetInSeconds>(v).ok())
37+
.verify_map(|v| to_signed::<OffsetInSeconds>(v).ok())
3838
.context(StrContext::Expected("MM".into())),
3939
)
4040
.map(|(time, sign, hours, minutes)| {

gix-index/Cargo.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ test = true
2020
serde = ["dep:serde", "smallvec/serde", "gix-hash/serde"]
2121

2222
[dependencies]
23-
gix-features = { version = "^0.38.0", path = "../gix-features", features = ["rustsha1", "progress"] }
23+
gix-features = { version = "^0.38.0", path = "../gix-features", features = [
24+
"rustsha1",
25+
"progress",
26+
] }
2427
gix-hash = { version = "^0.14.1", path = "../gix-hash" }
2528
gix-bitmap = { version = "^0.2.10", path = "../gix-bitmap" }
2629
gix-object = { version = "^0.41.0", path = "../gix-object" }
2730
gix-traverse = { version = "^0.37.0", path = "../gix-traverse" }
2831
gix-lock = { version = "^13.0.0", path = "../gix-lock" }
2932
gix-fs = { version = "^0.10.0", path = "../gix-fs" }
33+
gix-utils = { version = "^0.1.9", path = "../gix-utils" }
3034

3135
hashbrown = "0.14.3"
3236
fnv = "1.0.7"
@@ -35,16 +39,20 @@ memmap2 = "0.9.0"
3539
filetime = "0.2.15"
3640
bstr = { version = "1.3.0", default-features = false }
3741

38-
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }
42+
serde = { version = "1.0.114", optional = true, default-features = false, features = [
43+
"derive",
44+
] }
3945
smallvec = "1.7.0"
40-
btoi = "0.4.3"
4146
itoa = "1.0.3"
4247
bitflags = "2"
4348

4449
document-features = { version = "0.2.0", optional = true }
4550

4651
[target.'cfg(not(windows))'.dependencies]
47-
rustix = { version = "0.38.20", default-features = false, features = ["std", "fs"] }
52+
rustix = { version = "0.38.20", default-features = false, features = [
53+
"std",
54+
"fs",
55+
] }
4856
libc = { version = "0.2.149" }
4957

5058
[package.metadata.docs.rs]

gix-index/src/extension/tree/decode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ fn one_recursive(data: &[u8], hash_len: usize) -> Option<(Tree, &[u8])> {
2222
let (path, data) = split_at_byte_exclusive(data, 0)?;
2323

2424
let (entry_count, data) = split_at_byte_exclusive(data, b' ')?;
25-
let num_entries: i32 = btoi::btoi(entry_count).ok()?;
25+
let num_entries: i32 = gix_utils::btoi::to_signed(entry_count).ok()?;
2626

2727
let (subtree_count, data) = split_at_byte_exclusive(data, b'\n')?;
28-
let subtree_count: usize = btoi::btou(subtree_count).ok()?;
28+
let subtree_count: usize = gix_utils::btoi::to_unsigned(subtree_count).ok()?;
2929

3030
let (id, mut data) = if num_entries >= 0 {
3131
let (hash, data) = split_at_pos(data, hash_len)?;

gix-object/Cargo.toml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,49 @@ path = "./benches/decode_objects.rs"
2020

2121
[features]
2222
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
23-
serde = ["dep:serde", "bstr/serde", "smallvec/serde", "gix-hash/serde", "gix-actor/serde"]
23+
serde = [
24+
"dep:serde",
25+
"bstr/serde",
26+
"smallvec/serde",
27+
"gix-hash/serde",
28+
"gix-actor/serde",
29+
]
2430
## When parsing objects by default errors will only be available on the granularity of success or failure, and with the above flag enabled
2531
## details information about the error location will be collected.
2632
## Use it in applications which expect broken or invalid objects or for debugging purposes. Incorrectly formatted objects aren't at all
2733
## common otherwise.
2834
verbose-object-parsing-errors = ["winnow/std"]
2935

3036
[dependencies]
31-
gix-features = { version = "^0.38.0", path = "../gix-features", features = ["rustsha1", "progress"] }
37+
gix-features = { version = "^0.38.0", path = "../gix-features", features = [
38+
"rustsha1",
39+
"progress",
40+
] }
3241
gix-hash = { version = "^0.14.1", path = "../gix-hash" }
3342
gix-validate = { version = "^0.8.3", path = "../gix-validate" }
3443
gix-actor = { version = "^0.30.0", path = "../gix-actor" }
3544
gix-date = { version = "^0.8.3", path = "../gix-date" }
45+
gix-utils = { version = "^0.1.9", path = "../gix-utils" }
3646

37-
btoi = "0.4.2"
3847
itoa = "1.0.1"
3948
thiserror = "1.0.34"
40-
bstr = { version = "1.3.0", default-features = false, features = ["std", "unicode"] }
49+
bstr = { version = "1.3.0", default-features = false, features = [
50+
"std",
51+
"unicode",
52+
] }
4153
winnow = { version = "0.6.0", features = ["simd"] }
4254
smallvec = { version = "1.4.0", features = ["write"] }
43-
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
55+
serde = { version = "1.0.114", optional = true, default-features = false, features = [
56+
"derive",
57+
] }
4458

4559
document-features = { version = "0.2.0", optional = true }
4660

4761
[dev-dependencies]
4862
criterion = "0.5.1"
4963
pretty_assertions = "1.0.0"
50-
gix-testtools = { path = "../tests/tools"}
64+
gix-testtools = { path = "../tests/tools" }
5165

5266
[package.metadata.docs.rs]
5367
all-features = true
5468
features = ["document-features"]
55-

gix-object/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub mod decode {
358358
pub enum LooseHeaderDecodeError {
359359
#[error("{message}: {number:?}")]
360360
ParseIntegerError {
361-
source: btoi::ParseIntegerError,
361+
source: gix_utils::btoi::ParseIntegerError,
362362
message: &'static str,
363363
number: bstr::BString,
364364
},
@@ -383,7 +383,7 @@ pub mod decode {
383383
message: "Did not find 0 byte in header",
384384
})?;
385385
let size_bytes = &input[kind_end + 1..size_end];
386-
let size = btoi::btoi(size_bytes).map_err(|source| ParseIntegerError {
386+
let size = gix_utils::btoi::to_signed(size_bytes).map_err(|source| ParseIntegerError {
387387
source,
388388
message: "Object size in header could not be parsed",
389389
number: size_bytes.into(),

gix-protocol/Cargo.toml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ doctest = false
2323
## If set, blocking command implementations are available and will use the blocking version of the `gix-transport` crate.
2424
blocking-client = ["gix-transport/blocking-client", "maybe-async/is_sync"]
2525
## As above, but provides async implementations instead.
26-
async-client = ["gix-transport/async-client", "async-trait", "futures-io", "futures-lite"]
26+
async-client = [
27+
"gix-transport/async-client",
28+
"async-trait",
29+
"futures-io",
30+
"futures-lite",
31+
]
2732

2833
#! ### Other
2934
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
@@ -40,17 +45,24 @@ path = "tests/async-protocol.rs"
4045
required-features = ["async-client"]
4146

4247
[dependencies]
43-
gix-features = { version = "^0.38.0", path = "../gix-features", features = ["progress"] }
48+
gix-features = { version = "^0.38.0", path = "../gix-features", features = [
49+
"progress",
50+
] }
4451
gix-transport = { version = "^0.41.0", path = "../gix-transport" }
4552
gix-hash = { version = "^0.14.1", path = "../gix-hash" }
4653
gix-date = { version = "^0.8.3", path = "../gix-date" }
4754
gix-credentials = { version = "^0.24.0", path = "../gix-credentials" }
55+
gix-utils = { version = "^0.1.9", path = "../gix-utils" }
4856

4957
thiserror = "1.0.32"
50-
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
51-
bstr = { version = "1.3.0", default-features = false, features = ["std", "unicode"] }
58+
serde = { version = "1.0.114", optional = true, default-features = false, features = [
59+
"derive",
60+
] }
61+
bstr = { version = "1.3.0", default-features = false, features = [
62+
"std",
63+
"unicode",
64+
] }
5265
winnow = { version = "0.6.0", features = ["simd"] }
53-
btoi = "0.4.2"
5466

5567
# for async-client
5668
async-trait = { version = "0.1.51", optional = true }
@@ -62,7 +74,7 @@ document-features = { version = "0.2.0", optional = true }
6274

6375
[dev-dependencies]
6476
async-std = { version = "1.9.0", features = ["attributes"] }
65-
gix-packetline = { path = "../gix-packetline" ,version = "^0.17.3" }
77+
gix-packetline = { path = "../gix-packetline", version = "^0.17.3" }
6678
gix-testtools = { path = "../tests/tools" }
6779

6880
[package.metadata.docs.rs]

gix-protocol/src/remote_progress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> RemoteProgress<'a> {
7575

7676
fn parse_number(i: &mut &[u8]) -> PResult<usize, ()> {
7777
take_till(0.., |c: u8| !c.is_ascii_digit())
78-
.try_map(btoi::btoi)
78+
.try_map(gix_utils::btoi::to_signed)
7979
.parse_next(i)
8080
}
8181

gix-quote/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include = ["src/**/*", "LICENSE-*"]
1313
doctest = false
1414

1515
[dependencies]
16-
bstr = { version = "1.3.0", default-features = false, features = ["std"]}
16+
gix-utils = { version = "^0.1.9", path = "../gix-utils" }
17+
18+
bstr = { version = "1.3.0", default-features = false, features = ["std"] }
1719
thiserror = "1.0.38"
18-
btoi = "0.4.2"

gix-quote/src/ansi_c.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ pub fn undo(input: &BStr) -> Result<(Cow<'_, BStr>, usize), undo::Error> {
8989
})?
9090
.read_exact(&mut buf[1..])
9191
.expect("impossible to fail as numbers match");
92-
let byte = btoi::btou_radix(&buf, 8).map_err(|e| undo::Error::new(e, original))?;
92+
let byte = gix_utils::btoi::to_unsigned_with_radix(&buf, 8)
93+
.map_err(|e| undo::Error::new(e, original))?;
9394
out.push(byte);
9495
input = &input[2..];
9596
consumed += 2;

gix-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rust-version = "1.65"
1010
include = ["src/**/*", "LICENSE-*"]
1111

1212
[lib]
13-
doctest = false
13+
doctest = true
1414

1515
[features]
1616
bstr = ["dep:bstr"]

0 commit comments

Comments
 (0)