]> sjero.net Git - wget/blobdiff - src/utils.c
[svn] Allow --header to contain ",".
[wget] / src / utils.c
index e09a2355c7e1950274fa9ae4f76c3de200c01eaf..549f7a47ed44c2e1effd2fd9741066055a093ef7 100644 (file)
@@ -681,19 +681,21 @@ static char *
 proclist (char **strlist, const char *s, enum accd flags)
 {
   char **x;
-
   for (x = strlist; *x; x++)
-    if (has_wildcards_p (*x))
-      {
-       if (fnmatch (*x, s, FNM_PATHNAME) == 0)
-         break;
-      }
-    else
-      {
-       char *p = *x + ((flags & ALLABS) && (**x == '/')); /* Remove '/' */
-       if (frontcmp (p, s))
-         break;
-      }
+    {
+      /* Remove leading '/' if ALLABS */
+      char *p = *x + ((flags & ALLABS) && (**x == '/'));
+      if (has_wildcards_p (p))
+       {
+         if (fnmatch (p, s, FNM_PATHNAME) == 0)
+           break;
+       }
+      else
+       {
+         if (frontcmp (p, s))
+           break;
+       }
+    }
   return *x;
 }
 
@@ -1083,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
@@ -1980,7 +2006,7 @@ base64_decode (const char *base64, char *to)
 #undef NEXT_BASE64_CHAR
 \f
 /* Simple merge sort for use by stable_sort.  Implementation courtesy
-   Zeljko Vrba.  */
+   Zeljko Vrba with additional debugging by Nenad Barbutov.  */
 
 static void
 mergesort_internal (void *base, void *temp, size_t size, size_t from, size_t to,