code style: use spaces around pluses

This commit is contained in:
Daniel Stenberg 2017-09-09 23:55:08 +02:00
parent ca86006deb
commit e5743f08e7
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
104 changed files with 386 additions and 366 deletions

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
@ -238,37 +238,40 @@ static void dump(const char *timebuf, const char *text,
if(tracetype == TRACE_BIN) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i+c < size)
fprintf(stream, "%02x ", ptr[i+c]);
if(i + c < size)
fprintf(stream, "%02x ", ptr[i + c]);
else
fputs(" ", stream);
}
for(c = 0; (c < width) && (i+c < size); c++) {
for(c = 0; (c < width) && (i + c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
if((tracetype == TRACE_ASCII) &&
(i+c+1 < size) && (ptr[i+c] == 0x0D) && (ptr[i+c+1] == 0x0A)) {
i += (c+2-width);
(i + c + 1 < size) && (ptr[i + c] == 0x0D) &&
(ptr[i + c + 1] == 0x0A)) {
i += (c + 2 - width);
break;
}
#ifdef CURL_DOES_CONVERSIONS
/* repeat the 0D0A check above but use the host encoding for CRLF */
if((tracetype == TRACE_ASCII) &&
(i+c+1 < size) && (ptr[i+c] == '\r') && (ptr[i+c+1] == '\n')) {
i += (c+2-width);
(i + c + 1 < size) && (ptr[i + c] == '\r') &&
(ptr[i + c + 1] == '\n')) {
i += (c + 2 - width);
break;
}
/* convert to host encoding and print this character */
fprintf(stream, "%c", convert_char(infotype, ptr[i+c]));
fprintf(stream, "%c", convert_char(infotype, ptr[i + c]));
#else
(void)infotype;
fprintf(stream, "%c", ((ptr[i+c] >= 0x20) && (ptr[i+c] < 0x80)) ?
ptr[i+c] : UNPRINTABLE_CHAR);
fprintf(stream, "%c", ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80)) ?
ptr[i + c] : UNPRINTABLE_CHAR);
#endif /* CURL_DOES_CONVERSIONS */
/* check again for 0D0A, to avoid an extra \n if it's at width */
if((tracetype == TRACE_ASCII) &&
(i+c+2 < size) && (ptr[i+c+1] == 0x0D) && (ptr[i+c+2] == 0x0A)) {
i += (c+3-width);
(i + c + 2 < size) && (ptr[i + c + 1] == 0x0D) &&
(ptr[i + c + 2] == 0x0A)) {
i += (c + 3 - width);
break;
}
}

View file

@ -146,7 +146,7 @@ static char *parse_filename(const char *ptr, size_t len)
char stop = '\0';
/* simple implementation of strndup() */
copy = malloc(len+1);
copy = malloc(len + 1);
if(!copy)
return NULL;
memcpy(copy, ptr, len);

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2014, 2017, 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
@ -44,7 +44,7 @@ int tool_progress_cb(void *clientp,
/* The original progress-bar source code was written for curl by Lars Aas,
and this new edition inherits some of his concepts. */
char line[MAX_BARLENGTH+1];
char line[MAX_BARLENGTH + 1];
char format[40];
double frac;
double percent;

View file

@ -80,7 +80,7 @@ static char *get_param_word(char **str, char **end_pos)
while(*ptr && NULL == strchr(end_chars, *ptr))
++ptr;
*str = ptr;
return word_begin+1;
return word_begin + 1;
}
++ptr;
}

View file

