Commit graph

190 commits

Author SHA1 Message Date
Jed Denlea e5b46ea3eb wc: more tests and fixes
My previous commits meant to bring our wc's output and behavior in line
with GNU's. There should be tests that check for these changes!

I found a stupid bug in my own changes, I was not adding 1 to the
indexes produced by .enumerate() when printing errors.
2023-05-22 01:02:35 -07:00
Daniel Hofstetter 690fff2fc9 cksum: implement --untagged 2023-05-14 16:43:14 +02:00
Daniel Hofstetter 0781ad0a65 cksum: fix output of --algorithm
for the algorithms md5, sha[1,224,256,384,512], blake2b, and sm3 from

<digest> <filesize> <filename>

to

<algo name> (<filename>) = <digest>

to use the same format as GNU cksum
2023-05-11 14:24:43 +02:00
Daniel Hofstetter 0d782e09c1 comm: implement --zero-terminated 2023-03-01 16:59:51 +01:00
Yang Hau 678a11dcf2 cksum: Implement option -a
Implement option -a --algorithm.
Move digest to src/uucore/src/lib/features and rename it to hash.

fix lint

fix Cargo.toml
2023-02-18 20:58:53 +08:00
Daniel Hofstetter ccf999473c comm: use delimiter on "total" line 2023-02-07 09:22:55 +01:00
Daniel Hofstetter b06485990d comm: implement --total 2023-01-24 16:49:43 +01:00
Daniel Hofstetter 747bc2513e sum: fix output when using BSD sum algo (-r) 2023-01-13 10:05:09 +01:00
TechHara f6a0abaee3 add whitespace delimiter option 2022-12-12 12:00:57 -05:00
Andrew Baptist 4922d34177 Match GNU semantics for missing EOF
While the rust coreutils semantics were arguably more correct,
they were different than the gnu split semantics when handling a
file without a trailing EOF. This patch addresses that difference
and allows passing one more GNU test suite.
2022-10-07 17:50:26 -04:00
Owen Anderson 08d3da8f6c
Fix a TODO by making conv_block_unblock_helper consume the input. (#3787)
* Fix a TODO by making `conv_block_unblock_helper` consume the input.
2022-08-28 10:07:04 +02:00
Daniel Hofstetter ac35a1b985 comm: use NUL if delimiter is empty 2022-07-06 13:50:23 +02:00
Jan Scheer 8ee806a444
Merge branch 'main' into tail_notify 2022-06-02 16:31:25 +02:00
Daniel Hofstetter 6d82523a99 dircolors: implement --print-ls-colors 2022-05-30 09:11:27 +02:00
Jan Scheer 6bd9a1d537
Merge branch 'main' into tail_notify 2022-05-26 00:33:12 +02:00
Daniel Hofstetter ba746250fb dircolors: update internal db 2022-05-24 13:56:15 +02:00
Jan Scheer 409878e323
Merge branch 'main' into tail_notify 2022-05-16 22:45:52 +02:00
Michael Kefeder 83a64f4afe ptx: escape regular expression character class special chars 2022-04-30 10:01:11 +02:00
Michael Kefeder 994dedd6d9 tests/ptx: added breakfile option tests 2022-04-29 10:15:06 +02:00
Michael Kefeder c6ad244142 tests/ptx: verify output width is handled correctly 2022-04-28 16:46:10 +02:00
Jan Scheer 6e1e3ac012
Merge branch 'main' into tail_notify 2022-04-23 00:26:59 +02:00
Justin Tracey 2a0d58d060 get android builds to compile and pass tests 2022-04-20 08:44:49 +02:00
Jan Scheer eb21330ade
Merge branch 'main' into tail_notify 2022-04-19 22:14:55 +02:00
chordtoll b77b3cba55 dd: implement iseek + oseek flags
These are the first half of changes needed to pass the dd/bytes.sh tests:
- Add iseek and oseek options (additive with skip and seek options)
- Implement tests for the new flags, matching those from dd/bytes.sh
2022-03-18 20:45:04 +01:00
Jeffrey Finkelstein 77d92883c7 split: implement --line-bytes option
Implement the `--line-bytes` option to `split`. In this mode, the
program tries to write as many lines of the input as possible to each
chunk of output without exceeding a specified byte limit. The new
`LineBytesChunkWriter` struct represents this functionality.
2022-03-10 22:51:49 -05:00
Jeffrey Finkelstein ee36dea1a9 split: implement outputting kth chunk of file
Implement `-n l/k/N` option, where the `k`th chunk of the input file
is written to stdout. For example,

    $ seq -w 0 99 > f; split -n l/3/10 f
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
2022-03-05 10:27:51 +01:00
Jeffrey Finkelstein 6718d97f97 split: add support for -e argument
Add the `-e` flag, which indicates whether to elide (that is, remove)
empty files that would have been created by the `-n` option.

The `-n` command-line argument gives a specific number of chunks into
which the input files will be split. If the number of chunks is
greater than the number of bytes, then empty files will be created for
the excess chunks. But if `-e` is given, then empty files will not be
created.

For example, contrast

    $ printf 'a\n' > f && split -e -n 3 f && cat xaa xab xac
    a
    cat: xac: No such file or directory

with

    $ printf 'a\n' > f && split -n 3 f && cat xaa xab xac
    a
2022-02-17 19:03:51 -05:00
Terts Diepraam e1a611374a
Merge pull request #2981 from jfinkels/split-hex-numbers
split: add support for -x option (hex suffixes)
2022-02-17 23:20:58 +01:00
Jeffrey Finkelstein ba1ce7179b dd: move unit tests into dd.rs and test_dd.rs
Clean up unit tests in the `dd` crate to make them easier to
manage. This commit does a few things.

* move test cases that test the complete functionality of the `dd`
  program from the `dd_unit_tests` module up to the
  `tests/by-util/test_dd.rs` module so that they can take advantage of
  the testing framework and common testing tools provided by uutils,
* move test cases that test internal functions of the `dd`
  implementation into the `tests` module within `dd.rs` so that they
  live closer to the code they are testing,
* replace test cases defined by macros with test cases defined by
  plain old functions to make the test cases easier to read at a
  glance.
2022-02-15 21:50:48 -05:00
Jeffrey Finkelstein a4955b4e06 split: add support for -x option (hex suffixes)
Add support for the `-x` command-line option to `split`. This option
causes `split` to produce filenames with hexadecimal suffixes instead
of the default alphabetic suffixes.
2022-02-13 11:18:37 -05:00
Sylvestre Ledru f9e04ae5ef
Merge pull request #2966 from allan-silva/wc-files0-from-opt
wc: implement files0-from option
2022-02-12 19:05:05 +01:00
Sylvestre Ledru 6b6d5ee7db
Merge pull request #2827 from jfinkels/split-std-io-copy
split: use std::io::copy() with new writer implementation to improve maintainability and speed
2022-02-12 11:33:12 +01:00
Shreyans Jain 3176ad5c1b
tests/hashsum: Fix missing space in checkfile 2022-02-10 13:55:53 +05:30
Shreyans Jain 30d7a4b167
hashsum: Add BLAKE3 to Hashing Algorithms
Signed-off-by: Shreyans Jain <shreyansthebest2007@gmail.com>
2022-02-10 12:46:44 +05:30
Jeffrey Finkelstein 1d7e1b8732 split: use ByteChunkWriter and LineChunkWriter
Replace `ByteSplitter` and `LineSplitter` with `ByteChunkWriter` and
`LineChunkWriter` respectively. This results in a more maintainable
design and an increase in the speed of splitting by lines.
2022-02-08 22:57:57 -05:00
Jeffrey Finkelstein ca7af808d5 tests: correct a test case for split
Correct the `test_split::test_suffixes_exhausted` test case so that it
actually exercises the intended behavior of `split`. Previously, the
test fixture contained 26 bytes. After this commit, the test fixture
contains 27 bytes. When using a suffix width of one, only 26 filenames
should be available when naming chunk files---one for each lowercase
ASCII letter. This commit ensures that the filenames will be exhausted
as intended by the test.
2022-02-08 22:53:57 -05:00
Allan Silva 6a6875012e wc: implement files0-from option
When this option is present, the files argument is not processed. This option processes the file list from provided file, splitting them by the ascii NUL (\0) character. When files0-from is '-', the file list is processed from stdin.
2022-02-04 10:12:08 -03:00
Terts Diepraam 7fc82cd376
Merge pull request #2902 from jtracey/join-non-unicode-sep
join: add support for non-unicode field separators
2022-01-31 21:54:56 +01:00
Terts Diepraam 7477761428
Merge pull request #2882 from jtracey/join-bigfields-compat
join: "support" field numbers larger than usize::MAX
2022-01-31 21:52:13 +01:00
Justin Tracey 58d65fb953 join: add support for non-unicode field separators
This allows for `-t` to take invalid unicode (but still single-byte) values
on unix-like platforms. Other platforms, which as of the time of this commit
do not support `OsStr::as_bytes()`, could possibly be supported in the future,
but would require design decisions as to what that means.
2022-01-30 20:04:22 -05:00
Sylvestre Ledru 7c1abdb7d9
Merge pull request #2866 from jfinkels/split-number-2
split: implement -n option
2022-01-30 09:58:04 +01:00
Sylvestre Ledru 52ab6325a0
Merge pull request #2881 from jtracey/join-null-field-sep
join: add support for `-t '\0'`
2022-01-29 10:55:04 +01:00
Jeffrey Finkelstein b636ff04a0 split: implement -n option
Implement the `-n` command-line option to `split`, which splits a file
into a specified number of chunks by byte.
2022-01-27 21:16:27 -05:00
Cecylia Bocovich c8f9ea5b15
tests/join: test default check order behaviour 2022-01-22 17:51:29 -05:00
Justin Tracey ce3df12eaa join: "support" field numbers larger than usize::MAX
They silently get folded to usize::MAX, which is the official GNU behavior.
2022-01-17 17:49:41 -05:00
Terts Diepraam 08efa1fe5a
Merge branch 'main' into join-null-field-sep 2022-01-17 12:59:52 +01:00
Justin Tracey 109277d405 join: add support for -t '\0' 2022-01-16 18:05:58 -05:00
Justin Tracey 346415e1d2 join: add support for -z option 2022-01-16 17:56:07 -05:00
Sylvestre Ledru 00c11b184f
Merge pull request #2851 from jtracey/join-strless
join: operate on bytes instead of Strings
2022-01-16 16:24:38 +01:00
Jeffrey Finkelstein cfe5a0d82c split: correct filename creation algorithm
Fix two issues with the filename creation algorithm. First, this
corrects the behavior of the `-a` option. This commit ensures a
failure occurs when the number of chunks exceeds the number of
filenames representable with the specified fixed width:

    $ printf "%0.sa" {1..11} | split -d -b 1 -a 1
    split: output file suffixes exhausted

Second, this corrects the behavior of the default behavior when `-a`
is not specified on the command line. Previously, it was always
settings the filenames to have length 2 suffixes. This commit corrects
the behavior to follow the algorithm implied by GNU split, where the
filename lengths grow dynamically by two characters once the number of
chunks grows sufficiently large:

    $ printf "%0.sa" {1..91} | ./target/debug/coreutils split -d -b 1 \
    >   && ls x* | tail
    x81
    x82
    x83
    x84
    x85
    x86
    x87
    x88
    x89
    x9000
2022-01-10 20:43:22 -05:00