"Darryl B" <[EMAIL PROTECTED]> writes:
> I've tried doing
>
> wget -O file.txt -i file.html
>
> in v1.7 and v1.6 and in both cases the output file isn't a concatenation of
> the URLs in file.html; instead it's just the output of the last URL in
> file.html.
Thanks for the report; does this patch fix the problem? (It's against
the latest CVS, but should apply to 1.6 too.)
2001-04-02 Hrvoje Niksic <[EMAIL PROTECTED]>
* retr.c (retrieve_url): New variable global_download_count used
to identify first retrieval.
* ftp.c (getftp): Ditto.
* http.c (gethttp): Rewind opt.dfp only on first retrieval.
Index: src/ftp.c
===================================================================
RCS file: /pack/anoncvs/wget/src/ftp.c,v
retrieving revision 1.34
diff -u -r1.34 ftp.c
--- src/ftp.c 2001/04/01 21:34:40 1.34
+++ src/ftp.c 2001/04/01 22:41:18
@@ -814,8 +814,13 @@
}
else
{
+ extern int global_download_count;
fp = opt.dfp;
- if (!restval)
+
+ /* Rewind the output document if the download starts over and if
+ this is the first download. See gethttp() for a longer
+ explanation. */
+ if (!restval && global_download_count == 0)
{
/* This will silently fail for streams that don't correspond
to regular files, but that's OK. */
Index: src/http.c
===================================================================
RCS file: /pack/anoncvs/wget/src/http.c,v
retrieving revision 1.41
diff -u -r1.41 http.c
--- src/http.c 2001/04/01 20:04:21 1.41
+++ src/http.c 2001/04/01 22:41:19
@@ -1285,8 +1285,22 @@
}
else /* opt.dfp */
{
+ extern int global_download_count;
fp = opt.dfp;
- if (!hs->restval)
+ /* To ensure that repeated "from scratch" downloads work for -O
+ files, we rewind the file pointer, unless restval is
+ non-zero. (This works only when -O is used on regular files,
+ but it's still a valuable feature.)
+
+ However, this loses when more than one URL is specified on
+ the command line the second rewinds eradicates the contents
+ of the first download. Thus we disable the above trick for
+ all the downloads except the very first one.
+
+ #### A possible solution to this would be to remember the
+ file position in the output document and to seek to that
+ position, instead of rewinding. */
+ if (!hs->restval && global_download_count == 0)
{
/* This will silently fail for streams that don't correspond
to regular files, but that's OK. */
Index: src/retr.c
===================================================================
RCS file: /pack/anoncvs/wget/src/retr.c,v
retrieving revision 1.22
diff -u -r1.22 retr.c
--- src/retr.c 2001/03/31 02:05:54 1.22
+++ src/retr.c 2001/04/01 22:41:19
@@ -54,6 +54,9 @@
static long internal_secs, internal_msecs;
#endif
+/* See the comment in gethttp() why this is needed. */
+int global_download_count;
+
void logflush PARAMS ((void));
/* From http.c. */
@@ -571,6 +574,8 @@
*newloc = url;
else
xfree (url);
+
+ ++global_download_count;
return result;
}