]> sjero.net Git - wget/commitdiff
[svn] Allow --header to contain ",".
authorhniksic <devnull@localhost>
Mon, 30 May 2005 13:31:24 +0000 (06:31 -0700)
committerhniksic <devnull@localhost>
Mon, 30 May 2005 13:31:24 +0000 (06:31 -0700)
src/ChangeLog
src/init.c
src/utils.c
src/utils.h

index f0c1488b89e7e9b6c02588bf46896a317fad7a7d..9625804f43502eb7e260fe6dd7b82e3a98ac594a 100644 (file)
@@ -1,3 +1,11 @@
+2005-05-30  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * init.c (cmd_spec_header): Don't split the string along the
+       commas using cmd_vector; just append the new value using
+       vec_append instead.
+
+       * utils.c (vec_append): New function.
+
 2005-05-27  Andreas Beckmann  <debian@abeckmann.de>
 
        * html-url.c (tag_handle_link): Mark the content from the <link
index e17510c32a81f5056249d830e2f964c380e59f94..b6347aa5ecf8cc6804f99c50fe2ea37a220f3224 100644 (file)
@@ -162,7 +162,7 @@ static struct {
   { "ftpproxy",                &opt.ftp_proxy,         cmd_string },
   { "ftpuser",         &opt.ftp_user,          cmd_string },
   { "glob",            &opt.ftp_glob,          cmd_boolean },
-  { "header",          &opt.user_headers,      cmd_spec_header },
+  { "header",          NULL,                   cmd_spec_header },
   { "htmlextension",   &opt.html_extension,    cmd_boolean },
   { "htmlify",         NULL,                   cmd_spec_htmlify },
   { "httpkeepalive",   &opt.http_keep_alive,   cmd_boolean },
@@ -1118,15 +1118,24 @@ cmd_spec_dirstruct (const char *com, const char *val, void *place_ignored)
 }
 
 static int
-cmd_spec_header (const char *com, const char *val, void *place)
+cmd_spec_header (const char *com, const char *val, void *place_ignored)
 {
+  /* Empty value means reset the list of headers. */
+  if (*val == '\0')
+    {
+      free_vec (opt.user_headers);
+      opt.user_headers = NULL;
+      return 1;
+    }
+
   if (!check_user_specified_header (val))
     {
       fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),
               exec_name, com, val);
       return 0;
     }
-  return cmd_vector (com, val, place);
+  opt.user_headers = vec_append (opt.user_headers, val);
+  return 1;
 }
 
 static int
index 04968e6226e2b9f7d81baa1acf376f6593cb6a30..549f7a47ed44c2e1effd2fd9741066055a093ef7 100644 (file)
@@ -1085,6 +1085,30 @@ merge_vecs (char **v1, char **v2)
   xfree (v2);
   return v1;
 }
+
+/* Append a freshly allocated copy of STR to VEC.  If VEC is NULL, it
+   is allocated as needed.  Return the new value of the vector. */
+
+char **
+vec_append (char **vec, const char *str)
+{
+  int cnt;                     /* count of vector elements, including
+                                  the one we're about to append */
+  if (vec != NULL)
+    {
+      for (cnt = 0; vec[cnt]; cnt++)
+       ;
+      ++cnt;
+    }
+  else
+    cnt = 1;
+  /* Reallocate the array to fit the new element and the NULL. */
+  vec = xrealloc (vec, (cnt + 1) * sizeof (char *));
+  /* Append a copy of STR to the vector. */
+  vec[cnt - 1] = xstrdup (str);
+  vec[cnt] = NULL;
+  return vec;
+}
 \f
 /* Sometimes it's useful to create "sets" of strings, i.e. special
    hash tables where you want to store strings as keys and merely
index 51816a08abd10c394a4ec30d8269f6260f83d6ba..9306b71d7d953078ae5f5782a3c162da3e317a04 100644 (file)
@@ -92,6 +92,7 @@ void read_file_free PARAMS ((struct file_memory *));
 
 void free_vec PARAMS ((char **));
 char **merge_vecs PARAMS ((char **, char **));
+char **vec_append PARAMS ((char **, const char *));
 
 void string_set_add PARAMS ((struct hash_table *, const char *));
 int string_set_contains PARAMS ((struct hash_table *, const char *));