]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
src: cleanup ISBLANK vs ISSPACE
authorDaniel Stenberg <daniel@haxx.se>
Thu, 6 Mar 2025 10:01:55 +0000 (11:01 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 7 Mar 2025 07:58:46 +0000 (08:58 +0100)
- use ISBLANK() where only spaces and tabs should match
- change while(x && ISBLANK(X)) => while(ISBLANK(x))

Closes #16589

src/tool_formparse.c
src/tool_getparam.c
src/tool_parsecfg.c
src/tool_urlglob.c
src/var.c

index e2ca982718cf5bcee5ffb16462dd4619c00370f4..5e680cc52be3bb673b9de36eeb7c5a1dbfa0d8c9 100644 (file)
@@ -509,23 +509,23 @@ static int get_param_part(struct OperationConfig *config, char endchar,
     *pheaders = NULL;
   if(pencoder)
     *pencoder = NULL;
-  while(ISSPACE(*p))
+  while(ISBLANK(*p))
     p++;
   tp = p;
   *pdata = get_param_word(config, &p, &endpos, endchar);
   /* If not quoted, strip trailing spaces. */
   if(*pdata == tp)
-    while(endpos > *pdata && ISSPACE(endpos[-1]))
+    while(endpos > *pdata && ISBLANK(endpos[-1]))
       endpos--;
   sep = *p;
   *endpos = '\0';
   while(sep == ';') {
-    while(p++ && ISSPACE(*p))
+    while(p++ && ISBLANK(*p))
       ;
 
     if(!endct && checkprefix("type=", p)) {
       size_t tlen;
-      for(p += 5; ISSPACE(*p); p++)
+      for(p += 5; ISBLANK(*p); p++)
         ;
       /* set type pointer */
       type = p;
@@ -541,13 +541,13 @@ static int get_param_part(struct OperationConfig *config, char endchar,
         *endct = '\0';
         endct = NULL;
       }
-      for(p += 9; ISSPACE(*p); p++)
+      for(p += 9; ISBLANK(*p); p++)
         ;
       tp = p;
       filename = get_param_word(config, &p, &endpos, endchar);
       /* If not quoted, strip trailing spaces. */
       if(filename == tp)
-        while(endpos > filename && ISSPACE(endpos[-1]))
+        while(endpos > filename && ISBLANK(endpos[-1]))
           endpos--;
       sep = *p;
       *endpos = '\0';
@@ -562,15 +562,14 @@ static int get_param_part(struct OperationConfig *config, char endchar,
         char *hdrfile;
         FILE *fp;
         /* Read headers from a file. */
-
         do {
           p++;
-        } while(ISSPACE(*p));
+        } while(ISBLANK(*p));
         tp = p;
         hdrfile = get_param_word(config, &p, &endpos, endchar);
         /* If not quoted, strip trailing spaces. */
         if(hdrfile == tp)
-          while(endpos > hdrfile && ISSPACE(endpos[-1]))
+          while(endpos > hdrfile && ISBLANK(endpos[-1]))
             endpos--;
         sep = *p;
         *endpos = '\0';
@@ -591,13 +590,13 @@ static int get_param_part(struct OperationConfig *config, char endchar,
       else {
         char *hdr;
 
-        while(ISSPACE(*p))
+        while(ISBLANK(*p))
           p++;
         tp = p;
         hdr = get_param_word(config, &p, &endpos, endchar);
         /* If not quoted, strip trailing spaces. */
         if(hdr == tp)
-          while(endpos > hdr && ISSPACE(endpos[-1]))
+          while(endpos > hdr && ISBLANK(endpos[-1]))
             endpos--;
         sep = *p;
         *endpos = '\0';
@@ -613,7 +612,7 @@ static int get_param_part(struct OperationConfig *config, char endchar,
         *endct = '\0';
         endct = NULL;
       }
-      for(p += 8; ISSPACE(*p); p++)
+      for(p += 8; ISBLANK(*p); p++)
         ;
       tp = p;
       encoder = get_param_word(config, &p, &endpos, endchar);
@@ -627,7 +626,7 @@ static int get_param_part(struct OperationConfig *config, char endchar,
     else if(endct) {
       /* This is part of content type. */
       for(endct = p; *p && *p != ';' && *p != endchar; p++)
-        if(!ISSPACE(*p))
+        if(!ISBLANK(*p))
           endct = p + 1;
       sep = *p;
     }
index eeeb90346e43754ee2a53c43af6922852f445b37..e42f263861c27389db9df7cd226db505600be2f7 100644 (file)
@@ -1114,11 +1114,9 @@ static ParameterError parse_url(struct GlobalConfig *global,
       curlx_dyn_init(&line, 8092);
       while(my_get_line(f, &line, &error)) {
         const char *ptr = curlx_dyn_ptr(&line);
-
         err = add_url(global, config, ptr, GETOUT_USEREMOTE | GETOUT_NOGLOB);
         if(err)
           break;
-        curlx_dyn_reset(&line);
       }
       if(!fromstdin)
         fclose(f);
@@ -1146,12 +1144,12 @@ static ParameterError parse_localport(struct OperationConfig *config,
   if(*p) {
     pp = p;
     /* check for ' - [end]' */
-    if(ISSPACE(*pp))
+    if(ISBLANK(*pp))
       pp++;
     if(*pp != '-')
       return PARAM_BAD_USE;
     pp++;
-    if(*pp && ISSPACE(*pp))
+    if(ISBLANK(*pp))
       pp++;
   }
   msnprintf(buffer, sizeof(buffer), "%.*s", (int)plen, nextarg);
index 84c83d8e9637dd7ee22019e89c474a3152a77c4a..a462b4322cc793a911270691a0428fdc36c7af9d 100644 (file)
@@ -111,7 +111,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
       /* the option starts with a dash? */
       dashed_option = (option[0] == '-');
 
-      while(*line && !ISSPACE(*line) && !ISSEP(*line, dashed_option))
+      while(*line && !ISBLANK(*line) && !ISSEP(*line, dashed_option))
         line++;
       /* ... and has ended here */
 
@@ -123,7 +123,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
 #endif
 
       /* pass spaces and separator(s) */
-      while(*line && (ISSPACE(*line) || ISSEP(*line, dashed_option)))
+      while(ISBLANK(*line) || ISSEP(*line, dashed_option))
         line++;
 
       /* the parameter starts here (unless quoted) */
@@ -141,7 +141,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
       }
       else {
         param = line; /* parameter starts here */
-        while(*line && !ISSPACE(*line))
+        while(*line && !ISSPACE(*line)) /* stop also on CRLF */
           line++;
 
         if(*line) {
@@ -150,7 +150,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
           /* to detect mistakes better, see if there is data following */
           line++;
           /* pass all spaces */
-          while(*line && ISSPACE(*line))
+          while(ISBLANK(*line))
             line++;
 
           switch(*line) {
index 8370058661a31198663274470b6a28e454270543..a296e3535baf1b19fa7b536802d9e974f0ab4673 100644 (file)
@@ -278,7 +278,7 @@ static CURLcode glob_range(struct URLGlob *glob, char **patternp,
         endp = NULL;
       else {
         pattern = endp + 1;
-        while(*pattern && ISBLANK(*pattern))
+        while(ISBLANK(*pattern))
           pattern++;
         if(!ISDIGIT(*pattern)) {
           endp = NULL;
index 5ac75068911d5a6239e5f909af76a87270cc185e..1eab942b66e8c6cd24292a0479e51903c1b27dee 100644 (file)
--- a/src/var.c
+++ b/src/var.c
@@ -119,7 +119,7 @@ static ParameterError varfunc(struct GlobalConfig *global,
       f += FUNC_TRIM_LEN;
       if(clen) {
         /* skip leading white space, including CRLF */
-        while(*c && ISSPACE(*c)) {
+        while(ISSPACE(*c)) {
           c++;
           len--;
         }