]> sjero.net Git - wget/commitdiff
[svn] Make sure directory and file names are encoded the same way.
authorhniksic <devnull@localhost>
Thu, 11 Apr 2002 15:25:51 +0000 (08:25 -0700)
committerhniksic <devnull@localhost>
Thu, 11 Apr 2002 15:25:51 +0000 (08:25 -0700)
Published in <sxsofgqmf6e.fsf@florida.arsdigita.de>.

src/ChangeLog
src/url.c

index 4605cad2b15f5c99e06afb817631674e12e77cd0..24227f9925ca8b92d733574b98edb8bff786d211 100644 (file)
@@ -1,3 +1,10 @@
+2002-04-11  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * url.c (url_filename): Use compose_file_name regardless of
+       whether opt.dirstruct is set.
+       (mkstruct): Don't handle the query and the reencoding of DIR; that
+       is done in compose_file_name.
+
 2002-04-10  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * wget.h: Ditto for extern char *exec_name.
index 911c4100a0822fa0634a3e0050c81d86c1aaf31f..6fb2418288f16f4bb4aef28732111a631b76d934 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -1228,9 +1228,8 @@ count_slashes (const char *s)
 static char *
 mkstruct (const struct url *u)
 {
-  char *dir, *dir_preencoding;
-  char *file, *res, *dirpref;
-  char *query = u->query && *u->query ? u->query : NULL;
+  char *dir, *file;
+  char *res, *dirpref;
   int l;
 
   if (opt.cut_dirs)
@@ -1284,9 +1283,6 @@ mkstruct (const struct url *u)
       dir = newdir;
     }
 
-  dir_preencoding = dir;
-  dir = reencode_string (dir_preencoding);
-
   l = strlen (dir);
   if (l && dir[l - 1] == '/')
     dir[l - 1] = '\0';
@@ -1298,16 +1294,9 @@ mkstruct (const struct url *u)
 
   /* Finally, construct the full name.  */
   res = (char *)xmalloc (strlen (dir) + 1 + strlen (file)
-                        + (query ? (1 + strlen (query)) : 0)
                         + 1);
   sprintf (res, "%s%s%s", dir, *dir ? "/" : "", file);
-  if (query)
-    {
-      strcat (res, "?");
-      strcat (res, query);
-    }
-  if (dir != dir_preencoding)
-    xfree (dir);
+
   return res;
 }
 
@@ -1374,26 +1363,25 @@ char *
 url_filename (const struct url *u)
 {
   char *file, *name;
-  int have_prefix = 0;         /* whether we must prepend opt.dir_prefix */
+
+  char *query = u->query && *u->query ? u->query : NULL;
 
   if (opt.dirstruct)
     {
-      file = mkstruct (u);
-      have_prefix = 1;
+      char *base = mkstruct (u);
+      file = compose_file_name (base, query);
+      xfree (base);
     }
   else
     {
       char *base = *u->file ? u->file : "index.html";
-      char *query = u->query && *u->query ? u->query : NULL;
       file = compose_file_name (base, query);
-    }
 
-  if (!have_prefix)
-    {
       /* Check whether the prefix directory is something other than "."
         before prepending it.  */
       if (!DOTP (opt.dir_prefix))
        {
+         /* #### should just realloc FILE and prepend dir_prefix. */
          char *nfile = (char *)xmalloc (strlen (opt.dir_prefix)
                                         + 1 + strlen (file) + 1);
          sprintf (nfile, "%s/%s", opt.dir_prefix, file);
@@ -1401,6 +1389,7 @@ url_filename (const struct url *u)
          file = nfile;
        }
     }
+
   /* DOS-ish file systems don't like `%' signs in them; we change it
      to `@'.  */
 #ifdef WINDOWS