]> sjero.net Git - wget/commitdiff
[svn] Default dir_prefix to NULL rather than ".".
authorhniksic <devnull@localhost>
Fri, 19 Sep 2003 15:28:36 +0000 (08:28 -0700)
committerhniksic <devnull@localhost>
Fri, 19 Sep 2003 15:28:36 +0000 (08:28 -0700)
src/ChangeLog
src/init.c
src/url.c

index f4eaa0047f39ed154e07a14f4775903f92748c7e..0a73fffc02eac91acb4880d88669a535949d212a 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-19  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * 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  <hniksic@xemacs.org>
 
        * safe-ctype.h (_sch_test): Cast BIT to unsigned char, like latest
index b4ab130aee67a2f5482c0519df53552c9e0646c0..59a2aab9bf14af3d43b2cc5f540d9be5a92a7b2f 100644 (file)
@@ -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++)
-       ;
-#else
-      for (++val; *val == '/'; val++)
+      for (++val; ISSEP (*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);
index 4f5c7f8ea4cabbbb720160caf456134e9e8e96de..af44f9b7351f71bd7968372955669391f3b218b5 100644 (file)
--- 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