1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-21 20:51:11 +00:00
Commit graph

1038 commits

Author SHA1 Message Date
Etienne Cordonnier
8f17113d61 fsext.rs: use type inference fsid_t / __fsid_t
Commit https://github.com/uutils/coreutils/pull/3396/commits/2a0d58d060eb51ee482e7e8a764f36bda21105e5 (part of https://github.com/uutils/coreutils/pull/3396 which contains a description of the changes) changed this line from libc::fsid_t to nix::sys::statfs::fsid_t.
The pull-request description at https://github.com/uutils/coreutils/pull/3396 indicates that this was done in order to fix the android build, and indeed using a cast to nix::sys::statfs::fsid_t
takes advantage of the definition of nix::sys::statfs::fsid_t which abstracts away the different name on Android:

```
/// Identifies a mounted file system
#[cfg(target_os = "android")]
pub type fsid_t = libc::__fsid_t;
/// Identifies a mounted file system
#[cfg(not(target_os = "android"))]
pub type fsid_t = libc::fsid_t;
```

This cast works as long as the libc version used by nix is the same than the libc version used by coreutils.

This cast becomes invalid when using a local libc version for local debugging, and changing Cargo.toml to point to it:
```
-libc = "0.2.153"
+libc = { path = "../path/to/libc" }
```

The cast becomes invalid because self.f_fsid is of type libc::fsid_t (local version of
libc), whereas nix::sys::statfs::fsid_t still uses the libc version downloaded
by cargo from crates.io in this case.

I was getting this error:

