diff options
author | Jim Meyering <jim@meyering.net> | 1994-11-02 05:04:17 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-11-02 05:04:17 +0000 |
commit | 346a1b23518a7270ca90c9d5ec3f8b5e256796d2 (patch) | |
tree | 4a5a0b384c8ce63011e3e9647c8d1c6711065a1e /src | |
parent | 32340b45e70eeff17f153615e8f3e43712cb7ba9 (diff) | |
download | coreutils-346a1b23518a7270ca90c9d5ec3f8b5e256796d2.tar.xz |
(cut_bytes): Print at least a newline for every line of input.
(cut_fields): Print a newline even for lines whose only selected
field is empty. But print nothing when using -s without -f1.
And print nothing for empty input. Reported by
Richard_Sharman@software.mitel.com.
Diffstat (limited to 'src')
-rw-r--r-- | src/cut.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -495,9 +495,7 @@ cut_bytes (stream) FILE *stream; { int byte_idx; /* Number of chars in the line so far. */ - int printed_from_curr_line; - printed_from_curr_line = 0; byte_idx = 0; while (1) { @@ -505,21 +503,22 @@ cut_bytes (stream) c = getc (stream); - if (c == '\n' || c == EOF) + if (c == '\n') { - if (printed_from_curr_line) - putchar ('\n'); - if (c == EOF) - break; - printed_from_curr_line = 0; + putchar ('\n'); byte_idx = 0; } + else if (c == EOF) + { + if (byte_idx > 0) + putchar ('\n'); + break; + } else { ++byte_idx; if (print_kth (byte_idx)) { - printed_from_curr_line = 1; putchar (c); } } @@ -620,7 +619,8 @@ cut_fields (stream) ++field_idx; else if (c == '\n' || c == EOF) { - if (found_any_selected_field) + if (found_any_selected_field + || !(suppress_non_delimited && field_idx == 1)) putchar ('\n'); if (c == EOF) break; |