diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-01-22 11:16:08 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-01-22 11:16:08 +0100 |
commit | bf99807657eac6f0d4fc593b3a83d34338c62293 (patch) | |
tree | d0d4eeb36d73cadb78df67d762dd2e80f1bf5f85 /archival/unzip.c | |
parent | 9b7ebfe6447349e6b614b53413c21fce7bce7da1 (diff) | |
download | busybox-w32-bf99807657eac6f0d4fc593b3a83d34338c62293.tar.gz busybox-w32-bf99807657eac6f0d4fc593b3a83d34338c62293.tar.bz2 busybox-w32-bf99807657eac6f0d4fc593b3a83d34338c62293.zip |
unzip: add missing fflush; code shrink
function old new delta
my_fgets80 - 41 +41
unzip_main 2291 2242 -49
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/unzip.c')
-rw-r--r-- | archival/unzip.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/archival/unzip.c b/archival/unzip.c index 83bf8f6d6..e4c824850 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -267,6 +267,14 @@ static void unzip_extract(zip_header_t *zip_header, int dst_fd) | |||
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | static void my_fgets80(char *buf80) | ||
271 | { | ||
272 | fflush_all(); | ||
273 | if (!fgets(buf80, 80, stdin)) { | ||
274 | bb_perror_msg_and_die("can't read standard input"); | ||
275 | } | ||
276 | } | ||
277 | |||
270 | int unzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 278 | int unzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
271 | int unzip_main(int argc, char **argv) | 279 | int unzip_main(int argc, char **argv) |
272 | { | 280 | { |
@@ -291,7 +299,7 @@ int unzip_main(int argc, char **argv) | |||
291 | llist_t *zreject = NULL; | 299 | llist_t *zreject = NULL; |
292 | char *base_dir = NULL; | 300 | char *base_dir = NULL; |
293 | int i, opt; | 301 | int i, opt; |
294 | char key_buf[80]; | 302 | char key_buf[80]; /* must match size used by my_fgets80 */ |
295 | struct stat stat_buf; | 303 | struct stat stat_buf; |
296 | 304 | ||
297 | /* -q, -l and -v: UnZip 5.52 of 28 February 2005, by Info-ZIP: | 305 | /* -q, -l and -v: UnZip 5.52 of 28 February 2005, by Info-ZIP: |
@@ -624,10 +632,7 @@ int unzip_main(int argc, char **argv) | |||
624 | i = 'y'; | 632 | i = 'y'; |
625 | } else { | 633 | } else { |
626 | printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); | 634 | printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); |
627 | fflush_all(); | 635 | my_fgets80(key_buf); |
628 | if (!fgets(key_buf, sizeof(key_buf), stdin)) { | ||
629 | bb_perror_msg_and_die("can't read standard input"); | ||
630 | } | ||
631 | i = key_buf[0]; | 636 | i = key_buf[0]; |
632 | } | 637 | } |
633 | } else { /* File is not regular file */ | 638 | } else { /* File is not regular file */ |
@@ -668,9 +673,7 @@ int unzip_main(int argc, char **argv) | |||
668 | case 'r': | 673 | case 'r': |
669 | /* Prompt for new name */ | 674 | /* Prompt for new name */ |
670 | printf("new name: "); | 675 | printf("new name: "); |
671 | if (!fgets(key_buf, sizeof(key_buf), stdin)) { | 676 | my_fgets80(key_buf); |
672 | bb_perror_msg_and_die("can't read standard input"); | ||
673 | } | ||
674 | free(dst_fn); | 677 | free(dst_fn); |
675 | dst_fn = xstrdup(key_buf); | 678 | dst_fn = xstrdup(key_buf); |
676 | chomp(dst_fn); | 679 | chomp(dst_fn); |