diff options
author | Jim Meyering <jim@meyering.net> | 2003-08-02 19:53:52 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-08-02 19:53:52 +0000 |
commit | aca28ca9ac235250ba848c707522edddbac70c42 (patch) | |
tree | 296e3afe3c6420a19fbfd75c06527fddef77ccbf | |
parent | 40944ce6ceb576174d80e65d41b1e0bd592535cf (diff) | |
download | coreutils-aca28ca9ac235250ba848c707522edddbac70c42.tar.xz |
(cut_fields): Don't read again after encountering EOF.
E.g., `cut -f2' would do so.
-rw-r--r-- | src/cut.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -563,15 +563,15 @@ cut_fields (FILE *stream) unsigned int field_idx; int found_any_selected_field; int buffer_first_field; - int empty_input; found_any_selected_field = 0; field_idx = 1; c = getc (stream); - empty_input = (c == EOF); - if (c != EOF) - ungetc (c, stream); + if (c == EOF) + return; + + ungetc (c, stream); /* To support the semantics of the -s flag, we may have to buffer all of the first field to determine whether it is `delimited.' @@ -667,7 +667,7 @@ cut_fields (FILE *stream) else if (c == '\n' || c == EOF) { if (found_any_selected_field - || (!empty_input && !(suppress_non_delimited && field_idx == 1))) + || !(suppress_non_delimited && field_idx == 1)) putchar ('\n'); if (c == EOF) break; |