]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: simplify more white space loops
authorDaniel Stenberg <daniel@haxx.se>
Mon, 17 Feb 2025 10:24:49 +0000 (11:24 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 17 Feb 2025 12:17:18 +0000 (13:17 +0100)
Since the ISBLANK() and ISSPACE() macros check for specific matches,
there is no point in using while(*ptr && ISSPACE(*ptr)) etc, as the
'*ptr' check is then superfluous.

Closes #16363

12 files changed:
lib/altsvc.c
lib/headers.c
lib/hsts.c
lib/http.c
lib/http_aws_sigv4.c
lib/http_digest.c
lib/http_negotiate.c
lib/http_ntlm.c
lib/http_proxy.c
lib/noproxy.c
lib/rtsp.c
lib/strtoofft.c

index c7449ab1068b99e437beb5230ce0cf7b4be9e55c..c3aaf1dad6d8367494162ca920b8ca5f513bb8d8 100644 (file)
@@ -232,7 +232,7 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
     Curl_dyn_init(&buf, MAX_ALTSVC_LINE);
     while(Curl_get_line(&buf, fp)) {
       char *lineptr = Curl_dyn_ptr(&buf);
-      while(*lineptr && ISBLANK(*lineptr))
+      while(ISBLANK(*lineptr))
         lineptr++;
       if(*lineptr == '#')
         /* skip commented lines */
@@ -410,7 +410,7 @@ static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen)
   size_t len;
   const char *protop;
   const char *p = *ptr;
-  while(*p && ISBLANK(*p))
+  while(ISBLANK(*p))
     p++;
   protop = p;
   while(*p && !ISBLANK(*p) && (*p != ';') && (*p != '='))
@@ -593,12 +593,12 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
             /* skip option if name is too long */
             option[0] = '\0';
           }
-          while(*p && ISBLANK(*p))
+          while(ISBLANK(*p))
             p++;
           if(*p != '=')
             return CURLE_OK;
           p++;
-          while(*p && ISBLANK(*p))
+          while(ISBLANK(*p))
             p++;
           if(!*p)
             return CURLE_OK;
