]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* setup.c (findhref): Return NULL on empty string. Eat any trailing
authorChristopher Faylor <me@cgf.cx>
Thu, 27 Apr 2000 18:24:13 +0000 (18:24 +0000)
committerChristopher Faylor <me@cgf.cx>
Thu, 27 Apr 2000 18:24:13 +0000 (18:24 +0000)
";something".
(processdirlisting): Attempt to limit recursively processing the same
directory.

ChangeLog
setup.c

index 5c432b6f0232dd6bd371c327bd6ef25a85b58812..8d55054a89567aa507b7b287c001679de9106d6e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Apr 27 14:21:30 2000  Christopher Faylor <cgf@cygnus.com>
+
+       * setup.c (findhref): Return NULL on empty string.  Eat any trailing
+       ";something".
+       (processdirlisting): Attempt to limit recursively processing the same
+       directory.
+
 Thu Apr 27 11:42:23 2000  Christopher Faylor <cgf@cygnus.com>
 
        * setup.c (filedel): New function.
diff --git a/setup.c b/setup.c
index db1915819d89b39cd94008883cef32aa12fab4f3..c664d28f1929e389a20416729c5aba1a5ddf1ada 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -660,8 +660,14 @@ findhref (char *buffer, char *date, size_t *filesize)
 {
   char *ref = NULL;
   char *anchor;
-  char *p = buffer;
-
+  char *p;
+  int eatspace;
+  char *q;
+  char digits[20];
+  char *diglast = digits + sizeof (digits) - 1;
+  int len;
+
+  p = buffer;
   while ((p = strchr (p, '<')) != NULL)
     {
       char *q = p;
@@ -684,44 +690,45 @@ findhref (char *buffer, char *date, size_t *filesize)
        }
     }
   
-  if (ref)
-    {
-      int eatspace;
-      char *p, *q;
-      char digits[20];
-      char *diglast = digits + sizeof (digits) - 1;
-      int len;
-
-      ref += ref[5] == '"' ? 6 : 5;
-
-      len = strcspn (ref, "\" >");
-
-      ref[len] = '\0';
-      if (!filesize)
-       return ref;
-
-      *filesize = 0;
-
-      if (anchor == buffer || !isspace (anchor[-1]))
-       return ref;
-
-      eatspace = 1;
-      *diglast = '\0';
-      for (p = anchor, q = diglast; --p >= buffer; )
-       if (!isspace (*p))
-         {
-           eatspace = 0;
-           if (isdigit (*p))
-             *--q = *p;
-         }
-       else if (!eatspace)
-         break;
-
-      if (q < diglast)
-       *filesize = atoi (q);
-    }
+  if (!ref)
+    return NULL;
+
+  ref += ref[5] == '"' ? 6 : 5;
+
+  len = strcspn (ref, "\" >");
+
+  ref[len] = '\0';
+  if (!filesize)
+    goto out;
 
-  return ref;
+  *filesize = 0;
+
+  if (anchor == buffer || !isspace (anchor[-1]))
+    goto out;
+
+  eatspace = 1;
+  *diglast = '\0';
+  for (p = anchor, q = diglast; --p >= buffer; )
+    if (!isspace (*p))
+      {
+       eatspace = 0;
+       if (isdigit (*p))
+         *--q = *p;
+      }
+    else if (!eatspace)
+      break;
+
+  if (q < diglast)
+    *filesize = atoi (q);
+
+out:
+  if (!*ref)
+    return NULL;
+  /* This effectively disallows using a ';' in a file name.  Hopefully,
+     this will not be an issue. */
+  if ((p = strrchr (ref, ';')) != NULL)
+    *p = '\0';
+  return *ref ? ref : NULL;
 }
 
 static int
@@ -738,8 +745,9 @@ static int
 processdirlisting (const char *urlbase, const char *file)
 {
   int retval = 0;
-  char buffer[256];
+  char buffer[4096];
   static enum {UNKNOWN, ALWAYS, NEVER} download_when = {UNKNOWN};
+  size_t urllen = strlen (urlbase);
 
   FILE *in = fopen (file, "rt");
 
@@ -762,6 +770,8 @@ processdirlisting (const char *urlbase, const char *file)
          warning ("Unable to download from %s", ref);
          winerror ();
        }
+      else if (strlen (url) == urllen || strnicmp (urlbase, url, urllen) != 0)
+       continue;
       else if (ref[strlen (ref) - 1] == '/')
        {
          if (strcmp (url + strlen (url) - 2, "./") != 0)
This page took 0.034676 seconds and 5 git commands to generate.