From 8b2a216c77768f7ca482e82b9b2f0ff1f772ed20 Mon Sep 17 00:00:00 2001 From: hniksic Date: Sat, 1 Dec 2001 11:17:19 -0800 Subject: [PATCH] [svn] Make --base -i work. Published in . --- src/ChangeLog | 5 +++++ src/url.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index cb5d2cd5..2c513dcf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-12-01 Hrvoje Niksic + + * url.c (get_urls_file): If opt.base_href is specified, merge each + URL with the base. + 2001-12-01 Hrvoje Niksic * main.c (print_help): Don't document the removed `-nh'. diff --git a/src/url.c b/src/url.c index 44866bf6..fde1a412 100644 --- a/src/url.c +++ b/src/url.c @@ -1009,13 +1009,25 @@ get_urls_file (const char *file) --line_end; if (line_end > line_beg) { + /* URL is in the [line_beg, line_end) region. */ + int up_error_code; char *url_text; struct urlpos *entry; struct url *url; - /* We must copy the URL to a zero-terminated string. *sigh*. */ + /* We must copy the URL to a zero-terminated string, and we + can't use alloca because we're in a loop. *sigh*. */ url_text = strdupdelim (line_beg, line_end); + + if (opt.base_href) + { + /* Merge opt.base_href with URL. */ + char *merged = uri_merge (opt.base_href, url_text); + xfree (url_text); + url_text = merged; + } + url = url_parse (url_text, &up_error_code); if (!url) { @@ -1382,7 +1394,7 @@ find_last_char (const char *b, const char *e, char c) The parameters LINKLENGTH is useful if LINK is not zero-terminated. See uri_merge for a gentler interface to this functionality. - #### This function should handle `./' and `../' so that the evil + Perhaps this function should handle `./' and `../' so that the evil path_simplify can go. */ static char * uri_merge_1 (const char *base, const char *link, int linklength, int no_scheme)