From: Daniel Stenberg Date: Tue, 20 Jan 2026 11:07:15 +0000 (+0100) Subject: lib: use ISBLANK and ISNEWLINE more X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c957ad1fea2895728e960b640254c9efb536f93;p=thirdparty%2Fcurl.git lib: use ISBLANK and ISNEWLINE more Closes #20373 --- diff --git a/lib/imap.c b/lib/imap.c index dc519e8264..293a34daa6 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -437,13 +437,12 @@ static CURLcode imap_get_message(struct Curl_easy *data, struct bufref *out) if(len > 2) { /* Find the start of the message */ len -= 2; - for(message += 2; *message == ' ' || *message == '\t'; message++, len--) + for(message += 2; ISBLANK(*message); message++, len--) ; /* Find the end of the message */ while(len--) - if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' && - message[len] != '\t') + if(!ISNEWLINE(message[len]) && !ISBLANK(message[len])) break; /* Terminate the message */ @@ -1035,20 +1034,15 @@ static CURLcode imap_state_capability_resp(struct Curl_easy *data, /* Loop through the data line */ for(;;) { size_t wordlen; - while(*line && - (*line == ' ' || *line == '\t' || - *line == '\r' || *line == '\n')) { - + while(*line && (ISBLANK(*line) || ISNEWLINE(*line))) line++; - } if(!*line) break; /* Extract the word */ - for(wordlen = 0; line[wordlen] && line[wordlen] != ' ' && - line[wordlen] != '\t' && line[wordlen] != '\r' && - line[wordlen] != '\n';) + for(wordlen = 0; line[wordlen] && !ISBLANK(line[wordlen]) && + !ISNEWLINE(line[wordlen]);) wordlen++; /* Does the server support the STARTTLS capability? */ diff --git a/lib/pop3.c b/lib/pop3.c index 089af4890e..7b2c134446 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -358,13 +358,12 @@ static CURLcode pop3_get_message(struct Curl_easy *data, struct bufref *out) if(len > 2) { /* Find the start of the message */ len -= 2; - for(message += 2; *message == ' ' || *message == '\t'; message++, len--) + for(message += 2; ISBLANK(*message); message++, len--) ; /* Find the end of the message */ while(len--) - if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' && - message[len] != '\t') + if(!ISBLANK(message[len]) && !ISNEWLINE(message[len])) break; /* Terminate the message */ diff --git a/lib/smtp.c b/lib/smtp.c index 2427fd932d..112773b886 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -547,13 +547,12 @@ static CURLcode smtp_get_message(struct Curl_easy *data, struct bufref *out) if(len > 4) { /* Find the start of the message */ len -= 4; - for(message += 4; *message == ' ' || *message == '\t'; message++, len--) + for(message += 4; ISBLANK(*message); message++, len--) ; /* Find the end of the message */ while(len--) - if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' && - message[len] != '\t') + if(!ISNEWLINE(message[len]) && !ISBLANK(message[len])) break; /* Terminate the message */ @@ -1234,10 +1233,7 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data, size_t wordlen; unsigned short mechbit; - while(len && - (*line == ' ' || *line == '\t' || - *line == '\r' || *line == '\n')) { - + while(len && (ISBLANK(*line) || ISNEWLINE(*line))) { line++; len--; } @@ -1246,9 +1242,8 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data, break; /* Extract the word */ - for(wordlen = 0; wordlen < len && line[wordlen] != ' ' && - line[wordlen] != '\t' && line[wordlen] != '\r' && - line[wordlen] != '\n';) + for(wordlen = 0; wordlen < len && !ISBLANK(line[wordlen]) && + !ISNEWLINE(line[wordlen]);) wordlen++; /* Test the word for a matching authentication mechanism */