Skip to content

Commit

Permalink
checksrc: force indentation of lines after an else
Browse files Browse the repository at this point in the history
This extends the INDENTATION case to also handle 'else' statements
and require proper indentation on the following line. Also fixes the
offending cases found in the codebase.
  • Loading branch information
danielgustafsson committed Apr 25, 2018
1 parent 84358e4 commit 377e334
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/checksrc.pl
Expand Up @@ -499,9 +499,9 @@ sub scanfile {
}

# if the previous line starts with if/while/for AND ends with an open
# brace, check that this line is indented $indent more steps, if not
# a cpp line
if($prevl =~ /^( *)(if|while|for)\(.*\{\z/) {
# brace, or an else statement, check that this line is indented $indent
# more steps, if not a cpp line
if($prevl =~ /^( *)((if|while|for)\(.*\{|else)\z/) {
my $first = length($1);

# this line has some character besides spaces
Expand Down
3 changes: 1 addition & 2 deletions lib/multi.c
Expand Up @@ -1798,8 +1798,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if((data->easy_conn->sockfd != CURL_SOCKET_BAD) ||
(data->easy_conn->writesockfd != CURL_SOCKET_BAD))
multistate(data, CURLM_STATE_WAITPERFORM);
else
{
else {
if(data->state.wildcardmatch &&
((data->easy_conn->handler->flags & PROTOPT_WILDCARD) == 0)) {
data->wildcard.state = CURLWC_DONE;
Expand Down
3 changes: 1 addition & 2 deletions lib/rtsp.c
Expand Up @@ -764,8 +764,7 @@ CURLcode rtp_client_write(struct connectdata *conn, char *ptr, size_t len)
writeit = data->set.fwrite_rtp;
user_ptr = data->set.rtp_out;
}
else
{
else {
writeit = data->set.fwrite_func;
user_ptr = data->set.out;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/telnet.c
Expand Up @@ -1203,8 +1203,7 @@ CURLcode telrcv(struct connectdata *conn,
CURL_SB_ACCUM(tn, c);
tn->telrcv_state = CURL_TS_SB;
}
else
{
else {
CURL_SB_ACCUM(tn, CURL_IAC);
CURL_SB_ACCUM(tn, CURL_SE);
tn->subpointer -= 2;
Expand Down
3 changes: 1 addition & 2 deletions lib/vtls/schannel.c
Expand Up @@ -544,8 +544,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
InitSecBuffer(&inbuf, SECBUFFER_APPLICATION_PROTOCOLS, alpn_buffer, cur);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
}
else
{
else {
InitSecBuffer(&inbuf, SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
}
Expand Down
6 changes: 2 additions & 4 deletions src/tool_operate.c
Expand Up @@ -456,8 +456,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
the number of resources as urlnum. */
urlnum = count_next_metalink_resource(mlfile);
}
else
if(!config->globoff) {
else if(!config->globoff) {
/* Unless explicitly shut off, we expand '{...}' and '[...]'
expressions and return total number of URLs in pattern set */
result = glob_url(&urls, urlnode->url, &urlnum,
Expand Down Expand Up @@ -1858,8 +1857,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
*/
break;
}
else
if(urlnum > 1) {
else if(urlnum > 1) {
/* when url globbing, exit loop upon critical error */
if(is_fatal_error(result))
break;
Expand Down

0 comments on commit 377e334

Please sign in to comment.