17 Commits

Author SHA1 Message Date
Sami Daniel 8105420bb4 Create the side-by-side option (-y) feature for the diff command (Incomplete).
- Create the function, in the utils package, limited_string that allows you to truncate a string based on a
delimiter (May break the encoding of the character where it was cut)

- Create tests for limited_string function

- Add support for -y and --side-by-side flags that enables diff output for side-by-side mode

- Create implementation of the diff -y (SideBySide) command, base command for sdiff, using the crate
diff as engine. Currently it does not fully represent GNU diff -y, some flags (|, (, ), , /) could
not be developed due to the limitation of the engine we currently use (crate diff), which did not
allow perform logic around it. Only the use of '<' and '>' were enabled.

- Create tests for SideBySide implementation
2025-06-02 22:32:11 -03:00
Gustavo Noronha Silva 50057412bd Add cmp utility
The utility should support all the arguments supported by GNU cmp and
perform slightly better.

On a "bad" scenario, ~36M files which are completely different, our
version runs in ~72% of the time of the original on my M1 Max:

 > hyperfine --warmup 1 -i --output=pipe \
     'cmp -l huge huge.3'
 Benchmark 1: cmp -l huge huge.3
   Time (mean ± σ):      3.237 s ±  0.014 s    [User: 2.891 s, System: 0.341 s]
   Range (min … max):    3.221 s …  3.271 s    10 runs

   Warning: Ignoring non-zero exit code.

 > hyperfine --warmup 1 -i --output=pipe \
     '../target/release/diffutils cmp -l huge huge.3'
 Benchmark 1: ../target/release/diffutils cmp -l huge huge.3
   Time (mean ± σ):      2.392 s ±  0.009 s    [User: 1.978 s, System: 0.406 s]
   Range (min … max):    2.378 s …  2.406 s    10 runs

   Warning: Ignoring non-zero exit code.

Our cmp runs in ~116% of the time when comparing libxul.so to the
chromium-browser binary with -l and -b. In a best case scenario of
comparing 2 files which are the same except for the last byte, our
tool is slightly faster.
2024-10-01 13:30:57 -03:00
Tanmay Patil 00e18a6b0c Define assert_diff_eq macro for context&unified diff comparison 2024-04-10 22:20:48 +05:30
Olivier Tilloy e6a0ba28c5 Pass a Params reference to the various diff() functions, instead of a long list of arguments 2024-03-31 21:27:28 +02:00
Olivier Tilloy 8d65c2badd Implement -t/--expand-tabs option 2024-03-28 18:09:03 +01:00
Sylvestre Ledru 9084134f04 rustfmt the code 2024-01-22 22:32:32 +01:00
Sylvestre Ledru f42fc82f18 adjust the fuzzers to use the new structure 2024-01-22 22:32:11 +01:00
Michael Howell e72ea046b7 Add context and normal diff modes 2021-03-09 16:34:57 -07:00
Michael Howell 4ad5818994 Add better docs; implement the trimmed ",1" feature 2021-02-25 09:06:01 -07:00
Michael Howell c1176af0b7 FMT 2021-02-25 00:48:54 -07:00
Michael Howell d96c02ef9e Remove unused variables 2021-02-25 00:47:55 -07:00
Michael Howell e7e8a91d74 Fuzzing 2021-02-25 00:12:15 -07:00
Michael Howell fe5ec13992 Clean up language for more consistency 2021-02-24 00:28:52 -07:00
Michael Howell 6eb1f5cc97 Add more comments to code 2021-02-24 00:13:41 -07:00
Michael Howell f43cc97003 Run cargo fmt 2021-02-23 23:53:32 -07:00
Michael Howell 25a7ab4d37 Add reverse test 2021-02-23 22:22:21 -07:00
Michael Howell 5433dc68db Initial commit 2021-02-23 22:18:58 -07:00