diff options
author | Rob Landley <rob@landley.net> | 2006-09-23 19:56:21 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-09-23 19:56:21 +0000 |
commit | 29d94b907f8e1849385e9a2ac5e286c5c2d40936 (patch) | |
tree | 15c270192cc99ea439c3a6093eef0b980c3962d3 /coreutils/uudecode.c | |
parent | a94554d010844e17ecf674fe738679f09cbc6c21 (diff) | |
download | busybox-w32-29d94b907f8e1849385e9a2ac5e286c5c2d40936.tar.gz busybox-w32-29d94b907f8e1849385e9a2ac5e286c5c2d40936.tar.bz2 busybox-w32-29d94b907f8e1849385e9a2ac5e286c5c2d40936.zip |
Another attempt at untangling the logic so the compiler can follow it and not
generate pointless warnings.
Diffstat (limited to 'coreutils/uudecode.c')
-rw-r--r-- | coreutils/uudecode.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 1df143f9d..21ebce3ac 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -142,41 +142,40 @@ int uudecode_main(int argc, char **argv) | |||
142 | /* Search for the start of the encoding */ | 142 | /* Search for the start of the encoding */ |
143 | while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) { | 143 | while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL) { |
144 | int (*decode_fn_ptr)(FILE * src, FILE * dst); | 144 | int (*decode_fn_ptr)(FILE * src, FILE * dst); |
145 | char *line_ptr = NULL; | 145 | char *line_ptr; |
146 | 146 | FILE *dst_stream; | |
147 | int mode; | ||
148 | int ret; | ||
149 | |||
147 | if (strncmp(line, "begin-base64 ", 13) == 0) { | 150 | if (strncmp(line, "begin-base64 ", 13) == 0) { |
148 | line_ptr = line + 13; | 151 | line_ptr = line + 13; |
149 | decode_fn_ptr = read_base64; | 152 | decode_fn_ptr = read_base64; |
150 | } else if (strncmp(line, "begin ", 6) == 0) { | 153 | } else if (strncmp(line, "begin ", 6) == 0) { |
151 | line_ptr = line + 6; | 154 | line_ptr = line + 6; |
152 | decode_fn_ptr = read_stduu; | 155 | decode_fn_ptr = read_stduu; |
156 | } else { | ||
157 | free(line); | ||
158 | continue; | ||
153 | } | 159 | } |
154 | 160 | ||
155 | if (line_ptr) { | 161 | mode = strtoul(line_ptr, NULL, 8); |
156 | FILE *dst_stream; | 162 | if (outname == NULL) { |
157 | int mode; | 163 | outname = strchr(line_ptr, ' '); |
158 | int ret; | 164 | if ((outname == NULL) || (*outname == '\0')) { |
159 | 165 | break; | |
160 | mode = strtoul(line_ptr, NULL, 8); | ||
161 | if (outname == NULL) { | ||
162 | outname = strchr(line_ptr, ' '); | ||
163 | if ((outname == NULL) || (*outname == '\0')) { | ||
164 | break; | ||
165 | } | ||
166 | outname++; | ||
167 | } | ||
168 | if (strcmp(outname, "-") == 0) { | ||
169 | dst_stream = stdout; | ||
170 | } else { | ||
171 | dst_stream = xfopen(outname, "w"); | ||
172 | chmod(outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)); | ||
173 | } | 166 | } |
174 | free(line); | 167 | outname++; |
175 | ret = decode_fn_ptr(src_stream, dst_stream); | 168 | } |
176 | bb_fclose_nonstdin(src_stream); | 169 | if (strcmp(outname, "-") == 0) { |
177 | return(ret); | 170 | dst_stream = stdout; |
171 | } else { | ||
172 | dst_stream = xfopen(outname, "w"); | ||
173 | chmod(outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)); | ||
178 | } | 174 | } |
179 | free(line); | 175 | free(line); |
176 | ret = decode_fn_ptr(src_stream, dst_stream); | ||
177 | bb_fclose_nonstdin(src_stream); | ||
178 | return(ret); | ||
180 | } | 179 | } |
181 | bb_error_msg_and_die("No `begin' line"); | 180 | bb_error_msg_and_die("No `begin' line"); |
182 | } | 181 | } |