Skip to content

Commit ba3346d

Browse files
authored
Merge branch 'main' into install-stream
2 parents 8ebdc06 + 7c65243 commit ba3346d

File tree

8 files changed

+187
-52
lines changed

8 files changed

+187
-52
lines changed

.vscode/cspell.dictionaries/jargon.wordlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ retval
157157
subdir
158158
val
159159
vals
160+
inval
161+
nofield
160162

161163
# * clippy
162164
uninlined

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ walkdir = "2.5"
342342
winapi-util = "0.1.8"
343343
windows-sys = { version = "0.59.0", default-features = false }
344344
xattr = "1.3.1"
345-
zip = { version = "1.1.4", default-features = false, features = ["deflate"] }
345+
zip = { version = "2.2.2", default-features = false, features = ["deflate"] }
346346

347347
hex = "0.4.3"
348348
md-5 = "0.10.6"

src/uu/base32/src/base_common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
1111
use std::path::{Path, PathBuf};
1212
use uucore::display::Quotable;
1313
use uucore::encoding::{
14-
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER},
14+
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER_PERMISSIVE},
1515
Format, Z85Wrapper, BASE2LSBF, BASE2MSBF,
1616
};
1717
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
@@ -226,11 +226,11 @@ pub fn get_supports_fast_decode_and_encode(
226226

227227
match format {
228228
Format::Base16 => Box::from(EncodingWrapper::new(
229-
HEXUPPER,
229+
HEXUPPER_PERMISSIVE,
230230
BASE16_VALID_DECODING_MULTIPLE,
231231
BASE16_UNPADDED_MULTIPLE,
232232
// spell-checker:disable-next-line
233-
b"0123456789ABCDEF",
233+
b"0123456789ABCDEFabcdef",
234234
)),
235235
Format::Base2Lsbf => Box::from(EncodingWrapper::new(
236236
BASE2LSBF,

src/uu/cut/src/cut.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ fn cut_fields_explicit_out_delim<R: Read, M: Matcher>(
131131

132132
if delim_search.peek().is_none() {
133133
if !only_delimited {
134+
// Always write the entire line, even if it doesn't end with `newline_char`
134135
out.write_all(line)?;
135-
if line[line.len() - 1] != newline_char {
136+
if line.is_empty() || line[line.len() - 1] != newline_char {
136137
out.write_all(&[newline_char])?;
137138
}
138139
}
@@ -213,8 +214,12 @@ fn cut_fields_implicit_out_delim<R: Read, M: Matcher>(
213214
let mut print_delim = false;
214215

215216
if delim_search.peek().is_none() {
216-
if !only_delimited && line[line.len() - 1] == newline_char {
217+
if !only_delimited {
218+
// Always write the entire line, even if it doesn't end with `newline_char`
217219
out.write_all(line)?;
220+
if line.is_empty() || line[line.len() - 1] != newline_char {
221+
out.write_all(&[newline_char])?;
222+
}
218223
}
219224

220225
return Ok(true);

tests/by-util/test_basenc.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ fn test_base16_decode() {
130130
.stdout_only("Hello, World!");
131131
}
132132

133+
#[test]
134+
fn test_base16_decode_lowercase() {
135+
new_ucmd!()
136+
.args(&["--base16", "-d"])
137+
.pipe_in("48656c6c6f2c20576f726c6421")
138+
.succeeds()
139+
.stdout_only("Hello, World!");
140+
}
141+
142+
#[test]
143+
fn test_base16_decode_and_ignore_garbage_lowercase() {
144+
new_ucmd!()
145+
.args(&["--base16", "-d", "-i"])
146+
.pipe_in("48656c6c6f2c20576f726c6421")
147+
.succeeds()
148+
.stdout_only("Hello, World!");
149+
}
150+
133151
#[test]
134152
fn test_base2msbf() {
135153
new_ucmd!()

tests/by-util/test_cut.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5+
6+
// spell-checker:ignore defg
7+
58
use crate::common::util::TestScenario;
69

710
static INPUT: &str = "lists.txt";
@@ -288,7 +291,7 @@ fn test_newline_delimited() {
288291
.args(&["-f", "1", "-d", "\n"])
289292
.pipe_in("a:1\nb:")
290293
.succeeds()
291-
.stdout_only_bytes("a:1\n");
294+
.stdout_only_bytes("a:1\nb:\n");
292295
}
293296

294297
#[test]
@@ -329,3 +332,31 @@ fn test_8bit_non_utf8_delimiter() {
329332
.succeeds()
330333
.stdout_check(|out| out == "b_c\n".as_bytes());
331334
}
335+
336+
#[test]
337+
fn test_newline_preservation_with_f1_option() {
338+
let (at, mut ucmd) = at_and_ucmd!();
339+
at.write("1", "a\nb");
340+
let expected = "a\nb\n";
341+
ucmd.args(&["-f1-", "1"]).succeeds().stdout_is(expected);
342+
}
343+
344+
#[ignore = "Not yet implemented"]
345+
#[test]
346+
fn test_output_delimiter_with_character_ranges() {
347+
new_ucmd!()
348+
.args(&["-c2-3,4-", "--output-delim=:"])
349+
.pipe_in("abcdefg\n")
350+
.succeeds()
351+
.stdout_only("bc:defg\n");
352+
}
353+
354+
#[ignore = "Not yet implemented"]
355+
#[test]
356+
fn test_output_delimiter_with_adjacent_ranges() {
357+
new_ucmd!()
358+
.args(&["-b1-2,3-4", "--output-d=:"])
359+
.pipe_in("abcd\n")
360+
.succeeds()
361+
.stdout_only("ab:cd\n");
362+
}

0 commit comments

Comments
 (0)