mirror of
https://github.com/curl/curl.git
synced 2026-08-26 06:23:32 +03:00
strcasecompare: is the new name for strequal()
... to make it less likely that we forget that the function actually does case insentive compares. Also replaced several invokes of the function with a plain strcmp when case sensitivity is not an issue (like comparing with "-").
This commit is contained in:
parent
1833a45dde
commit
502acba2af
36 changed files with 98 additions and 111 deletions
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "test.h"
|
||||
#include "strequal.h"
|
||||
#include "strcase.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
static CURLcode send_request(CURL *curl, const char *url, int seq,
|
||||
|
|
@ -72,11 +72,11 @@ static long parse_auth_name(const char *arg)
|
|||
{
|
||||
if(!arg)
|
||||
return CURLAUTH_NONE;
|
||||
if(strequal(arg, "basic"))
|
||||
if(strcasecompare(arg, "basic"))
|
||||
return CURLAUTH_BASIC;
|
||||
if(strequal(arg, "digest"))
|
||||
if(strcasecompare(arg, "digest"))
|
||||
return CURLAUTH_DIGEST;
|
||||
if(strequal(arg, "ntlm"))
|
||||
if(strcasecompare(arg, "ntlm"))
|
||||
return CURLAUTH_NTLM;
|
||||
return CURLAUTH_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd fake_ntlm
|
|||
CURLX_SRCS = \
|
||||
../../lib/mprintf.c \
|
||||
../../lib/nonblock.c \
|
||||
../../lib/strequal.c \
|
||||
../../lib/strcase.c \
|
||||
../../lib/strtoofft.c \
|
||||
../../lib/timeval.c \
|
||||
../../lib/warnless.c
|
||||
|
|
@ -11,7 +11,7 @@ CURLX_SRCS = \
|
|||
CURLX_HDRS = \
|
||||
../../lib/curlx.h \
|
||||
../../lib/nonblock.h \
|
||||
../../lib/strequal.h \
|
||||
../../lib/strcase.h \
|
||||
../../lib/strtoofft.h \
|
||||
../../lib/timeval.h \
|
||||
../../lib/warnless.h
|
||||
|
|
|
|||
|
|
@ -590,7 +590,7 @@ static int ProcessRequest(struct httprequest *req)
|
|||
if(got_exit_signal)
|
||||
return 1; /* done */
|
||||
|
||||
if((req->cl==0) && curlx_strnequal("Content-Length:", line, 15)) {
|
||||
if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
|
||||
/* If we don't ignore content-length, we read it and we read the whole
|
||||
request including the body before we return. If we've been told to
|
||||
ignore the content-length, we will return as soon as all headers
|
||||
|
|
@ -616,8 +616,8 @@ static int ProcessRequest(struct httprequest *req)
|
|||
logmsg("... but will abort after %zu bytes", req->cl);
|
||||
break;
|
||||
}
|
||||
else if(curlx_strnequal("Transfer-Encoding: chunked", line,
|
||||
strlen("Transfer-Encoding: chunked"))) {
|
||||
else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
|
||||
strlen("Transfer-Encoding: chunked"))) {
|
||||
/* chunked data coming in */
|
||||
chunked = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -697,7 +697,7 @@ static int ProcessRequest(struct httprequest *req)
|
|||
if(got_exit_signal)
|
||||
return 1; /* done */
|
||||
|
||||
if((req->cl==0) && curlx_strnequal("Content-Length:", line, 15)) {
|
||||
if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
|
||||
/* If we don't ignore content-length, we read it and we read the whole
|
||||
request including the body before we return. If we've been told to
|
||||
ignore the content-length, we will return as soon as all headers
|
||||
|
|
@ -723,8 +723,8 @@ static int ProcessRequest(struct httprequest *req)
|
|||
logmsg("... but will abort after %zu bytes", req->cl);
|
||||
break;
|
||||
}
|
||||
else if(curlx_strnequal("Transfer-Encoding: chunked", line,
|
||||
strlen("Transfer-Encoding: chunked"))) {
|
||||
else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
|
||||
strlen("Transfer-Encoding: chunked"))) {
|
||||
/* chunked data coming in */
|
||||
chunked = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "strequal.h"
|
||||
#include "strcase.h"
|
||||
|
||||
static CURLcode unit_setup(void) {return CURLE_OK;}
|
||||
static void unit_stop(void) {}
|
||||
|
|
@ -30,25 +30,25 @@ UNITTEST_START
|
|||
|
||||
int rc;
|
||||
|
||||
rc = curl_strequal("iii", "III");
|
||||
rc = curl_strcasecompare("iii", "III");
|
||||
fail_unless(rc != 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iiia", "III");
|
||||
rc = curl_strcasecompare("iiia", "III");
|
||||
fail_unless(rc == 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iii", "IIIa");
|
||||
rc = curl_strcasecompare("iii", "IIIa");
|
||||
fail_unless(rc == 0, "return code should be zero");
|
||||
|
||||
rc = curl_strequal("iiiA", "IIIa");
|
||||
rc = curl_strcasecompare("iiiA", "IIIa");
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("iii", "III", 3);
|
||||
rc = curl_strncasecompare("iii", "III", 3);
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("iiiABC", "IIIcba", 3);
|
||||
rc = curl_strncasecompare("iiiABC", "IIIcba", 3);
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
rc = curl_strnequal("ii", "II", 3);
|
||||
rc = curl_strncasecompare("ii", "II", 3);
|
||||
fail_unless(rc != 0, "return code should be non-zero");
|
||||
|
||||
UNITTEST_STOP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue