coreutils/src/uu
Jeffrey Finkelstein 63b496eaa8 truncate: refactor parse_size() function
Change the interface provided by the `parse_size()` function to reduce
its responsibilities to just a single task: parsing a number of bytes
from a string of the form '123KB', etc. Previously, the function was
also responsible for deciding which mode truncate would operate in.

Furthermore, this commit simplifies the code for parsing the number and
unit to be less verbose and use less mutable state.

Finally, this commit adds some unit tests for the `parse_size()`
function.
2021-05-19 23:07:11 -04:00
..
arch Switched 'arch' to use clap instead of getopts 2021-05-09 21:53:03 +03:00
base32 Removed clippy warnings. 2021-05-01 11:36:46 -07:00
base64 base64: Refactor argument parsing 2021-05-01 11:36:46 -07:00
basename basename: rename variable names 2021-05-03 23:32:01 +09:00
cat cat: the function 'unistd::write' doesn't need a mutable reference 2021-05-02 10:31:28 +02:00
chgrp Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
chmod uucore: refactor - reduce duplicate code related to fs::display_permissions 2021-05-08 11:52:41 +02:00
chown Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
chroot Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
cksum Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
comm Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
cp cp: fix 'variable does not need to be mutable' 2021-05-02 09:39:09 +02:00
csplit Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
cut Merge pull request #2111 from cbjadwani/cut_optimizations 2021-04-28 20:40:28 +02:00
date date: fix format literal for nanoseconds 2021-05-12 10:21:24 +02:00
df df/uucore: refactor - move duplicate code to uucore/fsext.rs 2021-05-10 23:37:01 +02:00
dircolors Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
dirname tr/dirname: fix clap short_alias 2021-04-30 20:19:43 +02:00
du Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
echo Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
env new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
expand new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
expr Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
factor fix clippy warnings 2021-05-10 15:48:32 +02:00
false new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
fmt Fix fmt crashing on subtracting unsigned numbers (#2178) 2021-05-05 23:12:17 +02:00
fold Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
groups new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
hashsum apply more clippy suggestions from nightly 2021-04-12 20:07:10 +02:00
head head: print headings when reading multiple files 2021-05-16 12:03:10 -04:00
hostid Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
hostname new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
id new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
install Implement install create leading components(-D) option (#2092) 2021-04-19 22:03:13 +02:00
join new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
kill kill: migrate to clap 2021-05-02 12:31:41 +02:00
link link: replace getopts with clap 2021-05-02 10:40:48 +08:00
ln fix trivial warnings without features 2021-04-11 16:05:25 +02:00
logname logname: fix test & style warning 2021-05-06 14:19:47 +02:00
ls fix clippy warnings 2021-05-10 15:48:32 +02:00
mkdir new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
mkfifo Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
mknod Migrate mknod to clap, closes #2051 (#2056) 2021-05-05 22:59:40 +02:00
mktemp new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
more Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
mv fix trivial warnings without features 2021-04-11 16:05:25 +02:00
nice new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
nl Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
nohup Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
nproc new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
numfmt new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
od Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
paste new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
pathchk Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
pinky who: fix --lookup 2021-05-13 22:16:15 +02:00
printenv new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
printf printf: remove useless declaration 2021-05-01 13:11:41 +02:00
ptx Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
pwd new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
readlink fix trivial warnings without features 2021-04-11 16:05:25 +02:00
realpath fix trivial warnings without features 2021-04-11 16:05:25 +02:00
relpath Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
rm fix trivial warnings without features 2021-04-11 16:05:25 +02:00
rmdir new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
seq fix trivial warnings without features 2021-04-11 16:05:25 +02:00
shred Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
shuf Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
sleep new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
sort Merge pull request #2194 from miDeb/sort-stable-merge 2021-05-12 08:38:48 +02:00
split Typo in comment 2021-05-08 14:25:21 +02:00
stat stat: remove unused/duplicate tests 2021-05-18 19:58:33 +02:00
stdbuf Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
sum Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
sync new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
tac Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
tail tail: use std::io::copy() to write bytes to stdout 2021-05-17 18:15:39 -04:00
tee new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
test test: improve handling of inverted Boolean expressions 2021-05-10 22:48:40 -04:00
timeout Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
touch touch: dealing with DST in touch -m -t (#2073) 2021-04-17 10:08:10 +02:00
tr tr: fix clippy warning 2021-05-02 13:53:11 +02:00
true new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
truncate truncate: refactor parse_size() function 2021-05-19 23:07:11 -04:00
tsort Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
tty Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
uname new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
unexpand Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
uniq uniq: avoid building list of duplicate lines 2021-04-19 17:02:59 +05:30
unlink Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852) 2021-04-25 23:28:42 +02:00
uptime new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
users new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
wc wc: correct some error messages for invalid inputs 2021-05-15 10:35:21 -04:00
who who: fix --lookup 2021-05-13 22:16:15 +02:00
whoami new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
yes new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00