index 2985e1e18549368ddf56732036c1b8be89690297..411515dfe1fb5041accf8718ab246edcbcf851ca 100644 (file)
@@ -209,7 +209,7 @@ static CURLcode namevalue(char *header, size_t hlen, unsigned int type,
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
   /* skip all leading space letters */
-  while(*header && ISBLANK(*header))
+  while(ISBLANK(*header))
     header++;
 
   *value = header;
index 1c729d94cbd5d9599b9f160ffb8828afbbf2109d..7fb36525983410b49e618056ce317db35ec41727 100644 (file)
@@ -154,7 +154,7 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
     return CURLE_OK;
 
   do {
-    while(*p && ISBLANK(*p))
+    while(ISBLANK(*p))
       p++;
     if(strncasecompare("max-age", p, 7)) {
       bool quoted = FALSE;
@@ -164,11 +164,11 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
         return CURLE_BAD_FUNCTION_ARGUMENT;
 
       p += 7;
-      while(*p && ISBLANK(*p))
+      while(ISBLANK(*p))
         p++;
       if(*p++ != '=')
         return CURLE_BAD_FUNCTION_ARGUMENT;
-      while(*p && ISBLANK(*p))
+      while(ISBLANK(*p))
         p++;
 
       if(*p == '\"') {
@@ -202,7 +202,7 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
         p++;
     }
 
-    while(*p && ISBLANK(*p))
+    while(ISBLANK(*p))
       p++;
     if(*p == ';')
       p++;
@@ -534,7 +534,7 @@ static CURLcode hsts_load(struct hsts *h, const char *file)
     Curl_dyn_init(&buf, MAX_HSTS_LINE);
     while(Curl_get_line(&buf, fp)) {
       char *lineptr = Curl_dyn_ptr(&buf);
-      while(*lineptr && ISBLANK(*lineptr))
+      while(ISBLANK(*lineptr))
         lineptr++;
       /*
        * Skip empty or commented lines, since we know the line will have a
index 8010b4d92d05cfcefe1ab75cd14ca8abdf8a1c73..f82e030a1b22ecb7099cae7eb5587d35bc43944e 100644 (file)
@@ -257,7 +257,7 @@ char *Curl_copy_header_value(const char *header)
 
   /* Find the first non-space letter */
   start = header;
-  while(*start && ISSPACE(*start))
+  while(ISSPACE(*start))
     start++;
 
   end = strchr(start, '\r');
@@ -1016,7 +1016,7 @@ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy,
       auth++;
     if(*auth == ',') /* if we are on a comma, skip it */
       auth++;
-    while(*auth && ISSPACE(*auth))
+    while(ISSPACE(*auth))
       auth++;
   }
 
@@ -1404,7 +1404,7 @@ Curl_compareheader(const char *headerline, /* line to check */
   start = &headerline[hlen];
 
   /* pass all whitespace */
-  while(*start && ISSPACE(*start))
+  while(ISSPACE(*start))
     start++;
 
   /* find the end of the header line */
@@ -1597,7 +1597,7 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data,
         if(ptr) {
           optr = ptr;
           ptr++; /* pass the semicolon */
-          while(*ptr && ISSPACE(*ptr))
+          while(ISSPACE(*ptr))
             ptr++;
 
           if(*ptr) {
@@ -1625,7 +1625,7 @@ CURLcode Curl_add_custom_headers(struct Curl_easy *data,
         /* we require a colon for this to be a true header */
 
         ptr++; /* pass the colon */
-        while(*ptr && ISSPACE(*ptr))
+        while(ISSPACE(*ptr))
           ptr++;
 
         if(*ptr || semicolonp) {
@@ -3847,7 +3847,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data,
        */
       const char *p = hd;
 
-      while(*p && ISBLANK(*p))
+      while(ISBLANK(*p))
         p++;
       if(!strncmp(p, "HTTP/", 5)) {
         p += 5;
@@ -3907,7 +3907,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data,
     }
     else if(data->conn->handler->protocol & CURLPROTO_RTSP) {
       const char *p = hd;
-      while(*p && ISBLANK(*p))
+      while(ISBLANK(*p))
         p++;
       if(!strncmp(p, "RTSP/", 5)) {
         p += 5;
@@ -4448,7 +4448,7 @@ CURLcode Curl_http_req_to_h2(struct dynhds *h2_headers,
     scheme = Curl_checkheaders(data, STRCONST(HTTP_PSEUDO_SCHEME));
     if(scheme) {
       scheme += sizeof(HTTP_PSEUDO_SCHEME);
-      while(*scheme && ISBLANK(*scheme))
+      while(ISBLANK(*scheme))
         scheme++;
       infof(data, "set pseudo header %s to %s", HTTP_PSEUDO_SCHEME, scheme);
     }
index 2fbb8de13ae236f6ab520c5ca551204522320ce2..e572cc4f5b6508c151b59d0d1fe80710391c7e70 100644 (file)
@@ -95,12 +95,12 @@ static void trim_headers(struct curl_slist *head)
     store = value;
 
     /* skip leading whitespace */
-    while(*value && ISBLANK(*value))
+    while(ISBLANK(*value))
       value++;
 
     while(*value) {
       int space = 0;
-      while(*value && ISBLANK(*value)) {
+      while(ISBLANK(*value)) {
         value++;
         space++;
       }
@@ -356,7 +356,7 @@ static char *parse_content_sha_hdr(struct Curl_easy *data,
     return NULL;
   ++value;
 
-  while(*value && ISBLANK(*value))
+  while(ISBLANK(*value))
     ++value;
 
   len = strlen(value);
index a3ba17a51fa1b221128ba5c203f7c80436f4deee..3c81640f20d5d55318c3dcc3a0d6fa3a3b1d069c 100644 (file)
@@ -62,7 +62,7 @@ CURLcode Curl_input_digest(struct Curl_easy *data,
     return CURLE_BAD_CONTENT_ENCODING;
 
   header += strlen("Digest");
-  while(*header && ISBLANK(*header))
+  while(ISBLANK(*header))
     header++;
 
   return Curl_auth_decode_digest_http_message(header, digest);
index f031d0abc86fbe95181d1304857491f77a101a87..b686b8ebc6091f71e8d169a97092ae3db3791216 100644 (file)
@@ -86,7 +86,7 @@ CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn,
 
   /* Obtain the input token, if any */
   header += strlen("Negotiate");
-  while(*header && ISBLANK(*header))
+  while(ISBLANK(*header))
     header++;
 
   len = strlen(header);
index 771f81da4c965f8280852143357d6a2c155127d8..2eee92742a8a3e9618f60be50212b77036e40247 100644 (file)
@@ -70,7 +70,7 @@ CURLcode Curl_input_ntlm(struct Curl_easy *data,
   if(checkprefix("NTLM", header)) {
     header += strlen("NTLM");
 
-    while(*header && ISSPACE(*header))
+    while(ISSPACE(*header))
       header++;
 
     if(*header) {
index 3a2e9f2b05f484180d8fed52731bd4d8a256a555..8a9effd49fe9ce2cefe2283e4ac7a8d810c29645 100644 (file)
@@ -108,7 +108,7 @@ static CURLcode dynhds_add_custom(struct Curl_easy *data,
         name = headers->data;
         namelen = ptr - headers->data;
         ptr++; /* pass the colon */
-        while(*ptr && ISSPACE(*ptr))
+        while(ISSPACE(*ptr))
           ptr++;
         if(*ptr) {
           value = ptr;
@@ -131,7 +131,7 @@ static CURLcode dynhds_add_custom(struct Curl_easy *data,
         name = headers->data;
         namelen = ptr - headers->data;
         ptr++; /* pass the semicolon */
-        while(*ptr && ISSPACE(*ptr))
+        while(ISSPACE(*ptr))
           ptr++;
         if(!*ptr) {
           /* quirk #2, send an empty header */
index 78cc06fa019f6c0f6c51690d173397d66ffbb677..23dd46ba747d85a0c882aa47d2c9afe0fd5d03ca 100644 (file)
@@ -177,7 +177,7 @@ bool Curl_check_noproxy(const char *name, const char *no_proxy)
       bool match = FALSE;
 
       /* pass blanks */
-      while(*p && ISBLANK(*p))
+      while(ISBLANK(*p))
         p++;
 
       token = p;
index 652734ee2d2f4282c7cf86076dbfecd6a8edc03f..7ff7274cb9cf9bb6a00de96b9ac1204f3f566f9b 100644 (file)
@@ -944,7 +944,7 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, const char *header)
 
     /* Find the first non-space letter */
     start = header + 8;
-    while(*start && ISBLANK(*start))
+    while(ISBLANK(*start))
       start++;
 
     if(!*start) {
@@ -1003,7 +1003,7 @@ CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport)
   const char *start, *end;
   start = transport;
   while(start && *start) {
-    while(*start && ISBLANK(*start) )
+    while(ISBLANK(*start) )
       start++;
     end = strchr(start, ';');
     if(checkprefix("interleaved=", start)) {
index 5a7f058f96625af18a0195ee689dcde031a4df84..f347e2b6fe8f760ccb9d7180c59d55071123ae52 100644 (file)
@@ -39,7 +39,7 @@ CURLofft curlx_strtoofft(const char *str, char **endp, int base,
   *num = 0; /* clear by default */
   DEBUGASSERT((base == 10) || (base == 16));
 
-  while(*str && ISBLANK(*str))
+  while(ISBLANK(*str))
     str++;
 
   rc = base == 10 ?