diff options
Diffstat (limited to 'cut.c')
-rw-r--r-- | cut.c | 18 |
1 files changed, 4 insertions, 14 deletions
@@ -108,20 +108,10 @@ static void cut_file(FILE *file) | |||
108 | for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) { | 108 | for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) { |
109 | /* cut based on chars/bytes */ | 109 | /* cut based on chars/bytes */ |
110 | if (part == 'c' || part == 'b') { | 110 | if (part == 'c' || part == 'b') { |
111 | int i; | 111 | chomp(line); |
112 | /* a valid end position has been specified */ | 112 | if (0 < endpos && endpos < strlen(line)) |
113 | if (endpos > 0) { | 113 | line[endpos] = '\0'; |
114 | for (i = startpos-1; i < endpos; i++) { | 114 | puts(line + startpos - 1); |
115 | fputc(line[i], stdout); | ||
116 | } | ||
117 | fputc('\n', stdout); | ||
118 | } | ||
119 | /* otherwise, just go to the end of the line */ | ||
120 | else { | ||
121 | for (i = startpos-1; line[i]; i++) { | ||
122 | fputc(line[i], stdout); | ||
123 | } | ||
124 | } | ||
125 | } | 115 | } |
126 | /* cut based on fields */ | 116 | /* cut based on fields */ |
127 | else if (part == 'f') { | 117 | else if (part == 'f') { |