diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-03-15 08:29:22 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-03-15 08:29:22 +0000 |
commit | c7bda1ce659294d6e22c06e087f6f265983c7578 (patch) | |
tree | 4c6d2217f4d8306c59cf1096f8664e1cfd167213 /coreutils/wc.c | |
parent | 8854004b41065b3d081af7f3df13a100b0c8bfbe (diff) | |
download | busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2 busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip |
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'coreutils/wc.c')
-rw-r--r-- | coreutils/wc.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/coreutils/wc.c b/coreutils/wc.c index 779901524..0eb795c4b 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
@@ -26,7 +26,7 @@ | |||
26 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) | 26 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) |
27 | * | 27 | * |
28 | * Rewritten to fix a number of problems and do some size optimizations. | 28 | * Rewritten to fix a number of problems and do some size optimizations. |
29 | * Problems in the previous busybox implementation (besides bloat) included: | 29 | * Problems in the previous busybox implementation (besides bloat) included: |
30 | * 1) broken 'wc -c' optimization (read note below) | 30 | * 1) broken 'wc -c' optimization (read note below) |
31 | * 2) broken handling of '-' args | 31 | * 2) broken handling of '-' args |
32 | * 3) no checking of ferror on EOF returns | 32 | * 3) no checking of ferror on EOF returns |
@@ -110,33 +110,33 @@ int wc_main(int argc, char **argv) | |||
110 | char status = EXIT_SUCCESS; | 110 | char status = EXIT_SUCCESS; |
111 | char in_word; | 111 | char in_word; |
112 | char print_type; | 112 | char print_type; |
113 | 113 | ||
114 | print_type = bb_getopt_ulflags(argc, argv, wc_opts); | 114 | print_type = bb_getopt_ulflags(argc, argv, wc_opts); |
115 | 115 | ||
116 | if (print_type == 0) { | 116 | if (print_type == 0) { |
117 | print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS); | 117 | print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS); |
118 | } | 118 | } |
119 | 119 | ||
120 | argv += optind; | 120 | argv += optind; |
121 | if (!*argv) { | 121 | if (!*argv) { |
122 | *--argv = (char *) bb_msg_standard_input; | 122 | *--argv = (char *) bb_msg_standard_input; |
123 | } | 123 | } |
124 | 124 | ||
125 | memset(totals, 0, sizeof(totals)); | 125 | memset(totals, 0, sizeof(totals)); |
126 | 126 | ||
127 | pcounts = counts; | 127 | pcounts = counts; |
128 | 128 | ||
129 | do { | 129 | do { |
130 | ++num_files; | 130 | ++num_files; |
131 | if (!(fp = bb_wfopen_input(*argv))) { | 131 | if (!(fp = bb_wfopen_input(*argv))) { |
132 | status = EXIT_FAILURE; | 132 | status = EXIT_FAILURE; |
133 | continue; | 133 | continue; |
134 | } | 134 | } |
135 | 135 | ||
136 | memset(counts, 0, sizeof(counts)); | 136 | memset(counts, 0, sizeof(counts)); |
137 | linepos = 0; | 137 | linepos = 0; |
138 | in_word = 0; | 138 | in_word = 0; |
139 | 139 | ||
140 | do { | 140 | do { |
141 | ++counts[WC_CHARS]; | 141 | ++counts[WC_CHARS]; |
142 | c = getc(fp); | 142 | c = getc(fp); |
@@ -177,21 +177,21 @@ int wc_main(int argc, char **argv) | |||
177 | } else { | 177 | } else { |
178 | continue; | 178 | continue; |
179 | } | 179 | } |
180 | 180 | ||
181 | counts[WC_WORDS] += in_word; | 181 | counts[WC_WORDS] += in_word; |
182 | in_word = 0; | 182 | in_word = 0; |
183 | if (c == EOF) { | 183 | if (c == EOF) { |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | } while (1); | 186 | } while (1); |
187 | 187 | ||
188 | if (totals[WC_LENGTH] < counts[WC_LENGTH]) { | 188 | if (totals[WC_LENGTH] < counts[WC_LENGTH]) { |
189 | totals[WC_LENGTH] = counts[WC_LENGTH]; | 189 | totals[WC_LENGTH] = counts[WC_LENGTH]; |
190 | } | 190 | } |
191 | totals[WC_LENGTH] -= counts[WC_LENGTH]; | 191 | totals[WC_LENGTH] -= counts[WC_LENGTH]; |
192 | 192 | ||
193 | bb_fclose_nonstdin(fp); | 193 | bb_fclose_nonstdin(fp); |
194 | 194 | ||
195 | OUTPUT: | 195 | OUTPUT: |
196 | s = fmt_str + 1; /* Skip the leading space on 1st pass. */ | 196 | s = fmt_str + 1; /* Skip the leading space on 1st pass. */ |
197 | u = 0; | 197 | u = 0; |
@@ -202,16 +202,16 @@ int wc_main(int argc, char **argv) | |||
202 | } | 202 | } |
203 | totals[u] += pcounts[u]; | 203 | totals[u] += pcounts[u]; |
204 | } while (++u < 4); | 204 | } while (++u < 4); |
205 | 205 | ||
206 | s += 8; /* Set the format to the empty string. */ | 206 | s += 8; /* Set the format to the empty string. */ |
207 | 207 | ||
208 | if (*argv != bb_msg_standard_input) { | 208 | if (*argv != bb_msg_standard_input) { |
209 | s -= 3; /* We have a name, so do %s conversion. */ | 209 | s -= 3; /* We have a name, so do %s conversion. */ |
210 | } | 210 | } |
211 | bb_printf(s, *argv); | 211 | bb_printf(s, *argv); |
212 | 212 | ||
213 | } while (*++argv); | 213 | } while (*++argv); |
214 | 214 | ||
215 | /* If more than one file was processed, we want the totals. To save some | 215 | /* If more than one file was processed, we want the totals. To save some |
216 | * space, we set the pcounts ptr to the totals array. This has the side | 216 | * space, we set the pcounts ptr to the totals array. This has the side |
217 | * effect of trashing the totals array after outputting it, but that's | 217 | * effect of trashing the totals array after outputting it, but that's |
@@ -222,6 +222,6 @@ int wc_main(int argc, char **argv) | |||
222 | pcounts = totals; | 222 | pcounts = totals; |
223 | goto OUTPUT; | 223 | goto OUTPUT; |
224 | } | 224 | } |
225 | 225 | ||
226 | bb_fflush_stdout_and_exit(status); | 226 | bb_fflush_stdout_and_exit(status); |
227 | } | 227 | } |