diff --git a/src/ChangeLog b/src/ChangeLog index f4eaa004..0a73fffc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-09-19 Hrvoje Niksic + + * url.c (url_file_name): Expect NULL dir_prefix. + + * init.c (cmd_file): Use a macro to prevent multiple #ifdef + WINDOWS. + (defaults): Set dir_prefix to NULL by default. + 2003-09-19 Hrvoje Niksic * safe-ctype.h (_sch_test): Cast BIT to unsigned char, like latest diff --git a/src/init.c b/src/init.c index b4ab130a..59a2aab9 100644 --- a/src/init.c +++ b/src/init.c @@ -256,7 +256,6 @@ defaults (void) opt.cookies = 1; opt.verbose = -1; - opt.dir_prefix = xstrdup ("."); opt.ntry = 20; opt.reclevel = 5; opt.add_hostdir = 1; @@ -668,6 +667,12 @@ cmd_string (const char *com, const char *val, void *closure) return 1; } +#ifndef WINDOWS +# define ISSEP(c) ((c) == '/') +#else +# define ISSEP(c) ((c) == '/' || (c) == '\\') +#endif + /* Like the above, but handles tilde-expansion when reading a user's `.wgetrc'. In that case, and if VAL begins with `~', the tilde gets expanded to the user's home directory. */ @@ -680,11 +685,7 @@ cmd_file (const char *com, const char *val, void *closure) /* #### If VAL is empty, perhaps should set *CLOSURE to NULL. */ - if (!enable_tilde_expansion || !(*val == '~' && (*(val + 1) == '/' -#ifdef WINDOWS - || *(val + 1) == '\\' -#endif - ))) + if (!enable_tilde_expansion || !(*val == '~' && ISSEP (val[1]))) { noexpand: *pstring = xstrdup (val); @@ -698,21 +699,12 @@ cmd_file (const char *com, const char *val, void *closure) goto noexpand; homelen = strlen (home); - while (homelen && (home[homelen - 1] == '/' -#ifdef WINDOWS - || home[homelen - 1] == '\\' -#endif - )) + while (homelen && ISSEP (home[homelen - 1])) home[--homelen] = '\0'; /* Skip the leading "~/". */ -#ifdef WINDOWS - for (++val; *val == '/' || *val == '\\'; val++) + for (++val; ISSEP (*val); val++) ; -#else - for (++val; *val == '/'; val++) - ; -#endif result = xmalloc (homelen + 1 + strlen (val) + 1); memcpy (result, home, homelen); @@ -721,6 +713,7 @@ cmd_file (const char *com, const char *val, void *closure) *pstring = result; } + #ifdef WINDOWS /* Convert "\" to "/". */ { @@ -1146,7 +1139,7 @@ cleanup (void) free_netrc (netrc_list); } FREE_MAYBE (opt.lfilename); - xfree (opt.dir_prefix); + FREE_MAYBE (opt.dir_prefix); FREE_MAYBE (opt.input_filename); FREE_MAYBE (opt.output_document); free_vec (opt.accepts); diff --git a/src/url.c b/src/url.c index 4f5c7f8e..af44f9b7 100644 --- a/src/url.c +++ b/src/url.c @@ -54,16 +54,6 @@ so, delete this exception statement from your version. */ extern int errno; #endif -/* Is X "."? */ -#define DOTP(x) ((*(x) == '.') && (!*(x + 1))) -/* Is X ".."? */ -#define DDOTP(x) ((*(x) == '.') && (*(x + 1) == '.') && (!*(x + 2))) - -static const int NS_INADDRSZ = 4; -static const int NS_IN6ADDRSZ = 16; -static const int NS_INT16SZ = 2; - - struct scheme_data { char *leading_string; @@ -711,6 +701,10 @@ is_valid_ipv4_address (const char *str, const char *end) return 1; } +static const int NS_INADDRSZ = 4; +static const int NS_IN6ADDRSZ = 16; +static const int NS_INT16SZ = 2; + static int is_valid_ipv6_address (const char *str, const char *end) { @@ -1663,7 +1657,7 @@ url_file_name (const struct url *u) fnres.tail = 0; /* Start with the directory prefix, if specified. */ - if (!DOTP (opt.dir_prefix)) + if (opt.dir_prefix) append_string (opt.dir_prefix, &fnres); /* If "dirstruct" is turned on (typically the case with -r), add