aboutsummaryrefslogtreecommitdiff
path: root/coreutils/cut.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-09-23 11:11:14 +0100
committerRon Yorston <rmy@pobox.com>2024-09-23 11:11:14 +0100
commitbca962188b113497221976a71fd18b1c11a120ab (patch)
treeef3ecd1a55f4bdca9ee21ad44b7fe1213cb173e3 /coreutils/cut.c
parent674bcfad99b6b486204f4a97beb6e3571034a05e (diff)
downloadbusybox-w32-bca962188b113497221976a71fd18b1c11a120ab.tar.gz
busybox-w32-bca962188b113497221976a71fd18b1c11a120ab.tar.bz2
busybox-w32-bca962188b113497221976a71fd18b1c11a120ab.zip
cut: don't print empty lines with '-s' option
A command like 'cut -f1 -s' would print empty lines even though they don't contain a delimiter. Add a test to avoid this. Based on a submission to the upstream mailing list: http://lists.busybox.net/pipermail/busybox/2024-July/090834.html Adds 32 bytes in 32-bit build, saves 32 in 64-bit. (GitHub issue #459)
Diffstat (limited to '')
-rw-r--r--coreutils/cut.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/coreutils/cut.c b/coreutils/cut.c
index d129f9b9d..067e69b12 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -152,6 +152,11 @@ static void cut_file(FILE *file, const char *delim, const char *odelim,
152 unsigned uu = 0, start = 0, end = 0, out = 0; 152 unsigned uu = 0, start = 0, end = 0, out = 0;
153 int dcount = 0; 153 int dcount = 0;
154 154
155#if ENABLE_PLATFORM_MINGW32
156 /* An empty line can't contain a delimiter */
157 if (linelen == 0 && (option_mask32 & CUT_OPT_SUPPRESS_FLGS))
158 goto next_line;
159#endif
155 /* Loop through bytes, finding next delimiter */ 160 /* Loop through bytes, finding next delimiter */
156 for (;;) { 161 for (;;) {
157 /* End of current range? */ 162 /* End of current range? */