]> sjero.net Git - wget/blobdiff - src/init.c
vms: support --backups
[wget] / src / init.c
index 0c41825524966abb21e447f9e39e442f15e60a9b..1c4432b56b79ab350b9f09413a6e979fe3bd6c69 100644 (file)
@@ -574,7 +574,8 @@ bool
 run_wgetrc (const char *file)
 {
   FILE *fp;
-  char *line;
+  char *line = NULL;
+  size_t bufsize = 0;
   int ln;
   int errcnt = 0;
 
@@ -586,7 +587,7 @@ run_wgetrc (const char *file)
       return true;                      /* not a fatal error */
     }
   ln = 1;
-  while ((line = read_whole_line (fp)) != NULL)
+  while (getline (&line, &bufsize, fp) > 0)
     {
       char *com = NULL, *val = NULL;
       int comind;
@@ -620,9 +621,9 @@ run_wgetrc (const char *file)
         }
       xfree_null (com);
       xfree_null (val);
-      xfree (line);
       ++ln;
     }
+  xfree (line);
   fclose (fp);
 
   return errcnt == 0;
@@ -964,15 +965,16 @@ cmd_string (const char *com, const char *val, void *place)
 static bool
 cmd_string_uppercase (const char *com, const char *val, void *place)
 {
-  char *q;
-  bool ret = cmd_string (com, val, place);
-  q = *((char **) place);
-  if (!ret || q == NULL)
-    return false;
+  char *q, **pstring;
+  pstring = (char **)place;
+  xfree_null (*pstring);
+
+  *pstring = xmalloc (strlen (val) + 1);
 
-  for ( ;*q; *q++)
-    *q = c_toupper (*q);
+  for (q = *pstring; *val; val++, q++)
+    *q = c_toupper (*val);
 
+  *q = '\0';
   return true;
 }