@ -449,7 +449,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
if(('-' != flag[0]) ||
(('-' == flag[0]) && ('-' == flag[1]))) {
/* this should be a long name */
const char *word = ('-' == flag[0]) ? flag+2 : flag;
const char *word = ('-' == flag[0]) ? flag + 2 : flag;
size_t fnam = strlen(word);
int numhits = 0;
@ -1004,7 +1004,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
#ifdef USE_METALINK
int mlmaj, mlmin, mlpatch;
metalink_get_version(&mlmaj, &mlmin, &mlpatch);
if((mlmaj*10000)+(mlmin*100)+mlpatch < CURL_REQ_LIBMETALINK_VERS) {
if((mlmaj*10000)+(mlmin*100) + mlpatch < CURL_REQ_LIBMETALINK_VERS) {
warnf(global,
"--metalink option cannot be used because the version of "
"the linked libmetalink library is too old. "
@ -1354,11 +1354,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
memcpy(config->postfields, oldpost, (size_t)oldlen);
/* use byte value 0x26 for '&' to accommodate non-ASCII platforms */
config->postfields[oldlen] = '\x26';
memcpy(&config->postfields[oldlen+1], postdata, size);
config->postfields[oldlen+1+size] = '\0';
memcpy(&config->postfields[oldlen + 1], postdata, size);
config->postfields[oldlen + 1 + size] = '\0';
Curl_safefree(oldpost);
Curl_safefree(postdata);
config->postfieldsize += size+1;
config->postfieldsize += size + 1;
}
else {
config->postfields = postdata;

View file

@ -680,7 +680,7 @@ static metalink_checksum *new_metalink_checksum_from_hex_digest
return 0;
for(i = 0; i < len; i += 2) {
digest[i/2] = hex_to_uint(hex_digest+i);
digest[i/2] = hex_to_uint(hex_digest + i);
}
chksum = malloc(sizeof(metalink_checksum));
if(chksum) {
@ -903,8 +903,8 @@ static int check_content_type(const char *content_type, const char *media_type)
return 0;
}
return curl_strnequal(ptr, media_type, media_type_len) &&
(*(ptr+media_type_len) == '\0' || *(ptr+media_type_len) == ' ' ||
*(ptr+media_type_len) == '\t' || *(ptr+media_type_len) == ';');
(*(ptr + media_type_len) == '\0' || *(ptr + media_type_len) == ' ' ||
*(ptr + media_type_len) == '\t' || *(ptr + media_type_len) == ';');
}
int check_metalink_content_type(const char *content_type)

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2015, 2017, 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,7 +63,7 @@ static void voutf(struct GlobalConfig *config,
(void)fwrite(ptr, cut + 1, 1, config->errors);
fputs("\n", config->errors);
ptr += cut+1; /* skip the space too */
ptr += cut + 1; /* skip the space too */
len -= cut;
}
else {

View file

@ -800,7 +800,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
if(urlnum > 1 && !global->mute) {
fprintf(global->errors, "\n[%lu/%lu]: %s --> %s\n",
li+1, urlnum, this_url, outfile ? outfile : "<stdout>");
li + 1, urlnum, this_url, outfile ? outfile : "<stdout>");
if(separator)
printf("%s%s\n", CURLseparator, this_url);
}

View file

@ -73,13 +73,13 @@ ParameterError file2string(char **bufp, FILE *file)
if(ptr)
*ptr = '\0';
buflen = strlen(buffer);
ptr = realloc(string, stringlen+buflen+1);
ptr = realloc(string, stringlen + buflen + 1);
if(!ptr) {
Curl_safefree(string);
return PARAM_NO_MEM;
}
string = ptr;
strcpy(string+stringlen, buffer);
strcpy(string + stringlen, buffer);
stringlen += buflen;
}
}
@ -99,27 +99,27 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
do {
if(!buffer || (alloc == nused)) {
/* size_t overflow detection for huge files */
if(alloc+1 > ((size_t)-1)/2) {
if(alloc + 1 > ((size_t)-1)/2) {
Curl_safefree(buffer);
return PARAM_NO_MEM;
}
alloc *= 2;
/* allocate an extra char, reserved space, for null termination */
newbuf = realloc(buffer, alloc+1);
newbuf = realloc(buffer, alloc + 1);
if(!newbuf) {
Curl_safefree(buffer);
return PARAM_NO_MEM;
}
buffer = newbuf;
}
nread = fread(buffer+nused, 1, alloc-nused, file);
nread = fread(buffer + nused, 1, alloc-nused, file);
nused += nread;
} while(nread);
/* null terminate the buffer in case it's used as a string later */
buffer[nused] = '\0';
/* free trailing slack space, if possible */
if(alloc != nused) {
newbuf = realloc(buffer, nused+1);
newbuf = realloc(buffer, nused + 1);
if(!newbuf) {
Curl_safefree(buffer);
return PARAM_NO_MEM;
@ -474,7 +474,7 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */
/* append the password separated with a colon */
passptr[userlen] = ':';
memcpy(&passptr[userlen+1], passwd, passwdlen+1);
memcpy(&passptr[userlen + 1], passwd, passwdlen + 1);
*userpwd = passptr;
}

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2015, 2017, 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
@ -35,11 +35,11 @@ char *strdup(const char *str)
if(len >= ((size_t)-1) / sizeof(char))
return (char *)NULL;
newstr = malloc((len+1)*sizeof(char));
newstr = malloc((len + 1)*sizeof(char));
if(!newstr)
return (char *)NULL;
memcpy(newstr, str, (len+1)*sizeof(char));
memcpy(newstr, str, (len + 1)*sizeof(char));
return newstr;

View file

@ -49,7 +49,7 @@ static CURLcode glob_fixed(URLGlob *glob, char *fixed, size_t len)
if(!pat->content.Set.elements)
return GLOBERROR("out of memory", 0, CURLE_OUT_OF_MEMORY);
pat->content.Set.elements[0] = malloc(len+1);
pat->content.Set.elements[0] = malloc(len + 1);
if(!pat->content.Set.elements[0])
return GLOBERROR("out of memory", 0, CURLE_OUT_OF_MEMORY);
@ -113,7 +113,7 @@ static CURLcode glob_set(URLGlob *glob, char **patternp,
CURLE_URL_MALFORMAT);
/* add 1 to size since it'll be incremented below */
if(multiply(amount, pat->content.Set.size+1))
if(multiply(amount, pat->content.Set.size + 1))
return GLOBERROR("range overflow", 0, CURLE_URL_MALFORMAT);
/* fall-through */
@ -207,7 +207,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
if(errno || &pattern[4] == endp || *endp != ']')
step = 0;
else
pattern = endp+1;
pattern = endp + 1;
}
else if(end_c != ']')
/* then this is wrong */
@ -264,7 +264,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
if(*endp != '-')
endp = NULL;
else {
pattern = endp+1;
pattern = endp + 1;
while(*pattern && ISBLANK(*pattern))
pattern++;
if(!ISDIGIT(*pattern)) {
@ -277,7 +277,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
/* overflow */
endp = NULL;
else if(*endp == ':') {
pattern = endp+1;
pattern = endp + 1;
errno = 0;
step_n = strtoul(pattern, &endp, 10);
if(errno)
@ -287,7 +287,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
else
step_n = 1;
if(endp && (*endp == ']')) {
pattern = endp+1;
pattern = endp + 1;
}
else
endp = NULL;
@ -384,8 +384,8 @@ static CURLcode glob_parse(URLGlob *glob, char *pattern,
/* only allow \ to escape known "special letters" */
if(*pattern == '\\' &&
(*(pattern+1) == '{' || *(pattern+1) == '[' ||
*(pattern+1) == '}' || *(pattern+1) == ']') ) {
(*(pattern + 1) == '{' || *(pattern + 1) == '[' ||
*(pattern + 1) == '}' || *(pattern + 1) == ']') ) {
/* escape character, skip '\' */
++pattern;