Commit b228d295 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

checksrc: stricter no-space-before-paren enforcement

In order to make the code style more uniform everywhere
parent 5fad800e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1910,7 +1910,10 @@ typedef enum {


/* curl_strequal() and curl_strnequal() are subject for removal in a future
   libcurl, see lib/README.curlx for details */
   libcurl, see lib/README.curlx for details

   !checksrc! disable SPACEBEFOREPAREN 2
*/
CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2);
CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n);

+3 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2010, 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
+18 −2
Original line number Diff line number Diff line
@@ -243,6 +243,12 @@ sub checksrc {
    }
}

sub nostrings {
    my ($str) = @_;
    $str =~ s/\".*\"//g;
    return $str;
}

sub scanfile {
    my ($file) = @_;

@@ -329,11 +335,21 @@ sub scanfile {
                      $line, length($1), $file, $l, "\/\/ comment");
        }

        # check spaces after for/if/while
        if($l =~ /^(.*)(for|if|while) \(/) {
        my $nostr = nostrings($l);
        # check spaces after for/if/while/function call
        if($nostr =~ /^(.*)(for|if|while| ([a-zA-Z0-9_]+)) \((.)/) {
            if($1 =~ / *\#/) {
                # this is a #if, treat it differently
            }
            elsif($3 eq "return") {
                # return must have a space
            }
            elsif($4 eq "*") {
                # (* beginning makes the space OK!
            }
            elsif($1 =~ / *typedef/) {
                # typedefs can use space-paren
            }
            else {
                checkwarn("SPACEBEFOREPAREN", $line, length($1)+length($2), $file, $l,
                          "$2 with space");
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ int Curl_thread_join(curl_thread_t *hnd)

#elif defined(USE_THREADS_WIN32)

/* !checksrc! disable SPACEBEFOREPAREN 1 */
curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void *),
                                 void *arg)
{
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@

#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)

/* !checksrc! disable SPACEBEFOREPAREN 1 */
curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void *),
                                 void *arg);

Loading