diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-14 13:58:49 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-14 13:58:49 +0100 |
commit | b25ea3f156c6b5927b358f9b12b90f1852f30311 (patch) | |
tree | cc2e7f2cb4f7b25468377db0c355e90340c0914c /coreutils/cut.c | |
parent | d48400d8fb266526059eb43b318cb95132f61fb3 (diff) | |
download | busybox-w32-b25ea3f156c6b5927b358f9b12b90f1852f30311.tar.gz busybox-w32-b25ea3f156c6b5927b358f9b12b90f1852f30311.tar.bz2 busybox-w32-b25ea3f156c6b5927b358f9b12b90f1852f30311.zip |
cut: fix -F n-m to match toybox
function old new delta
cut_main 1339 1391 +52
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/cut.c')
-rw-r--r-- | coreutils/cut.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c index f4cf5401b..3abebe7ad 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c | |||
@@ -243,6 +243,16 @@ static void cut_file(FILE *file, const char *delim, const char *odelim, | |||
243 | start = next; | 243 | start = next; |
244 | continue; | 244 | continue; |
245 | } | 245 | } |
246 | /* -F N-M preserves intermediate delimiters: */ | ||
247 | //printf "1 2 3 4 5 6 7\n" | toybox cut -O: -F2,4-6,7 | ||
248 | //2:4 5 6:7 | ||
249 | if (opt_REGEX && dcount <= cut_list[cl_pos].endpos) | ||
250 | continue; | ||
251 | // NB: toybox does the above for -f too, but it's a compatibility bug: | ||
252 | //printf "1 2 3 4 5 6 7 8\n" | toybox cut -d' ' -O: -f2,4-6,7 | ||
253 | //2:4 5 6:7 // WRONG! | ||
254 | //printf "1 2 3 4 5 6 7 8\n" | cut -d' ' --output-delimiter=: -f2,4-6,7 | ||
255 | //2:4:5:6:7 // GNU coreutils 9.1 | ||
246 | } | 256 | } |
247 | #if ENABLE_FEATURE_CUT_REGEX | 257 | #if ENABLE_FEATURE_CUT_REGEX |
248 | if (end != start || !opt_REGEX) | 258 | if (end != start || !opt_REGEX) |