mirror of
https://github.com/curl/curl.git
synced 2026-08-05 17:26:13 +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
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -73,9 +73,9 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
|||
|
||||
if(!config->trace_stream) {
|
||||
/* open for append */
|
||||
if(curlx_strequal("-", config->trace_dump))
|
||||
if(!strcmp("-", config->trace_dump))
|
||||
config->trace_stream = stdout;
|
||||
else if(curlx_strequal("%", config->trace_dump))
|
||||
else if(!strcmp("%", config->trace_dump))
|
||||
/* Ok, this is somewhat hackish but we do it undocumented for now */
|
||||
config->trace_stream = config->errors; /* aka stderr */
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
}
|
||||
|
||||
for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
|
||||
if(curlx_strnequal(aliases[j].lname, word, fnam)) {
|
||||
if(curlx_strncasecompare(aliases[j].lname, word, fnam)) {
|
||||
longopt = TRUE;
|
||||
numhits++;
|
||||
if(curlx_raw_equal(aliases[j].lname, word)) {
|
||||
|
|
@ -1109,7 +1109,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
break;
|
||||
case 'C':
|
||||
/* This makes us continue an ftp transfer at given position */
|
||||
if(!curlx_strequal(nextarg, "-")) {
|
||||
if(strcmp(nextarg, "-")) {
|
||||
err = str2offset(&config->resume_from, nextarg);
|
||||
if(err)
|
||||
return err;
|
||||
|
|
@ -1153,7 +1153,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
}
|
||||
if('@' == is_file) {
|
||||
/* a '@' letter, it means that a file name or - (stdin) follows */
|
||||
if(curlx_strequal("-", p)) {
|
||||
if(!strcmp("-", p)) {
|
||||
file = stdin;
|
||||
set_binmode(stdin);
|
||||
}
|
||||
|
|
@ -1218,7 +1218,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
or - (stdin) follows */
|
||||
nextarg++; /* pass the @ */
|
||||
|
||||
if(curlx_strequal("-", nextarg)) {
|
||||
if(!strcmp("-", nextarg)) {
|
||||
file = stdin;
|
||||
if(subletter == 'b') /* forced data-binary */
|
||||
set_binmode(stdin);
|
||||
|
|
@ -1377,7 +1377,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
case 'm': /* TLS authentication type */
|
||||
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
|
||||
GetStr(&config->tls_authtype, nextarg);
|
||||
if(!strequal(config->tls_authtype, "SRP"))
|
||||
if(!strcasecompare(config->tls_authtype, "SRP"))
|
||||
return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
|
||||
}
|
||||
else
|
||||
|
|
@ -1770,7 +1770,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
FILE *file;
|
||||
const char *fname;
|
||||
nextarg++; /* pass the @ */
|
||||
if(curlx_strequal("-", nextarg)) {
|
||||
if(!strcmp("-", nextarg)) {
|
||||
fname = "<stdin>";
|
||||
file = stdin;
|
||||
}
|
||||
|
|
@ -1880,7 +1880,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
|
|||
bool passarg;
|
||||
char *flag = argv[i];
|
||||
|
||||
if(curlx_strequal("--", argv[i]))
|
||||
if(!strcmp("--", argv[i]))
|
||||
/* This indicates the end of the flags and thus enables the
|
||||
following (URL) argument to start with -. */
|
||||
stillflags = FALSE;
|
||||
|
|
@ -1936,7 +1936,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
|
|||
result != PARAM_ENGINES_REQUESTED) {
|
||||
const char *reason = param2text(result);
|
||||
|
||||
if(orig_opt && !curlx_strequal(":", orig_opt))
|
||||
if(orig_opt && strcmp(":", orig_opt))
|
||||
helpf(config->errors, "option %s: %s\n", orig_opt, reason);
|
||||
else
|
||||
helpf(config->errors, "%s\n", reason);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -104,11 +104,11 @@ void customrequest_helper(struct OperationConfig *config, HttpReq req,
|
|||
|
||||
if(!method)
|
||||
;
|
||||
else if(curl_strequal(method, dflt[req])) {
|
||||
else if(curlx_strcasecompare(method, dflt[req])) {
|
||||
notef(config->global, "Unnecessary use of -X or --request, %s is already "
|
||||
"inferred.\n", dflt[req]);
|
||||
}
|
||||
else if(curl_strequal(method, "head")) {
|
||||
else if(curlx_strcasecompare(method, "head")) {
|
||||
warnf(config->global,
|
||||
"Setting custom HTTP method to HEAD with -X/--request may not work "
|
||||
"the way you want. Consider using -I/--head instead.\n");
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
/* Single header file for all URLs */
|
||||
if(config->headerfile) {
|
||||
/* open file for output: */
|
||||
if(!curlx_strequal(config->headerfile, "-")) {
|
||||
if(strcmp(config->headerfile, "-")) {
|
||||
FILE *newfile = fopen(config->headerfile, "wb");
|
||||
if(!newfile) {
|
||||
warnf(config->global, "Failed to open %s\n", config->headerfile);
|
||||
|
|
@ -464,7 +464,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
urlnum = 1; /* without globbing, this is a single URL */
|
||||
|
||||
/* if multiple files extracted to stdout, insert separators! */
|
||||
separator= ((!outfiles || curlx_strequal(outfiles, "-")) && urlnum > 1);
|
||||
separator= ((!outfiles || !strcmp(outfiles, "-")) && urlnum > 1);
|
||||
|
||||
/* Here's looping around each globbed URL */
|
||||
for(li = 0 ; li < urlnum; li++) {
|
||||
|
|
@ -534,7 +534,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
}
|
||||
|
||||
if(((urlnode->flags&GETOUT_USEREMOTE) ||
|
||||
(outfile && !curlx_strequal("-", outfile))) &&
|
||||
(outfile && strcmp("-", outfile))) &&
|
||||
(metalink || !config->use_metalink)) {
|
||||
|
||||
/*
|
||||
|
|
@ -715,7 +715,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
DEBUGASSERT(infd == STDIN_FILENO);
|
||||
|
||||
set_binmode(stdin);
|
||||
if(curlx_strequal(uploadfile, ".")) {
|
||||
if(!strcmp(uploadfile, ".")) {
|
||||
if(curlx_nonblock((curl_socket_t)infd, TRUE) < 0)
|
||||
warnf(config->global,
|
||||
"fcntl failed on fd=%d: %s\n", infd, strerror(errno));
|
||||
|
|
@ -1559,7 +1559,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
char *effective_url = NULL;
|
||||
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
|
||||
if(effective_url &&
|
||||
curlx_strnequal(effective_url, "http", 4)) {
|
||||
curlx_strncasecompare(effective_url, "http", 4)) {
|
||||
/* This was HTTP(S) */
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
|
||||
if(response != 200 && response != 206) {
|
||||
|
|
@ -1842,8 +1842,8 @@ CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
|
|||
|
||||
/* Parse .curlrc if necessary */
|
||||
if((argc == 1) ||
|
||||
(!curlx_strequal(argv[1], "-q") &&
|
||||
!curlx_strequal(argv[1], "--disable"))) {
|
||||
(!curlx_strcasecompare(argv[1], "-q") &&
|
||||
!curlx_strcasecompare(argv[1], "--disable"))) {
|
||||
parseconfig(NULL, config); /* ignore possible failure */
|
||||
|
||||
/* If we had no arguments then make sure a url was specified in .curlrc */
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -63,8 +63,8 @@ bool output_expected(const char *url, const char *uploadfile)
|
|||
|
||||
bool stdin_upload(const char *uploadfile)
|
||||
{
|
||||
return (curlx_strequal(uploadfile, "-") ||
|
||||
curlx_strequal(uploadfile, ".")) ? TRUE : FALSE;
|
||||
return (!strcmp(uploadfile, "-") ||
|
||||
!strcmp(uploadfile, ".")) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
|
|||
keepit = *end;
|
||||
*end = 0; /* zero terminate */
|
||||
for(i = 0; replacements[i].name; i++) {
|
||||
if(curl_strequal(ptr, replacements[i].name)) {
|
||||
if(curl_strcasecompare(ptr, replacements[i].name)) {
|
||||
match = TRUE;
|
||||
switch(replacements[i].id) {
|
||||
case VAR_EFFECTIVE_URL:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue