aboutsummaryrefslogtreecommitdiff
path: root/wget.c
diff options
context:
space:
mode:
Diffstat (limited to 'wget.c')
-rw-r--r--wget.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/wget.c b/wget.c
index 4f894fcaa..c06e76d90 100644
--- a/wget.c
+++ b/wget.c
@@ -50,7 +50,7 @@ int wget_main(int argc, char **argv)
50 ++do_continue; 50 ++do_continue;
51 break; 51 break;
52 case 'O': 52 case 'O':
53 fname_out = optarg; 53 fname_out = (strcmp(optarg, "-") == 0 ? NULL : optarg);
54 break; 54 break;
55 default: 55 default:
56 usage(wget_usage); 56 usage(wget_usage);
@@ -74,12 +74,8 @@ int wget_main(int argc, char **argv)
74 * Open the output stream. 74 * Open the output stream.
75 */ 75 */
76 if (fname_out != NULL) { 76 if (fname_out != NULL) {
77 /* Check if the file is supposed to go to stdout */ 77 if (freopen(fname_out, (do_continue ? "a" : "w"), stdout) == NULL)
78 if (!strcmp(fname_out, "-") == 0) { 78 fatalError("wget: freopen(%s): %s\n", fname_out, strerror(errno));
79 /* Nope -- so open the output file */
80 if (freopen(fname_out, (do_continue ? "a" : "w"), stdout) == NULL)
81 fatalError("wget: freopen(%s): %s\n", fname_out, strerror(errno));
82 }
83 } 79 }
84 80
85 /* 81 /*
@@ -248,7 +244,7 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
248 return hdrval; 244 return hdrval;
249 } 245 }
250 246
251 /* Rat! The buffer isn't big enough to hold the entire header value. */ 247 /* Rats! The buffer isn't big enough to hold the entire header value. */
252 while (c = getc(fp), c != EOF && c != '\n') 248 while (c = getc(fp), c != EOF && c != '\n')
253 ; 249 ;
254 *istrunc = 1; 250 *istrunc = 1;