diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/chgrp.c | 2 | ||||
-rw-r--r-- | coreutils/chown.c | 2 | ||||
-rw-r--r-- | coreutils/cp.c | 2 | ||||
-rw-r--r-- | coreutils/cut.c | 8 | ||||
-rw-r--r-- | coreutils/dd.c | 50 | ||||
-rw-r--r-- | coreutils/du.c | 2 | ||||
-rw-r--r-- | coreutils/echo.c | 2 | ||||
-rw-r--r-- | coreutils/fold.c | 2 | ||||
-rw-r--r-- | coreutils/head.c | 2 | ||||
-rw-r--r-- | coreutils/mv.c | 2 | ||||
-rw-r--r-- | coreutils/printf.c | 1 | ||||
-rw-r--r-- | coreutils/realpath.c | 2 | ||||
-rw-r--r-- | coreutils/sleep.c | 4 | ||||
-rw-r--r-- | coreutils/sort.c | 1 | ||||
-rw-r--r-- | coreutils/tail.c | 2 | ||||
-rw-r--r-- | coreutils/touch.c | 139 | ||||
-rw-r--r-- | coreutils/truncate.c | 4 | ||||
-rw-r--r-- | coreutils/wc.c | 2 |
18 files changed, 117 insertions, 112 deletions
diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c index 4da43c45e..0c2060981 100644 --- a/coreutils/chgrp.c +++ b/coreutils/chgrp.c | |||
@@ -23,7 +23,7 @@ | |||
23 | //usage:#define chgrp_trivial_usage | 23 | //usage:#define chgrp_trivial_usage |
24 | //usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... GROUP FILE..." | 24 | //usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... GROUP FILE..." |
25 | //usage:#define chgrp_full_usage "\n\n" | 25 | //usage:#define chgrp_full_usage "\n\n" |
26 | //usage: "Change the group membership of each FILE to GROUP\n" | 26 | //usage: "Change the group membership of FILEs to GROUP\n" |
27 | //usage: "\n -R Recurse" | 27 | //usage: "\n -R Recurse" |
28 | //usage: "\n -h Affect symlinks instead of symlink targets" | 28 | //usage: "\n -h Affect symlinks instead of symlink targets" |
29 | //usage: IF_DESKTOP( | 29 | //usage: IF_DESKTOP( |
diff --git a/coreutils/chown.c b/coreutils/chown.c index ffccc6cce..170507147 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c | |||
@@ -28,7 +28,7 @@ | |||
28 | //usage:#define chown_trivial_usage | 28 | //usage:#define chown_trivial_usage |
29 | //usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... USER[:[GRP]] FILE..." | 29 | //usage: "[-Rh"IF_DESKTOP("LHPcvf")"]... USER[:[GRP]] FILE..." |
30 | //usage:#define chown_full_usage "\n\n" | 30 | //usage:#define chown_full_usage "\n\n" |
31 | //usage: "Change the owner and/or group of each FILE to USER and/or GRP\n" | 31 | //usage: "Change the owner and/or group of FILEs to USER and/or GRP\n" |
32 | //usage: "\n -R Recurse" | 32 | //usage: "\n -R Recurse" |
33 | //usage: "\n -h Affect symlinks instead of symlink targets" | 33 | //usage: "\n -h Affect symlinks instead of symlink targets" |
34 | //usage: IF_DESKTOP( | 34 | //usage: IF_DESKTOP( |
diff --git a/coreutils/cp.c b/coreutils/cp.c index 9b9b8f7bf..f92ba6886 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c | |||
@@ -40,7 +40,7 @@ | |||
40 | //usage:#define cp_trivial_usage | 40 | //usage:#define cp_trivial_usage |
41 | //usage: "[-arPLHpfilsTu] SOURCE... DEST" | 41 | //usage: "[-arPLHpfilsTu] SOURCE... DEST" |
42 | //usage:#define cp_full_usage "\n\n" | 42 | //usage:#define cp_full_usage "\n\n" |
43 | //usage: "Copy SOURCE(s) to DEST\n" | 43 | //usage: "Copy SOURCEs to DEST\n" |
44 | //usage: "\n -a Same as -dpR" | 44 | //usage: "\n -a Same as -dpR" |
45 | //usage: IF_SELINUX( | 45 | //usage: IF_SELINUX( |
46 | //usage: "\n -c Preserve security context" | 46 | //usage: "\n -c Preserve security context" |
diff --git a/coreutils/cut.c b/coreutils/cut.c index 16418ff33..5897d82b6 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c | |||
@@ -22,12 +22,12 @@ | |||
22 | //usage:#define cut_trivial_usage | 22 | //usage:#define cut_trivial_usage |
23 | //usage: "[OPTIONS] [FILE]..." | 23 | //usage: "[OPTIONS] [FILE]..." |
24 | //usage:#define cut_full_usage "\n\n" | 24 | //usage:#define cut_full_usage "\n\n" |
25 | //usage: "Print selected fields from each input FILE to stdout\n" | 25 | //usage: "Print selected fields from FILEs to stdout\n" |
26 | //usage: "\n -b LIST Output only bytes from LIST" | 26 | //usage: "\n -b LIST Output only bytes from LIST" |
27 | //usage: "\n -c LIST Output only characters from LIST" | 27 | //usage: "\n -c LIST Output only characters from LIST" |
28 | //usage: "\n -d CHAR Use CHAR instead of tab as the field delimiter" | 28 | //usage: "\n -d CHAR Use CHAR instead of tab as field delimiter" |
29 | //usage: "\n -s Output only the lines containing delimiter" | 29 | //usage: "\n -s Output only lines containing delimiter" |
30 | //usage: "\n -f N Print only these fields" | 30 | //usage: "\n -f LIST Print only these fields" |
31 | //usage: "\n -n Ignored" | 31 | //usage: "\n -n Ignored" |
32 | //usage: | 32 | //usage: |
33 | //usage:#define cut_example_usage | 33 | //usage:#define cut_example_usage |
diff --git a/coreutils/dd.c b/coreutils/dd.c index bd799aa2b..15938f689 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -59,7 +59,7 @@ | |||
59 | //usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n" | 59 | //usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n" |
60 | //usage: IF_FEATURE_DD_IBS_OBS( | 60 | //usage: IF_FEATURE_DD_IBS_OBS( |
61 | //usage: " [conv=notrunc|noerror|sync|fsync]\n" | 61 | //usage: " [conv=notrunc|noerror|sync|fsync]\n" |
62 | //usage: " [iflag=skip_bytes|fullblock|direct] [oflag=seek_bytes|append|direct]" | 62 | //usage: " [iflag=skip_bytes|count_bytes|fullblock|direct] [oflag=seek_bytes|append|direct]" |
63 | //usage: ) | 63 | //usage: ) |
64 | //usage:#define dd_full_usage "\n\n" | 64 | //usage:#define dd_full_usage "\n\n" |
65 | //usage: "Copy a file with converting and formatting\n" | 65 | //usage: "Copy a file with converting and formatting\n" |
@@ -82,6 +82,7 @@ | |||
82 | //usage: "\n conv=fsync Physically write data out before finishing" | 82 | //usage: "\n conv=fsync Physically write data out before finishing" |
83 | //usage: "\n conv=swab Swap every pair of bytes" | 83 | //usage: "\n conv=swab Swap every pair of bytes" |
84 | //usage: "\n iflag=skip_bytes skip=N is in bytes" | 84 | //usage: "\n iflag=skip_bytes skip=N is in bytes" |
85 | //usage: "\n iflag=count_bytes count=N is in bytes" | ||
85 | //usage: "\n oflag=seek_bytes seek=N is in bytes" | 86 | //usage: "\n oflag=seek_bytes seek=N is in bytes" |
86 | //usage: "\n iflag=direct O_DIRECT input" | 87 | //usage: "\n iflag=direct O_DIRECT input" |
87 | //usage: "\n oflag=direct O_DIRECT output" | 88 | //usage: "\n oflag=direct O_DIRECT output" |
@@ -139,21 +140,22 @@ enum { | |||
139 | FLAG_SWAB = (1 << 4) * ENABLE_FEATURE_DD_IBS_OBS, | 140 | FLAG_SWAB = (1 << 4) * ENABLE_FEATURE_DD_IBS_OBS, |
140 | /* end of conv flags */ | 141 | /* end of conv flags */ |
141 | /* start of input flags */ | 142 | /* start of input flags */ |
142 | FLAG_IFLAG_SHIFT = 5, | 143 | FLAG_IFLAG_SHIFT = 5, |
143 | FLAG_SKIP_BYTES = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS, | 144 | FLAG_SKIP_BYTES = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS, |
144 | FLAG_FULLBLOCK = (1 << 6) * ENABLE_FEATURE_DD_IBS_OBS, | 145 | FLAG_COUNT_BYTES = (1 << 6) * ENABLE_FEATURE_DD_IBS_OBS, |
145 | FLAG_IDIRECT = (1 << 7) * ENABLE_FEATURE_DD_IBS_OBS, | 146 | FLAG_FULLBLOCK = (1 << 7) * ENABLE_FEATURE_DD_IBS_OBS, |
147 | FLAG_IDIRECT = (1 << 8) * ENABLE_FEATURE_DD_IBS_OBS, | ||
146 | /* end of input flags */ | 148 | /* end of input flags */ |
147 | /* start of output flags */ | 149 | /* start of output flags */ |
148 | FLAG_OFLAG_SHIFT = 8, | 150 | FLAG_OFLAG_SHIFT = 9, |
149 | FLAG_SEEK_BYTES = (1 << 8) * ENABLE_FEATURE_DD_IBS_OBS, | 151 | FLAG_SEEK_BYTES = (1 << 9) * ENABLE_FEATURE_DD_IBS_OBS, |
150 | FLAG_APPEND = (1 << 9) * ENABLE_FEATURE_DD_IBS_OBS, | 152 | FLAG_APPEND = (1 << 10) * ENABLE_FEATURE_DD_IBS_OBS, |
151 | FLAG_ODIRECT = (1 << 10) * ENABLE_FEATURE_DD_IBS_OBS, | 153 | FLAG_ODIRECT = (1 << 11) * ENABLE_FEATURE_DD_IBS_OBS, |
152 | /* end of output flags */ | 154 | /* end of output flags */ |
153 | FLAG_TWOBUFS = (1 << 11) * ENABLE_FEATURE_DD_IBS_OBS, | 155 | FLAG_TWOBUFS = (1 << 12) * ENABLE_FEATURE_DD_IBS_OBS, |
154 | FLAG_COUNT = 1 << 12, | 156 | FLAG_COUNT = 1 << 13, |
155 | FLAG_STATUS_NONE = 1 << 13, | 157 | FLAG_STATUS_NONE = 1 << 14, |
156 | FLAG_STATUS_NOXFER = 1 << 14, | 158 | FLAG_STATUS_NOXFER = 1 << 15, |
157 | }; | 159 | }; |
158 | 160 | ||
159 | static void dd_output_status(int UNUSED_PARAM cur_signal) | 161 | static void dd_output_status(int UNUSED_PARAM cur_signal) |
@@ -178,8 +180,9 @@ static void dd_output_status(int UNUSED_PARAM cur_signal) | |||
178 | //So far we react to it (we print the stats), | 180 | //So far we react to it (we print the stats), |
179 | //status=none only suppresses final, non-USR1 generated status message. | 181 | //status=none only suppresses final, non-USR1 generated status message. |
180 | # endif | 182 | # endif |
181 | fprintf(stderr, "%llu bytes (%sB) copied, ", | 183 | fprintf(stderr, /*G.total_bytes < 1024 |
182 | G.total_bytes, | 184 | ? "%llu bytes copied, " : */ "%llu bytes (%sB) copied, " |
185 | , G.total_bytes, | ||
183 | /* show fractional digit, use suffixes */ | 186 | /* show fractional digit, use suffixes */ |
184 | make_human_readable_str(G.total_bytes, 1, 0) | 187 | make_human_readable_str(G.total_bytes, 1, 0) |
185 | ); | 188 | ); |
@@ -322,7 +325,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
322 | static const char conv_words[] ALIGN1 = | 325 | static const char conv_words[] ALIGN1 = |
323 | "notrunc\0""sync\0""noerror\0""fsync\0""swab\0"; | 326 | "notrunc\0""sync\0""noerror\0""fsync\0""swab\0"; |
324 | static const char iflag_words[] ALIGN1 = | 327 | static const char iflag_words[] ALIGN1 = |
325 | "skip_bytes\0""fullblock\0""direct\0"; | 328 | "skip_bytes\0""count_bytes\0""fullblock\0""direct\0"; |
326 | static const char oflag_words[] ALIGN1 = | 329 | static const char oflag_words[] ALIGN1 = |
327 | "seek_bytes\0append\0""direct\0"; | 330 | "seek_bytes\0append\0""direct\0"; |
328 | #endif | 331 | #endif |
@@ -364,6 +367,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
364 | /* Partially implemented: */ | 367 | /* Partially implemented: */ |
365 | //swab swap every pair of input bytes: will abort on non-even reads | 368 | //swab swap every pair of input bytes: will abort on non-even reads |
366 | OP_iflag_skip_bytes, | 369 | OP_iflag_skip_bytes, |
370 | OP_iflag_count_bytes, | ||
367 | OP_iflag_fullblock, | 371 | OP_iflag_fullblock, |
368 | OP_iflag_direct, | 372 | OP_iflag_direct, |
369 | OP_oflag_seek_bytes, | 373 | OP_oflag_seek_bytes, |
@@ -581,8 +585,17 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
581 | goto die_outfile; | 585 | goto die_outfile; |
582 | } | 586 | } |
583 | 587 | ||
584 | while (!(G.flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { | 588 | while (1) { |
585 | ssize_t n = dd_read(ibuf, ibs); | 589 | ssize_t n = ibs; |
590 | |||
591 | if (G.flags & FLAG_COUNT) { | ||
592 | if (count == 0) | ||
593 | break; | ||
594 | if ((G.flags & FLAG_COUNT_BYTES) && count < ibs) | ||
595 | n = count; | ||
596 | } | ||
597 | |||
598 | n = dd_read(ibuf, n); | ||
586 | if (n == 0) | 599 | if (n == 0) |
587 | break; | 600 | break; |
588 | if (n < 0) { | 601 | if (n < 0) { |
@@ -617,6 +630,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
617 | p16++; | 630 | p16++; |
618 | } | 631 | } |
619 | } | 632 | } |
633 | count -= (G.flags & FLAG_COUNT_BYTES) ? n : 1; | ||
620 | if ((size_t)n == ibs) | 634 | if ((size_t)n == ibs) |
621 | G.in_full++; | 635 | G.in_full++; |
622 | else { | 636 | else { |
diff --git a/coreutils/du.c b/coreutils/du.c index 4fd09a8ee..247a08c95 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -40,7 +40,7 @@ | |||
40 | //usage:#define du_trivial_usage | 40 | //usage:#define du_trivial_usage |
41 | //usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..." | 41 | //usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..." |
42 | //usage:#define du_full_usage "\n\n" | 42 | //usage:#define du_full_usage "\n\n" |
43 | //usage: "Summarize disk space used for each FILE and/or directory\n" | 43 | //usage: "Summarize disk space used for FILEs (or directories)\n" |
44 | //usage: "\n -a Show file sizes too" | 44 | //usage: "\n -a Show file sizes too" |
45 | //usage: "\n -L Follow all symlinks" | 45 | //usage: "\n -L Follow all symlinks" |
46 | //usage: "\n -H Follow symlinks on command line" | 46 | //usage: "\n -H Follow symlinks on command line" |
diff --git a/coreutils/echo.c b/coreutils/echo.c index 61ba060ec..aab177cee 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -87,6 +87,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv) | |||
87 | char *out; | 87 | char *out; |
88 | char *buffer; | 88 | char *buffer; |
89 | unsigned buflen; | 89 | unsigned buflen; |
90 | int err; | ||
90 | #if !ENABLE_FEATURE_FANCY_ECHO | 91 | #if !ENABLE_FEATURE_FANCY_ECHO |
91 | enum { | 92 | enum { |
92 | eflag = 0, /* 0 -- disable escape sequences */ | 93 | eflag = 0, /* 0 -- disable escape sequences */ |
@@ -97,7 +98,6 @@ int echo_main(int argc UNUSED_PARAM, char **argv) | |||
97 | #else | 98 | #else |
98 | char nflag = 1; | 99 | char nflag = 1; |
99 | char eflag = 0; | 100 | char eflag = 0; |
100 | int err; | ||
101 | 101 | ||
102 | while ((arg = *++argv) != NULL) { | 102 | while ((arg = *++argv) != NULL) { |
103 | char n, e; | 103 | char n, e; |
diff --git a/coreutils/fold.c b/coreutils/fold.c index 1e26dde0c..98c3b1491 100644 --- a/coreutils/fold.c +++ b/coreutils/fold.c | |||
@@ -23,7 +23,7 @@ | |||
23 | //usage:#define fold_trivial_usage | 23 | //usage:#define fold_trivial_usage |
24 | //usage: "[-bs] [-w WIDTH] [FILE]..." | 24 | //usage: "[-bs] [-w WIDTH] [FILE]..." |
25 | //usage:#define fold_full_usage "\n\n" | 25 | //usage:#define fold_full_usage "\n\n" |
26 | //usage: "Wrap input lines in each FILE (or stdin), writing to stdout\n" | 26 | //usage: "Wrap input lines in FILEs (or stdin), writing to stdout\n" |
27 | //usage: "\n -b Count bytes rather than columns" | 27 | //usage: "\n -b Count bytes rather than columns" |
28 | //usage: "\n -s Break at spaces" | 28 | //usage: "\n -s Break at spaces" |
29 | //usage: "\n -w Use WIDTH columns instead of 80" | 29 | //usage: "\n -w Use WIDTH columns instead of 80" |
diff --git a/coreutils/head.c b/coreutils/head.c index b6efabbe0..efb023c6f 100644 --- a/coreutils/head.c +++ b/coreutils/head.c | |||
@@ -29,7 +29,7 @@ | |||
29 | //usage:#define head_trivial_usage | 29 | //usage:#define head_trivial_usage |
30 | //usage: "[OPTIONS] [FILE]..." | 30 | //usage: "[OPTIONS] [FILE]..." |
31 | //usage:#define head_full_usage "\n\n" | 31 | //usage:#define head_full_usage "\n\n" |
32 | //usage: "Print first 10 lines of each FILE (or stdin) to stdout.\n" | 32 | //usage: "Print first 10 lines of FILEs (or stdin) to stdout.\n" |
33 | //usage: "With more than one FILE, precede each with a filename header.\n" | 33 | //usage: "With more than one FILE, precede each with a filename header.\n" |
34 | //usage: "\n -n N[kbm] Print first N lines" | 34 | //usage: "\n -n N[kbm] Print first N lines" |
35 | //usage: IF_FEATURE_FANCY_HEAD( | 35 | //usage: IF_FEATURE_FANCY_HEAD( |
diff --git a/coreutils/mv.c b/coreutils/mv.c index b9f8f6982..f5ed9fcfc 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c | |||
@@ -26,7 +26,7 @@ | |||
26 | //usage: "[-fin] SOURCE DEST\n" | 26 | //usage: "[-fin] SOURCE DEST\n" |
27 | //usage: "or: mv [-fin] SOURCE... DIRECTORY" | 27 | //usage: "or: mv [-fin] SOURCE... DIRECTORY" |
28 | //usage:#define mv_full_usage "\n\n" | 28 | //usage:#define mv_full_usage "\n\n" |
29 | //usage: "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY\n" | 29 | //usage: "Rename SOURCE to DEST, or move SOURCEs to DIRECTORY\n" |
30 | //usage: "\n -f Don't prompt before overwriting" | 30 | //usage: "\n -f Don't prompt before overwriting" |
31 | //usage: "\n -i Interactive, prompt before overwrite" | 31 | //usage: "\n -i Interactive, prompt before overwrite" |
32 | //usage: "\n -n Don't overwrite an existing file" | 32 | //usage: "\n -n Don't overwrite an existing file" |
diff --git a/coreutils/printf.c b/coreutils/printf.c index 7d36fdd61..b5b1c6576 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -122,6 +122,7 @@ static void FAST_FUNC conv_strtod(const char *arg, void *result) | |||
122 | char *end; | 122 | char *end; |
123 | /* Well, this one allows leading whitespace... so what? */ | 123 | /* Well, this one allows leading whitespace... so what? */ |
124 | /* What I like much less is that "-" accepted too! :( */ | 124 | /* What I like much less is that "-" accepted too! :( */ |
125 | //TODO: needs setlocale(LC_NUMERIC, "C")? | ||
125 | *(double*)result = strtod(arg, &end); | 126 | *(double*)result = strtod(arg, &end); |
126 | if (end[0]) { | 127 | if (end[0]) { |
127 | errno = ERANGE; | 128 | errno = ERANGE; |
diff --git a/coreutils/realpath.c b/coreutils/realpath.c index f5f868744..aeeef601c 100644 --- a/coreutils/realpath.c +++ b/coreutils/realpath.c | |||
@@ -23,7 +23,7 @@ | |||
23 | //usage:#define realpath_trivial_usage | 23 | //usage:#define realpath_trivial_usage |
24 | //usage: "FILE..." | 24 | //usage: "FILE..." |
25 | //usage:#define realpath_full_usage "\n\n" | 25 | //usage:#define realpath_full_usage "\n\n" |
26 | //usage: "Return the absolute pathnames of given FILE" | 26 | //usage: "Print absolute pathnames of FILEs" |
27 | 27 | ||
28 | #include "libbb.h" | 28 | #include "libbb.h" |
29 | 29 | ||
diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 7bfaab920..2658e84df 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c | |||
@@ -74,10 +74,6 @@ int sleep_main(int argc UNUSED_PARAM, char **argv) | |||
74 | sleep(INT_MAX); | 74 | sleep(INT_MAX); |
75 | 75 | ||
76 | #if ENABLE_FEATURE_FANCY_SLEEP | 76 | #if ENABLE_FEATURE_FANCY_SLEEP |
77 | # if ENABLE_FLOAT_DURATION | ||
78 | /* undo busybox.c setlocale */ | ||
79 | setlocale(LC_NUMERIC, "C"); | ||
80 | # endif | ||
81 | duration = 0; | 77 | duration = 0; |
82 | do { | 78 | do { |
83 | duration += parse_duration_str(*argv); | 79 | duration += parse_duration_str(*argv); |
diff --git a/coreutils/sort.c b/coreutils/sort.c index b194847d1..6c4e3038c 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -295,6 +295,7 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
295 | #if ENABLE_FEATURE_SORT_BIG | 295 | #if ENABLE_FEATURE_SORT_BIG |
296 | case FLAG_g: { | 296 | case FLAG_g: { |
297 | char *xx, *yy; | 297 | char *xx, *yy; |
298 | //TODO: needs setlocale(LC_NUMERIC, "C")? | ||
298 | double dx = strtod(x, &xx); | 299 | double dx = strtod(x, &xx); |
299 | double dy = strtod(y, &yy); | 300 | double dy = strtod(y, &yy); |
300 | /* not numbers < NaN < -infinity < numbers < +infinity) */ | 301 | /* not numbers < NaN < -infinity < numbers < +infinity) */ |
diff --git a/coreutils/tail.c b/coreutils/tail.c index 1f458f9ed..08fde6cdd 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -48,7 +48,7 @@ | |||
48 | //usage:#define tail_trivial_usage | 48 | //usage:#define tail_trivial_usage |
49 | //usage: "[OPTIONS] [FILE]..." | 49 | //usage: "[OPTIONS] [FILE]..." |
50 | //usage:#define tail_full_usage "\n\n" | 50 | //usage:#define tail_full_usage "\n\n" |
51 | //usage: "Print last 10 lines of each FILE (or stdin) to stdout.\n" | 51 | //usage: "Print last 10 lines of FILEs (or stdin) to stdout.\n" |
52 | //usage: "With more than one FILE, precede each with a filename header.\n" | 52 | //usage: "With more than one FILE, precede each with a filename header.\n" |
53 | //usage: "\n -f Print data as file grows" | 53 | //usage: "\n -f Print data as file grows" |
54 | //usage: "\n -c [+]N[kbm] Print last N bytes" | 54 | //usage: "\n -c [+]N[kbm] Print last N bytes" |
diff --git a/coreutils/touch.c b/coreutils/touch.c index b30811157..2b225dd16 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
@@ -19,16 +19,8 @@ | |||
19 | //config: touch is used to create or change the access and/or | 19 | //config: touch is used to create or change the access and/or |
20 | //config: modification timestamp of specified files. | 20 | //config: modification timestamp of specified files. |
21 | //config: | 21 | //config: |
22 | //config:config FEATURE_TOUCH_NODEREF | ||
23 | //config: bool "Add support for -h" | ||
24 | //config: default y | ||
25 | //config: depends on TOUCH | ||
26 | //config: help | ||
27 | //config: Enable touch to have the -h option. | ||
28 | //config: This requires libc support for lutimes() function. | ||
29 | //config: | ||
30 | //config:config FEATURE_TOUCH_SUSV3 | 22 | //config:config FEATURE_TOUCH_SUSV3 |
31 | //config: bool "Add support for SUSV3 features (-d -t -r)" | 23 | //config: bool "Add support for SUSV3 features (-a -d -m -t -r)" |
32 | //config: default y | 24 | //config: default y |
33 | //config: depends on TOUCH | 25 | //config: depends on TOUCH |
34 | //config: help | 26 | //config: help |
@@ -38,18 +30,17 @@ | |||
38 | 30 | ||
39 | //kbuild:lib-$(CONFIG_TOUCH) += touch.o | 31 | //kbuild:lib-$(CONFIG_TOUCH) += touch.o |
40 | 32 | ||
41 | /* BB_AUDIT SUSv3 _NOT_ compliant -- options -a, -m not supported. */ | ||
42 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/touch.html */ | ||
43 | |||
44 | //usage:#define touch_trivial_usage | 33 | //usage:#define touch_trivial_usage |
45 | //usage: "[-c]" IF_FEATURE_TOUCH_SUSV3(" [-d DATE] [-t DATE] [-r FILE]") " FILE..." | 34 | //usage: "[-c" IF_FEATURE_TOUCH_SUSV3("am") "]" |
35 | //usage: IF_FEATURE_TOUCH_SUSV3(" [-d DATE] [-t DATE] [-r FILE]") | ||
36 | //usage: " FILE..." | ||
46 | //usage:#define touch_full_usage "\n\n" | 37 | //usage:#define touch_full_usage "\n\n" |
47 | //usage: "Update the last-modified date on the given FILE[s]\n" | 38 | //usage: "Update mtime of FILEs\n" |
48 | //usage: "\n -c Don't create files" | 39 | //usage: "\n -c Don't create files" |
49 | //usage: IF_FEATURE_TOUCH_NODEREF( | ||
50 | //usage: "\n -h Don't follow links" | 40 | //usage: "\n -h Don't follow links" |
51 | //usage: ) | ||
52 | //usage: IF_FEATURE_TOUCH_SUSV3( | 41 | //usage: IF_FEATURE_TOUCH_SUSV3( |
42 | //usage: "\n -a Change only atime" | ||
43 | //usage: "\n -m Change only mtime" | ||
53 | //usage: "\n -d DT Date/time to use" | 44 | //usage: "\n -d DT Date/time to use" |
54 | //usage: "\n -t DT Date/time to use" | 45 | //usage: "\n -t DT Date/time to use" |
55 | //usage: "\n -r FILE Use FILE's date/time" | 46 | //usage: "\n -r FILE Use FILE's date/time" |
@@ -85,70 +76,67 @@ int touch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
85 | int touch_main(int argc UNUSED_PARAM, char **argv) | 76 | int touch_main(int argc UNUSED_PARAM, char **argv) |
86 | { | 77 | { |
87 | int fd; | 78 | int fd; |
88 | int status = EXIT_SUCCESS; | ||
89 | int opts; | 79 | int opts; |
80 | smalluint status = EXIT_SUCCESS; | ||
81 | #if ENABLE_FEATURE_TOUCH_SUSV3 | ||
82 | char *reference_file; | ||
83 | char *date_str; | ||
84 | /* timebuf[0] is atime, timebuf[1] is mtime */ | ||
85 | struct timespec timebuf[2]; | ||
86 | #else | ||
87 | # define reference_file NULL | ||
88 | # define date_str NULL | ||
89 | # define timebuf ((struct timespec*)NULL) | ||
90 | #endif | ||
91 | |||
90 | enum { | 92 | enum { |
91 | OPT_c = (1 << 0), | 93 | OPT_c = (1 << 0), |
92 | OPT_r = (1 << 1) * ENABLE_FEATURE_TOUCH_SUSV3, | 94 | OPT_h = (1 << 1), |
93 | OPT_d = (1 << 2) * ENABLE_FEATURE_TOUCH_SUSV3, | 95 | OPT_r = (1 << 2) * ENABLE_FEATURE_TOUCH_SUSV3, |
94 | OPT_t = (1 << 3) * ENABLE_FEATURE_TOUCH_SUSV3, | 96 | OPT_d = (1 << 3) * ENABLE_FEATURE_TOUCH_SUSV3, |
95 | OPT_h = (1 << 4) * ENABLE_FEATURE_TOUCH_NODEREF, | 97 | OPT_t = (1 << 4) * ENABLE_FEATURE_TOUCH_SUSV3, |
98 | OPT_a = (1 << 5) * ENABLE_FEATURE_TOUCH_SUSV3, | ||
99 | OPT_m = (1 << 6) * ENABLE_FEATURE_TOUCH_SUSV3, | ||
96 | }; | 100 | }; |
97 | #if ENABLE_FEATURE_TOUCH_SUSV3 | 101 | #if ENABLE_LONG_OPTS |
98 | # if ENABLE_LONG_OPTS | ||
99 | static const char touch_longopts[] ALIGN1 = | 102 | static const char touch_longopts[] ALIGN1 = |
100 | /* name, has_arg, val */ | 103 | /* name, has_arg, val */ |
101 | "no-create\0" No_argument "c" | 104 | "no-create\0" No_argument "c" |
102 | "reference\0" Required_argument "r" | 105 | "no-dereference\0" No_argument "h" |
103 | "date\0" Required_argument "d" | 106 | IF_FEATURE_TOUCH_SUSV3("reference\0" Required_argument "r") |
104 | IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h") | 107 | IF_FEATURE_TOUCH_SUSV3("date\0" Required_argument "d") |
105 | ; | 108 | ; |
106 | # define GETOPT32 getopt32long | ||
107 | # define LONGOPTS ,touch_longopts | ||
108 | # else | ||
109 | # define GETOPT32 getopt32 | ||
110 | # define LONGOPTS | ||
111 | # endif | ||
112 | char *reference_file = NULL; | ||
113 | char *date_str = NULL; | ||
114 | struct timeval timebuf[2]; | ||
115 | timebuf[1].tv_usec = timebuf[0].tv_usec = 0; | ||
116 | #else | ||
117 | # define reference_file NULL | ||
118 | # define date_str NULL | ||
119 | # define timebuf ((struct timeval*)NULL) | ||
120 | # define GETOPT32 getopt32 | ||
121 | # define LONGOPTS | ||
122 | #endif | 109 | #endif |
123 | |||
124 | /* -d and -t both set time. In coreutils, | 110 | /* -d and -t both set time. In coreutils, |
125 | * accepted data format differs a bit between -d and -t. | 111 | * accepted data format differs a bit between -d and -t. |
126 | * We accept the same formats for both */ | 112 | * We accept the same formats for both |
127 | opts = GETOPT32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:") | 113 | */ |
128 | IF_FEATURE_TOUCH_NODEREF("h") | 114 | opts = getopt32long(argv, "^" |
129 | /*ignored:*/ "fma" | 115 | "ch" |
130 | LONGOPTS | 116 | IF_FEATURE_TOUCH_SUSV3("r:d:t:am") |
131 | IF_FEATURE_TOUCH_SUSV3(, &reference_file) | 117 | /*ignored:*/ "f" IF_NOT_FEATURE_TOUCH_SUSV3("am") |
132 | IF_FEATURE_TOUCH_SUSV3(, &date_str) | 118 | "\0" /* opt_complementary: */ |
133 | IF_FEATURE_TOUCH_SUSV3(, &date_str) | 119 | /* at least one arg: */ "-1" |
120 | /* coreutils forbids -r and -t at once: */ IF_FEATURE_TOUCH_SUSV3(":r--t:t--r") | ||
121 | /* but allows these combinations: "r--d:d--r:t--d:d--t" */ | ||
122 | , touch_longopts | ||
123 | #if ENABLE_FEATURE_TOUCH_SUSV3 | ||
124 | , &reference_file | ||
125 | , &date_str | ||
126 | , &date_str | ||
127 | #endif | ||
134 | ); | 128 | ); |
135 | 129 | ||
136 | argv += optind; | 130 | timebuf[0].tv_nsec = timebuf[1].tv_nsec = UTIME_NOW; |
137 | if (!*argv) { | 131 | if (opts & OPT_r) { |
138 | bb_show_usage(); | ||
139 | } | ||
140 | |||
141 | if (reference_file) { | ||
142 | struct stat stbuf; | 132 | struct stat stbuf; |
143 | xstat(reference_file, &stbuf); | 133 | xstat(reference_file, &stbuf); |
144 | timebuf[1].tv_sec = timebuf[0].tv_sec = stbuf.st_mtime; | 134 | timebuf[0].tv_sec = stbuf.st_atime; |
145 | /* Can use .st_mtim.tv_nsec | 135 | timebuf[1].tv_sec = stbuf.st_mtime; |
146 | * (or is it .st_mtimensec?? see date.c) | 136 | timebuf[0].tv_nsec = stbuf.st_atim.tv_nsec; |
147 | * to set microseconds too. | 137 | timebuf[1].tv_nsec = stbuf.st_mtim.tv_nsec; |
148 | */ | ||
149 | } | 138 | } |
150 | 139 | if (opts & (OPT_d|OPT_t)) { | |
151 | if (date_str) { | ||
152 | struct tm tm_time; | 140 | struct tm tm_time; |
153 | time_t t; | 141 | time_t t; |
154 | 142 | ||
@@ -163,15 +151,20 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
163 | t = validate_tm_time(date_str, &tm_time); | 151 | t = validate_tm_time(date_str, &tm_time); |
164 | 152 | ||
165 | timebuf[1].tv_sec = timebuf[0].tv_sec = t; | 153 | timebuf[1].tv_sec = timebuf[0].tv_sec = t; |
154 | timebuf[1].tv_nsec = timebuf[0].tv_nsec = 0; | ||
166 | } | 155 | } |
156 | /* If both -a and -m specified, both times should be set. | ||
157 | * IOW: set OMIT only if one, not both, of them is given! | ||
158 | */ | ||
159 | if ((opts & (OPT_a|OPT_m)) == OPT_a) | ||
160 | timebuf[1].tv_nsec = UTIME_OMIT; | ||
161 | if ((opts & (OPT_a|OPT_m)) == OPT_m) | ||
162 | timebuf[0].tv_nsec = UTIME_OMIT; | ||
167 | 163 | ||
164 | argv += optind; | ||
168 | do { | 165 | do { |
169 | int result; | 166 | int result = utimensat(AT_FDCWD, *argv, timebuf, |
170 | result = ( | 167 | (opts & OPT_h) ? AT_SYMLINK_NOFOLLOW : 0); |
171 | #if ENABLE_FEATURE_TOUCH_NODEREF | ||
172 | (opts & OPT_h) ? lutimes : | ||
173 | #endif | ||
174 | utimes)(*argv, (reference_file || date_str) ? timebuf : NULL); | ||
175 | if (result != 0) { | 168 | if (result != 0) { |
176 | if (errno == ENOENT) { /* no such file? */ | 169 | if (errno == ENOENT) { /* no such file? */ |
177 | if (opts & OPT_c) { | 170 | if (opts & OPT_c) { |
@@ -181,9 +174,9 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
181 | /* Try to create the file */ | 174 | /* Try to create the file */ |
182 | fd = open(*argv, O_RDWR | O_CREAT, 0666); | 175 | fd = open(*argv, O_RDWR | O_CREAT, 0666); |
183 | if (fd >= 0) { | 176 | if (fd >= 0) { |
177 | if (opts & (OPT_r|OPT_d|OPT_t)) | ||
178 | futimens(fd, timebuf); | ||
184 | xclose(fd); | 179 | xclose(fd); |
185 | if (reference_file || date_str) | ||
186 | utimes(*argv, timebuf); | ||
187 | continue; | 180 | continue; |
188 | } | 181 | } |
189 | } | 182 | } |
diff --git a/coreutils/truncate.c b/coreutils/truncate.c index 233d0f2d1..e26c3e3e1 100644 --- a/coreutils/truncate.c +++ b/coreutils/truncate.c | |||
@@ -19,9 +19,9 @@ | |||
19 | //usage:#define truncate_trivial_usage | 19 | //usage:#define truncate_trivial_usage |
20 | //usage: "[-c] -s SIZE FILE..." | 20 | //usage: "[-c] -s SIZE FILE..." |
21 | //usage:#define truncate_full_usage "\n\n" | 21 | //usage:#define truncate_full_usage "\n\n" |
22 | //usage: "Truncate FILEs to the given size\n" | 22 | //usage: "Truncate FILEs to SIZE\n" |
23 | //usage: "\n -c Do not create files" | 23 | //usage: "\n -c Do not create files" |
24 | //usage: "\n -s SIZE Truncate to SIZE" | 24 | //usage: "\n -s SIZE" |
25 | //usage: | 25 | //usage: |
26 | //usage:#define truncate_example_usage | 26 | //usage:#define truncate_example_usage |
27 | //usage: "$ truncate -s 1G foo" | 27 | //usage: "$ truncate -s 1G foo" |
diff --git a/coreutils/wc.c b/coreutils/wc.c index 99eb9dc87..d5238d3fc 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
@@ -80,7 +80,7 @@ | |||
80 | //usage: "[-c"IF_UNICODE_SUPPORT("m")"lwL] [FILE]..." | 80 | //usage: "[-c"IF_UNICODE_SUPPORT("m")"lwL] [FILE]..." |
81 | //usage: | 81 | //usage: |
82 | //usage:#define wc_full_usage "\n\n" | 82 | //usage:#define wc_full_usage "\n\n" |
83 | //usage: "Count lines, words, and bytes for each FILE (or stdin)\n" | 83 | //usage: "Count lines, words, and bytes for FILEs (or stdin)\n" |
84 | //usage: "\n -c Count bytes" | 84 | //usage: "\n -c Count bytes" |
85 | //usage: IF_UNICODE_SUPPORT( | 85 | //usage: IF_UNICODE_SUPPORT( |
86 | //usage: "\n -m Count characters" | 86 | //usage: "\n -m Count characters" |