```
coreutils$ cargo build
   Compiling libc v0.2.171 (/home/ecordonnier/dev/libc)
   Compiling uucore v0.0.30 (/home/ecordonnier/dev/coreutils/src/uucore)
error[E0606]: casting `&libc::fsid_t` as `*const nix::libc::fsid_t` is invalid
   --> src/uucore/src/lib/features/fsext.rs:816:25
    |
816 |             unsafe { &*(&self.f_fsid as *const nix::sys::statfs::fsid_t as *const [u32; 2]) };
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0606`.
error: could not compile `uucore` (lib) due to 1 previous error
```

Let's rather use type inference to deal with libc::fsid_t vs libc::__fsid_t.

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2025-03-17 11:05:02 +01:00
Etienne Cordonnier
f084b7f168 make cargo fmt happy 2025-03-16 00:21:45 +01:00
Etienne Cordonnier
591bef3759 utmpx.rs: use correct constant names for musl libc
Unfortunately, the name of those constants are not standardized:
glibc uses __UT_HOSTSIZE, __UT_LINESIZE, __UT_NAMESIZE
musl uses UT_HOSTSIZE, UT_LINESIZE, UT_NAMESIZE

See:
1. https://git.musl-libc.org/cgit/musl/tree/include/utmpx.h
2. https://github.com/bminor/glibc/blob/master/sysdeps/gnu/bits/utmpx.h#L35

This is a partial fix for https://github.com/uutils/coreutils/issues/1361

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2025-03-15 22:39:35 +01:00
Daniel Hofstetter
12ab9c2c21 uucore: add crate_version macro 2025-03-15 16:03:16 +01:00
Nicolas Boichat
b7dcaa34da uucore: format: print absolute value of float, then add sign
Simplifies the code, but also fixes printing of negative and positive `NaN`:
`cargo run printf "%f %f\n" nan -nan`

Fixes part 2 of #7412.
2025-03-14 12:42:00 +01:00
Nicolas Boichat
e3872e8e8f uucore: format: force NaN back to lowercase
Fixes formatting of `NaN` to `nan`.

Fixes part 1 of #7412.
2025-03-14 12:42:00 +01:00
Nicolas Boichat
bfa8bf72c7 uucore: format: Fix default Float precision in try_from_spec
The default precision is 6, no matter the format. This applies
to all float formats, not just "%g" (aka FloatVariant::Shortest).

Fixes #7361.
2025-03-14 12:05:16 +01:00
Nicolas Boichat
0a8155b5c2 uucore: format: Fix capitalization of 0 in scientific formating
0.0E+00 was not capitalized properly when using `%E` format.

Fixes #7382.

Test: cargo test --package uucore --all-features float
Test: cargo run printf "%E\n" 0 => 0.000000E+00
2025-03-14 12:05:16 +01:00
Dorian Peron
bbca2ffdbf printf: fix escape octal parsing
Co-authored-by: aryal <141743392+aryalaadi@users.noreply.github.com>
2025-03-11 12:46:59 +01:00
Bluemangoo
150960ac5c
uucore&uptime: fix docs and warnings 2025-03-10 21:29:08 +08:00
Bluemangoo
b1fc601cf8
uucore: fix uptime on Windows 2025-03-10 21:29:08 +08:00
Sylvestre Ledru
105a90c9df prepare version 0.0.30 2025-03-08 11:04:08 +01:00
Sylvestre Ledru
15864bcac1
Merge pull request #7405 from cakebaker/remove_once_cell
Remove `once_cell` dependency and use `LazyLock`
2025-03-05 11:34:40 +01:00
Daniel Hofstetter
e177f7a6b0 Remove once_cell dependency & use LazyLock 2025-03-05 11:02:56 +01:00
Daniel Hofstetter
3b9b8c51cf uucore: remove lazy_static & use LazyLock instead 2025-03-05 10:13:30 +01:00
Daniel Hofstetter
1a316e80c0 cksum: replace is_some_and with is_none_or
for better readability
2025-03-05 08:52:08 +01:00
Daniel Hofstetter
ac30e4cf92 uucore: replace PanicInfo with PanicHookInfo 2025-03-04 11:03:18 +01:00
Tuomas Tynkkynen
8f119fba5e uucore: Fix proc_info compilation
Fixes #7383
2025-03-03 16:51:35 +02:00
Dorian Péron
5c29054a40
Merge pull request #7365 from drinkcat/printf-float-hex-exponent
printf: (partially) fix hex format: exponent is decimal, correctly print negative numbers
2025-02-28 15:53:39 +01:00
Nicolas Boichat
f23e6f1cab uucore: format: Fix printing of negative floating hex
Negative numbers were not printed correctly with `%a`:
 - A leading `-` is expected.
 - The exponent mask was too wide (15 bits instead of 11)
2025-02-26 21:42:21 +01:00
Nicolas Boichat
576655b926 uucore: format: Fix printing of floating hex exponents
Floating hex format is supposed to be `[-]0xh.hhhp±d`. Note that
the exponent is a decimal value, not an hex number: fix that.

Also, add basic tests for this format, while we're at it.

Test: `cargo test --package uucore --all-features float`

Fixes #7362.
2025-02-26 21:42:13 +01:00
Tuomas Tynkkynen
88b93a6865 uucore: Extend proc_info spell checker list 2025-02-25 19:29:45 +02:00
Tuomas Tynkkynen
339a6d4c46 uucore: Sync uid/gid methods from procps 2025-02-25 11:51:20 +02:00
Tuomas Tynkkynen
16c174d826 uucore: Sync thread_ids() method from procps 2025-02-25 11:51:20 +02:00
Jeffrey Finkelstein
faf3412019 Style fixes from cargo +nightly clippy 2025-02-22 10:11:01 -05:00
Daniel Hofstetter
6c47989186 clippy: fix warning from precedence lint 2025-02-21 07:37:48 +01:00
Bluemangoo
047ec995f2
uptime: refactor, move some codes to uucore (#7289) 2025-02-20 12:09:06 +01:00
Dorian Péron
f2cf08b4e6 test(cksum): fix and un-ignore test_md5_bits 2025-02-03 11:06:47 +01:00
Sylvestre Ledru
717a6921fc
Merge pull request #7246 from RenjiSann/printf-negative-asterisk
printf: negative asterisk param changes alignment
2025-02-02 23:13:56 +01:00
Jeffrey Finkelstein
db280b6e9f printf: error on missing hexadecial escape value
Change `printf` to correctly terminate with an error message when an
escape sequence starts with `\x` but doesn't include a literal
hexadecimal value after. For example, before this commit,

    printf '\x'

would output `\x`, but after this commit, it terminates with an error
message,

    printf: missing hexadecimal number in escape

Fixes #7097
2025-02-02 11:07:31 -05:00
Dorian Peron
dcc2f1b72c printf: remove unneeded Result<> from resolve_asterisk* functions 2025-01-31 16:54:01 +01:00
Dorian Peron
707e346b84 printf: negative asterisk param changes alignement 2025-01-31 16:50:26 +01:00
Sylvestre Ledru
2e09fdcbdf uucore/docs.rs: generate the doc for all features 2025-01-26 19:54:12 +01:00
Daniel Hofstetter
10f43ec936
Merge pull request #7129 from sylvestre/chgrp
chgrp: add option --from
2025-01-24 10:08:35 +01:00
Sylvestre Ledru
4f83924092
Merge branch 'main' into sort-mem-percent 2025-01-23 22:52:00 +01:00
danieleades
5d6a04ab71
Fix clippy warning manual_if_else (#7177)
and enable the rule
2025-01-23 22:49:13 +01:00
Sylvestre Ledru
8e9a4b5f9a chgrp: adjust the output with group 2025-01-23 22:38:38 +01:00
Sylvestre Ledru
5129aba0f0
Merge pull request #7192 from RenjiSann/cksum-fix-error-handling
cksum: Update error and flags handling to improver GNU's match
2025-01-23 22:14:17 +01:00
Sylvestre Ledru
0ba4dad0a6 print_verbose_ownership_retained_as: siplify the function 2025-01-23 22:04:25 +01:00
Dorian Peron
5d0d1c2a9d checksum: rework exit_code setting to make use of the return type, fix logic for --ignore-missing 2025-01-23 17:04:00 +01:00
Dorian Peron
dd17a26dd8 checksum: change verbosity system so --status, --quiet and --warn override each other 2025-01-23 17:04:00 +01:00
Dorian Peron
7fff3670b3 checksum: fix improperly formatted WARNING message 2025-01-23 17:04:00 +01:00
Dorian Peron
11a0b1b505 checksum: move line warning display to process_line loop 2025-01-23 17:03:48 +01:00
Tommaso Fellegara
93e3d08d5f
ls, date: refactor common code for formatting a datetime (#7194)
* refactoring ls and date

* Refactored and integrated ls and date and added tests to the new feature

* Style refactoring
2025-01-22 17:39:00 +01:00
Jeffrey Finkelstein
94c772c082 sort: support percent arguments to -S option
Add support for parsing percent arguments to the `-S` option. The given
percentage specifies a percentage of the total physical memory. For
Linux, the total physical memory is read from `/proc/meminfo`. The
feature is not yet implemented for other systems.

In order to implement the feature, the `uucore::parser::parse_size`
function was updated to recognize strings of the form `NNN%`.

Fixes #3500
2025-01-20 16:24:49 -05:00
Jeffrey Finkelstein
39847a741a Add ParseSizeError::PhysicalMem enum variant 2025-01-20 16:24:49 -05:00
Dorian Peron
ed4edb4b8a cksum: Add crc32b algorithm 2025-01-20 12:08:36 +01:00
Sylvestre Ledru
178f57fad6 uucore: add missing declarations 2025-01-18 21:43:18 +01:00
Yykz
96c17312ea df: fix display of special characters
Replace the display of certain special characters in `df`: ASCII space
for plain space character, ASCII horizontal tab for plain tab
character, and ASCII backslash for plain backslash character.

Co-authored-by: Jeffrey Finkelstein <jeffrey.finkelstein@protonmail.com>
2025-01-16 21:49:58 -05:00
Sylvestre Ledru
b9765a746b
Merge pull request #7121 from sylvestre/prep-release
Prepare release 0.0.29
2025-01-11 17:43:58 +01:00