checksrc: whitespace and code style cleanup
authorDaniel Stenberg <daniel@haxx.se>
Mon, 25 Apr 2011 20:44:39 +0000 (22:44 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 27 Apr 2011 07:09:35 +0000 (09:09 +0200)
Make everything adhere to the standards upheld by checksrc.pl and now
run checksrc from the makefile on debug builds.

src/Makefile.am
src/config-riscos.h
src/config-win32.h
src/getpass.c
src/homedir.c
src/main.c
src/setup.h
src/urlglob.c
src/writeenv.c
src/writeout.c
src/xattr.c

index 8b3c0b6..c1915f7 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2011, 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
@@ -95,3 +95,11 @@ $(HUGE):
        echo '#include "hugehelp.h"' >> $(HUGE)
        echo "void hugehelp(void) {}" >>$(HUGE)
 endif
+
+if CURLDEBUG
+# for debug builds, we scan the sources on all regular make invokes
+# ignore hugehelp.c since it is generated source code and it plays by slightly
+# different rules!
+all-local:
+       @@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/src -Whugehelp.c $(curl_SOURCES)
+endif
index 1000b53..7816bab 100644 (file)
@@ -1,4 +1,3 @@
-/* curl_config.h.in.  Generated automatically from configure.in by autoheader.  */
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
index a2c7f51..38a3298 100644 (file)
    2000 as a supported build target. VS2008 default installations provide an
    embedded Windows SDK v6.0A along with the claim that Windows 2000 is a
    valid build target for VS2008. Popular belief is that binaries built using
-   Windows SDK versions 6.X and Windows 2000 as a build target are functional */
+   Windows SDK versions 6.X and Windows 2000 as a build target are
+   functional */
 #if defined(_MSC_VER) && (_MSC_VER >= 1500)
 #  define VS2008_MINIMUM_TARGET 0x0500
 #endif
 #  ifndef WINVER
 #    define WINVER VS2008_DEFAULT_TARGET
 #  endif
-#  if (_WIN32_WINNT < VS2008_MINIMUM_TARGET) || (WINVER < VS2008_MINIMUM_TARGET)
+#  if (_WIN32_WINNT < VS2008_MINIMUM_TARGET) || \
+  (WINVER < VS2008_MINIMUM_TARGET)
 #    error VS2008 does not support Windows build targets prior to Windows 2000
 #  endif
 #endif
index b441a5a..95d257b 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -78,7 +78,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
 
   buffer[0]='\0';
   sts = sys$assign(&ttdesc, &chan,0,0);
-  if (sts & 1) {
+  if(sts & 1) {
     sts = sys$qiow(0, chan,
                    IO$_READPROMPT | IO$M_NOECHO,
                    &iosb, 0, 0, buffer, buflen, 0, 0,
@@ -113,12 +113,12 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
 
   for(i=0; i<buflen; i++) {
     buffer[i] = (char)getch();
-    if ( buffer[i] == '\r' || buffer[i] == '\n' ) {
+    if(buffer[i] == '\r' || buffer[i] == '\n') {
       buffer[i] = 0;
       break;
     }
     else
-      if ( buffer[i] == '\b')
+      if(buffer[i] == '\b')
         /* remove this letter and if this is not the first key, remove the
            previous one as well */
         i = i - (i>=1?2:1);
@@ -128,7 +128,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
   fputs("\n", stderr);
 #endif
   /* if user didn't hit ENTER, terminate buffer */
-  if (i==buflen)
+  if(i==buflen)
     buffer[buflen-1]=0;
 
   return buffer; /* we always return success */
@@ -153,20 +153,22 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
   printf("%s", prompt);
   do {
     buffer[i++] = getch();
-    if (buffer[i-1] == '\b') {
+    if(buffer[i-1] == '\b') {
       /* remove this letter and if this is not the first key,
          remove the previous one as well */
-      if (i > 1) {
+      if(i > 1) {
         printf("\b \b");
         i = i - 2;
-      } else {
+      }
+      else {
         RingTheBell();
         i = i - 1;
       }
-    } else if (buffer[i-1] != 13) {
-      putchar('*');
     }
-  } while ((buffer[i-1] != 13) && (i < buflen));
+    else if(buffer[i-1] != 13)
+      putchar('*');
+
+  } while((buffer[i-1] != 13) && (i < buflen));
   buffer[i-1] = 0;
   printf("\r\n");
   return buffer;
@@ -194,8 +196,8 @@ static bool ttyecho(bool enable, int fd)
   static struct_term noecho;
 #endif
   if(!enable) {
-  /* disable echo by extracting the current 'withecho' mode and remove the
-     ECHO bit and set back the struct */
+    /* disable echo by extracting the current 'withecho' mode and remove the
+       ECHO bit and set back the struct */
 #ifdef HAVE_TERMIOS_H
     tcgetattr(fd, &withecho);
     noecho = withecho;
index ab1d369..52f69c7 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -54,23 +54,23 @@ char *GetEnv(const char *variable, char do_expand)
    * started. Don't accept truncated results (i.e. rc >= sizeof(buf1)).  */
 
   rc = GetEnvironmentVariable(variable, buf1, sizeof(buf1));
-  if (rc > 0 && rc < sizeof(buf1)) {
+  if(rc > 0 && rc < sizeof(buf1)) {
     env = buf1;
     variable = buf1;
   }
-  if (do_expand && strchr(variable,'%')) {
+  if(do_expand && strchr(variable,'%')) {
     /* buf2 == variable if not expanded */
     rc = ExpandEnvironmentStrings (variable, buf2, sizeof(buf2));
-    if (rc > 0 && rc < sizeof(buf2) &&
-        !strchr(buf2,'%'))    /* no vars still unexpanded */
+    if(rc > 0 && rc < sizeof(buf2) &&
+       !strchr(buf2,'%'))    /* no vars still unexpanded */
       env = buf2;
   }
 #else
   (void)do_expand;
 #ifdef __VMS
   env = getenv(variable);
-  if (env && strcmp("HOME",variable) == 0) {
-        env = decc_translate_vms(env);
+  if(env && strcmp("HOME",variable) == 0) {
+    env = decc_translate_vms(env);
   }
 #else
   /* no length control */
@@ -97,13 +97,13 @@ char *homedir(void)
  {
    struct passwd *pw = getpwuid(geteuid());
 
-   if (pw) {
+   if(pw) {
 #ifdef __VMS
      home = decc_translate_vms(pw->pw_dir);
 #else
      home = pw->pw_dir;
 #endif
-     if (home && home[0])
+     if(home && home[0])
        home = strdup(home);
      else
        home = NULL;
index e33bf9b..a6adf44 100644 (file)
@@ -303,6 +303,22 @@ typedef enum {
 #  endif
 #endif
 
+#define CURL_CA_CERT_ERRORMSG1                                          \
+  "More details here: http://curl.haxx.se/docs/sslcerts.html\n\n"       \
+  "curl performs SSL certificate verification by default, "             \
+  "using a \"bundle\"\n"                                                \
+  " of Certificate Authority (CA) public keys (CA certs). If the default\n" \
+  " bundle file isn't adequate, you can specify an alternate file\n"    \
+  " using the --cacert option.\n"
+
+#define CURL_CA_CERT_ERRORMSG2                                          \
+  "If this HTTPS server uses a certificate signed by a CA represented in\n" \
+  " the bundle, the certificate verification probably failed due to a\n" \
+  " problem with the certificate (it might be expired, or the name might\n" \
+  " not match the domain name in the URL).\n"                           \
+  "If you'd like to turn off curl's verification of the certificate, use\n" \
+  " the -k (or --insecure) option.\n"
+
 #ifdef CURL_DOES_CONVERSIONS
 #ifdef HAVE_ICONV
 iconv_t inbound_cd  = (iconv_t)-1;
@@ -778,7 +794,7 @@ static void help(void)
     " -K/--config <file> Specify which config file to read",
     "    --connect-timeout <seconds> Maximum time allowed for connection",
     " -C/--continue-at <offset> Resumed transfer offset",
-    " -b/--cookie <name=string/file> Cookie string or file to read cookies from (H)",
+    " -b/--cookie <name=string/file> String or file to read cookies from (H)",
     " -c/--cookie-jar <file> Write cookies to this file after operation (H)",
     "    --create-dirs   Create necessary local directory hierarchy",
     "    --crlf          Convert LF to CRLF in upload",
@@ -786,21 +802,23 @@ static void help(void)
     " -d/--data <data>   HTTP POST data (H)",
     "    --data-ascii <data>  HTTP POST ASCII data (H)",
     "    --data-binary <data> HTTP POST binary data (H)",
-    "    --data-urlencode <name=data/name@filename> HTTP POST data url encoded (H)",
+    "    --data-urlencode <name=data/name@filename> "
+    "HTTP POST data url encoded (H)",
     "    --digest        Use HTTP Digest Authentication (H)",
     "    --disable-eprt  Inhibit using EPRT or LPRT (F)",
     "    --disable-epsv  Inhibit using EPSV (F)",
     " -D/--dump-header <file> Write the headers to this file",
     "    --egd-file <file> EGD socket path for random data (SSL)",
-    "    --engine <eng>  Crypto engine to use (SSL). \"--engine list\" for list",
+    "    --engine <eng>  Crypto engine (SSL). \"--engine list\" for list",
 #ifdef USE_ENVIRONMENT
     "    --environment   Write results to environment variables (RISC OS)",
 #endif
     " -f/--fail          Fail silently (no output at all) on HTTP errors (H)",
     " -F/--form <name=content> Specify HTTP multipart POST data (H)",
     "    --form-string <name=string> Specify HTTP multipart POST data (H)",
-    "    --ftp-account <data> Account data to send when requested by server (F)",
-    "    --ftp-alternative-to-user <cmd> String to replace \"USER [name]\" (F)",
+    "    --ftp-account <data> Account data string (F)",
+    "    --ftp-alternative-to-user <cmd> "
+    "String to replace \"USER [name]\" (F)",
     "    --ftp-create-dirs Create the remote dirs if not present (F)",
     "    --ftp-method [multicwd/nocwd/singlecwd] Control CWD usage (F)",
     "    --ftp-pasv      Use PASV/EPSV instead of PORT (F)",
@@ -809,13 +827,15 @@ static void help(void)
     "    --ftp-pret      Send PRET before PASV (for drftpd) (F)",
     "    --ftp-ssl-ccc   Send CCC after authenticating (F)",
     "    --ftp-ssl-ccc-mode [active/passive] Set CCC mode (F)",
-    "    --ftp-ssl-control Require SSL/TLS for ftp login, clear for transfer (F)",
+    "    --ftp-ssl-control Require SSL/TLS for ftp login, "
+    "clear for transfer (F)",
     " -G/--get           Send the -d data with a HTTP GET (H)",
     " -g/--globoff       Disable URL sequences and ranges using {} and []",
     " -H/--header <line> Custom header to pass to server (H)",
     " -I/--head          Show document info only",
     " -h/--help          This help text",
-    "    --hostpubmd5 <md5> Hex encoded MD5 string of the host public key. (SSH)",
+    "    --hostpubmd5 <md5> "
+    "Hex encoded MD5 string of the host public key. (SSH)",
     " -0/--http1.0       Use HTTP 1.0 (H)",
     "    --ignore-content-length  Ignore the HTTP Content-Length header",
     " -i/--include       Include protocol headers in the output (H/F)",
@@ -852,11 +872,14 @@ static void help(void)
     "    --ntlm          Use HTTP NTLM authentication (H)",
     " -o/--output <file> Write output to <file> instead of stdout",
     "    --pass  <pass>  Pass phrase for the private key (SSL/SSH)",
-    "    --post301       Do not switch to GET after following a 301 redirect (H)",
-    "    --post302       Do not switch to GET after following a 302 redirect (H)",
+    "    --post301       "
+    "Do not switch to GET after following a 301 redirect (H)",
+    "    --post302       "
+    "Do not switch to GET after following a 302 redirect (H)",
     " -#/--progress-bar  Display transfer progress as a progress bar",
     "    --proto <protocols>       Enable/disable specified protocols",
-    "    --proto-redir <protocols> Enable/disable specified protocols on redirect",
+    "    --proto-redir <protocols> "
+    "Enable/disable specified protocols on redirect",
     " -x/--proxy <host[:port]> Use HTTP proxy on given port",
     "    --proxy-anyauth Pick \"any\" proxy authentication method (H)",
     "    --proxy-basic   Use Basic authentication on the proxy (H)",
@@ -867,7 +890,7 @@ static void help(void)
     "    --proxy1.0 <host[:port]> Use HTTP/1.0 proxy on given port",
     " -p/--proxytunnel   Operate through a HTTP proxy tunnel (using CONNECT)",
     "    --pubkey <key>  Public key file name (SSH)",
-    " -Q/--quote <cmd>   Send command(s) to server before file transfer (F/SFTP)",
+    " -Q/--quote <cmd>   Send command(s) to server before transfer (F/SFTP)",
     "    --random-file <file> File for reading random data from (SSL)",
     " -r/--range <range> Retrieve only the bytes within a range",
     "    --raw           Pass HTTP \"raw\", without any transfer decoding (H)",
@@ -877,21 +900,27 @@ static void help(void)
     " -R/--remote-time   Set the remote file's time on the local output",
     " -X/--request <command> Specify request command to use",
     "    --resolve <host:port:address> Force resolve of HOST:PORT to ADDRESS",
-    "    --retry <num>   Retry request <num> times if transient problems occur",
-    "    --retry-delay <seconds> When retrying, wait this many seconds between each",
+    "    --retry <num>   "
+    "Retry request <num> times if transient problems occur",
+    "    --retry-delay <seconds> "
+    "When retrying, wait this many seconds between each",
     "    --retry-max-time <seconds> Retry only within this period",
-    " -S/--show-error    Show error. With -s, make curl show errors when they occur",
+    " -S/--show-error    "
+    "Show error. With -s, make curl show errors when they occur",
     " -s/--silent        Silent mode. Don't output anything",
     "    --socks4 <host[:port]> SOCKS4 proxy on given host + port",
     "    --socks4a <host[:port]> SOCKS4a proxy on given host + port",
     "    --socks5 <host[:port]> SOCKS5 proxy on given host + port",
-    "    --socks5-hostname <host[:port]> SOCKS5 proxy, pass host name to proxy",
+    "    --socks5-hostname <host[:port]> "
+    "SOCKS5 proxy, pass host name to proxy",
 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
     "    --socks5-gssapi-service <name> SOCKS5 proxy service name for gssapi",
     "    --socks5-gssapi-nec  Compatibility with NEC SOCKS5 server",
 #endif
-    " -Y/--speed-limit   Stop transfer if below speed-limit for 'speed-time' secs",
-    " -y/--speed-time    Time needed to trig speed-limit abort. Defaults to 30",
+    " -Y/--speed-limit   "
+    "Stop transfer if below speed-limit for 'speed-time' secs",
+    " -y/--speed-time    "
+    "Time needed to trig speed-limit abort. Defaults to 30",
     "    --ssl           Try SSL/TLS (FTP, IMAP, POP3, SMTP)",
     "    --ssl-reqd      Require SSL/TLS (FTP, IMAP, POP3, SMTP)",
     " -2/--sslv2         Use SSLv2 (SSL)",
@@ -1092,7 +1121,7 @@ static void list_engines(const struct curl_slist *engines)
     puts("  <none>");
     return;
   }
-  for( ; engines; engines = engines->next)
+  for(; engines; engines = engines->next)
     printf("  %s\n", engines->data);
 }
 
@@ -1294,15 +1323,13 @@ static int formparse(struct Configurable *config,
           ++count;
         }
         forms = malloc((count+1)*sizeof(struct curl_forms));
-        if(!forms)
-        {
+        if(!forms) {
           fprintf(config->errors, "Error building form post!\n");
           free(contents);
           FreeMultiInfo(multi_start);
           return 4;
         }
-        for(i = 0, ptr = multi_start; i < count; ++i, ptr = ptr->next)
-        {
+        for(i = 0, ptr = multi_start; i < count; ++i, ptr = ptr->next) {
           forms[i].option = ptr->form.option;
           forms[i].value = ptr->form.value;
         }
@@ -1335,7 +1362,7 @@ static int formparse(struct Configurable *config,
         ct[0]=0; /* zero terminate here */
       }
 
-      if( contp[0]=='<' && !literal_value) {
+      if(contp[0]=='<' && !literal_value) {
         info[i].option = CURLFORM_FILECONTENT;
         info[i].value = contp+1;
         i++;
@@ -2782,7 +2809,7 @@ static 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(!strequal(config->tls_authtype, "SRP"))
             return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
         }
         else
@@ -3495,8 +3522,7 @@ static int parseconfig(const char *filename,
         }
       }
 
-      if(alloced_param)
-      {
+      if(alloced_param) {
         free(param);
         param = NULL;
       }
@@ -3714,7 +3740,7 @@ static int myprogress (void *clientp,
   if(total < 1) {
     curl_off_t prevblock = bar->prev / 1024;
     curl_off_t thisblock = point / 1024;
-    while( thisblock > prevblock ) {
+    while(thisblock > prevblock) {
       fprintf( bar->out, "#" );
       prevblock++;
     }
@@ -3724,9 +3750,8 @@ static int myprogress (void *clientp,
     percent = frac * 100.0f;
     barwidth = bar->width - 7;
     num = (int) (((double)barwidth) * frac);
-    for( i = 0; i < num; i++ ) {
+    for(i = 0; i < num; i++)
       line[i] = '#';
-    }
     line[i] = '\0';
     snprintf( format, sizeof(format), "%%-%ds %%5.1f%%%%", barwidth );
     snprintf( outline, sizeof(outline), format, line, percent );
@@ -4448,9 +4473,9 @@ parse_filename(char *ptr, size_t len)
      is that even systems that don't handle backslashes as path separators
      probably want the path removed for convenience. */
   q = strrchr(p, '\\');
-  if (q) {
+  if(q) {
     p = q+1;
-    if (!*p) {
+    if(!*p) {
       free(copy);
       return NULL;
     }
@@ -5692,21 +5717,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
                     errorbuffer[0]? errorbuffer:
                     curl_easy_strerror((CURLcode)res));
             if(CURLE_SSL_CACERT == res) {
-#define CURL_CA_CERT_ERRORMSG1                                          \
-              "More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
-                "curl performs SSL certificate verification by default, using a \"bundle\"\n" \
-                " of Certificate Authority (CA) public keys (CA certs). If the default\n" \
-                " bundle file isn't adequate, you can specify an alternate file\n" \
-                " using the --cacert option.\n"
-
-#define CURL_CA_CERT_ERRORMSG2                                          \
-              "If this HTTPS server uses a certificate signed by a CA represented in\n" \
-                " the bundle, the certificate verification probably failed due to a\n" \
-                " problem with the certificate (it might be expired, or the name might\n" \
-                " not match the domain name in the URL).\n"             \
-                "If you'd like to turn off curl's verification of the certificate, use\n" \
-                " the -k (or --insecure) option.\n"
-
               fprintf(config->errors, "%s%s",
                       CURL_CA_CERT_ERRORMSG1,
                       CURL_CA_CERT_ERRORMSG2 );
@@ -5749,7 +5759,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
 #ifdef __AMIGA__
         /* Set the url as comment for the file. (up to 80 chars are allowed)
          */
-        if( strlen(url) > 78 )
+        if(strlen(url) > 78)
           url[79] = '\0';
 
         SetComment( outs.filename, url);
@@ -5845,12 +5855,12 @@ static void checkfds(void)
 {
 #ifdef HAVE_PIPE
   int fd[2] = { STDIN_FILENO, STDIN_FILENO };
-  while( fd[0] == STDIN_FILENO ||
-         fd[0] == STDOUT_FILENO ||
-         fd[0] == STDERR_FILENO ||
-         fd[1] == STDIN_FILENO ||
-         fd[1] == STDOUT_FILENO ||
-         fd[1] == STDERR_FILENO )
+  while(fd[0] == STDIN_FILENO ||
+        fd[0] == STDOUT_FILENO ||
+        fd[0] == STDERR_FILENO ||
+        fd[1] == STDIN_FILENO ||
+        fd[1] == STDOUT_FILENO ||
+        fd[1] == STDERR_FILENO)
     if(pipe(fd) < 0)
       return;   /* Out of handles. This isn't really a big problem now, but
                    will be when we try to create a socket later. */
index 0d2a99f..b510fd9 100644 (file)
@@ -7,7 +7,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -28,7 +28,8 @@
  * Define WIN32 when build target is Win32 API
  */
 
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !defined(__SYMBIAN32__)
+#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \
+  !defined(__SYMBIAN32__)
 #define WIN32
 #endif
 
index 590c37a..457e32c 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -74,7 +74,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
   pat->content.Set.elements = (char**)malloc(0);
   ++glob->size;
 
-  while (!done) {
+  while(!done) {
     switch (*pattern) {
     case '\0':                  /* URL ended while set was still open */
       snprintf(glob->errormsg, sizeof(glob->errormsg),
@@ -93,7 +93,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
       pat->content.Set.elements =
         realloc(pat->content.Set.elements,
                 (pat->content.Set.size + 1) * sizeof(char*));
-      if (!pat->content.Set.elements) {
+      if(!pat->content.Set.elements) {
         snprintf(glob->errormsg, sizeof(glob->errormsg), "out of memory");
         return GLOB_ERROR;
       }
@@ -101,7 +101,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
         strdup(glob->glob_buffer);
       ++pat->content.Set.size;
 
-      if (*pattern == '}') {
+      if(*pattern == '}') {
         /* entire set pattern completed */
         int wordamount;
 
@@ -159,13 +159,13 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
   /* patterns 0,1,2,... correspond to size=1,3,5,... */
   ++glob->size;
 
-  if (ISALPHA(*pattern)) {         /* character range detected */
+  if(ISALPHA(*pattern)) {         /* character range detected */
     char min_c;
     char max_c;
 
     pat->type = UPTCharRange;
     rc = sscanf(pattern, "%c-%c%c%d%c", &min_c, &max_c, &sep, &step, &sep2);
-    if ((rc < 3) || (min_c >= max_c) || ((max_c - min_c) > ('z' - 'a'))) {
+    if((rc < 3) || (min_c >= max_c) || ((max_c - min_c) > ('z' - 'a'))) {
       /* the pattern is not well-formed */
       snprintf(glob->errormsg, sizeof(glob->errormsg),
                "error: bad range specification after pos %zu\n", pos);
@@ -187,7 +187,7 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
     pat->content.CharRange.ptr_c = pat->content.CharRange.min_c = min_c;
     pat->content.CharRange.max_c = max_c;
   }
-  else if (ISDIGIT(*pattern)) { /* numeric range detected */
+  else if(ISDIGIT(*pattern)) { /* numeric range detected */
     int min_n;
     int max_n;
 
@@ -196,7 +196,7 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
 
     rc = sscanf(pattern, "%d-%d%c%d%c", &min_n, &max_n, &sep, &step, &sep2);
 
-    if ((rc < 2) || (min_n > max_n)) {
+    if((rc < 2) || (min_n > max_n)) {
       /* the pattern is not well-formed */
       snprintf(glob->errormsg, sizeof(glob->errormsg),
                "error: bad range specification after pos %zu\n", pos);
@@ -209,9 +209,9 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
     pat->content.NumRange.step =
       ((sep == ':') && (rc == 5) && (sep2 == ']'))?step:1;
 
-    if (*pattern == '0') {              /* leading zero specified */
+    if(*pattern == '0') {              /* leading zero specified */
       c = pattern;
-      while (ISDIGIT(*c)) {
+      while(ISDIGIT(*c)) {
         c++;
         ++pat->content.NumRange.padlength; /* padding length is set for all
                                               instances of this pattern */
@@ -261,15 +261,15 @@ static GlobCode glob_word(URLGlob *glob, char *pattern,
 
   *amount = 1; /* default is one single string */
 
-  while (*pattern != '\0' && *pattern != '{' && *pattern != '[') {
-    if (*pattern == '}' || *pattern == ']') {
+  while(*pattern != '\0' && *pattern != '{' && *pattern != '[') {
+    if(*pattern == '}' || *pattern == ']') {
       snprintf(glob->errormsg, sizeof(glob->errormsg),
                "unmatched close brace/bracket at pos %zu\n", pos);
       return GLOB_ERROR;
     }
 
     /* only allow \ to escape known "special letters" */
-    if (*pattern == '\\' &&
+    if(*pattern == '\\' &&
         (*(pattern+1) == '{' || *(pattern+1) == '[' ||
          *(pattern+1) == '}' || *(pattern+1) == ']') ) {
 
@@ -358,13 +358,13 @@ void glob_cleanup(URLGlob* glob)
   size_t i;
   int elem;
 
-  for (i = glob->size - 1; i < glob->size; --i) {
-    if (!(i & 1)) {     /* even indexes contain literals */
+  for(i = glob->size - 1; i < glob->size; --i) {
+    if(!(i & 1)) {     /* even indexes contain literals */
       free(glob->literal[i/2]);
     }
     else {              /* odd indexes contain sets or ranges */
-      if (glob->pattern[i/2].type == UPTSet) {
-        for (elem = glob->pattern[i/2].content.Set.size - 1;
+      if(glob->pattern[i/2].type == UPTSet) {
+        for(elem = glob->pattern[i/2].content.Set.size - 1;
              elem >= 0;
              --elem) {
           free(glob->pattern[i/2].content.Set.elements[elem]);
@@ -387,19 +387,19 @@ char *glob_next_url(URLGlob *glob)
   size_t buflen = glob->urllen+1;
   size_t len;
 
-  if (!glob->beenhere)
+  if(!glob->beenhere)
     glob->beenhere = 1;
   else {
     bool carry = TRUE;
 
     /* implement a counter over the index ranges of all patterns,
        starting with the rightmost pattern */
-    for (i = glob->size / 2 - 1; carry && i < glob->size; --i) {
+    for(i = glob->size / 2 - 1; carry && i < glob->size; --i) {
       carry = FALSE;
       pat = &glob->pattern[i];
       switch (pat->type) {
       case UPTSet:
-        if (++pat->content.Set.ptr_s == pat->content.Set.size) {
+        if(++pat->content.Set.ptr_s == pat->content.Set.size) {
           pat->content.Set.ptr_s = 0;
           carry = TRUE;
         }
@@ -407,14 +407,14 @@ char *glob_next_url(URLGlob *glob)
       case UPTCharRange:
         pat->content.CharRange.ptr_c = (char)(pat->content.CharRange.step +
                            (int)((unsigned char)pat->content.CharRange.ptr_c));
-        if (pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) {
+        if(pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) {
           pat->content.CharRange.ptr_c = pat->content.CharRange.min_c;
           carry = TRUE;
         }
         break;
       case UPTNumRange:
         pat->content.NumRange.ptr_n += pat->content.NumRange.step;
-        if (pat->content.NumRange.ptr_n > pat->content.NumRange.max_n) {
+        if(pat->content.NumRange.ptr_n > pat->content.NumRange.max_n) {
           pat->content.NumRange.ptr_n = pat->content.NumRange.min_n;
           carry = TRUE;
         }
@@ -424,12 +424,12 @@ char *glob_next_url(URLGlob *glob)
         exit (CURLE_FAILED_INIT);
       }
     }
-    if (carry)          /* first pattern ptr has run into overflow, done! */
+    if(carry)          /* first pattern ptr has run into overflow, done! */
       return NULL;
   }
 
-  for (j = 0; j < glob->size; ++j) {
-    if (!(j&1)) {              /* every other term (j even) is a literal */
+  for(j = 0; j < glob->size; ++j) {
+    if(!(j&1)) {              /* every other term (j even) is a literal */
       lit = glob->literal[j/2];
       len = snprintf(buf, buflen, "%s", lit);
       buf += len;
@@ -484,14 +484,14 @@ char *glob_match_url(char *filename, URLGlob *glob)
   if(NULL == target)
     return NULL; /* major failure */
 
-  while (*filename) {
-    if (*filename == '#' && ISDIGIT(filename[1])) {
+  while(*filename) {
+    if(*filename == '#' && ISDIGIT(filename[1])) {
       unsigned long i;
       char *ptr = filename;
       unsigned long num = strtoul(&filename[1], &filename, 10);
       i = num-1;
 
-      if (num && (i <= glob->size / 2)) {
+      if(num && (i <= glob->size / 2)) {
         URLPattern pat = glob->pattern[i];
         switch (pat.type) {
         case UPTSet:
index 18e1a06..e3edbec 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -84,17 +84,17 @@ void ourWriteEnv(CURL *curl)
   long longinfo;
   double doubleinfo;
 
-  for (i=0; variables[i].name; i++) {
+  for(i=0; variables[i].name; i++) {
     switch (variables[i].type) {
     case writeenv_STRING:
-      if (curl_easy_getinfo(curl, variables[i].id, &string) == CURLE_OK)
+      if(curl_easy_getinfo(curl, variables[i].id, &string) == CURLE_OK)
         internalSetEnv(variables[i].name, string);
       else
         internalSetEnv(variables[i].name, NULL);
       break;
 
     case writeenv_LONG:
-      if (curl_easy_getinfo(curl, variables[i].id, &longinfo) == CURLE_OK) {
+      if(curl_easy_getinfo(curl, variables[i].id, &longinfo) == CURLE_OK) {
         curl_msprintf(numtext, "%5ld", longinfo);
         internalSetEnv(variables[i].name, numtext);
       }
@@ -102,7 +102,7 @@ void ourWriteEnv(CURL *curl)
         internalSetEnv(variables[i].name, NULL);
       break;
     case writeenv_DOUBLE:
-      if (curl_easy_getinfo(curl, variables[i].id, &doubleinfo) == CURLE_OK) {
+      if(curl_easy_getinfo(curl, variables[i].id, &doubleinfo) == CURLE_OK) {
         curl_msprintf(numtext, "%6.2f", doubleinfo);
         internalSetEnv(variables[i].name, numtext);
       }
index b8801a4..e044a9d 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, 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
@@ -167,7 +167,8 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
                 break;
               case VAR_REDIRECT_TIME:
                 if(CURLE_OK ==
-                   curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &doubleinfo))
+                   curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME,
+                                     &doubleinfo))
                   fprintf(stream, "%.3f", doubleinfo);
                 break;
               case VAR_TOTAL_TIME:
@@ -211,12 +212,14 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
                 break;
               case VAR_SIZE_DOWNLOAD:
                 if(CURLE_OK ==
-                   curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &doubleinfo))
+                   curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD,
+                                     &doubleinfo))
                   fprintf(stream, "%.0f", doubleinfo);
                 break;
               case VAR_SPEED_DOWNLOAD:
                 if(CURLE_OK ==
-                   curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &doubleinfo))
+                   curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD,
+                                     &doubleinfo))
                   fprintf(stream, "%.3f", doubleinfo);
                 break;
               case VAR_SPEED_UPLOAD:
@@ -244,7 +247,8 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
                 break;
               case VAR_SSL_VERIFY_RESULT:
                 if(CURLE_OK ==
-                   curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &longinfo))
+                   curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT,
+                                     &longinfo))
                   fprintf(stream, "%ld", longinfo);
                 break;
               default:
index 3af3282..61d6697 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010, 2011, 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
@@ -51,10 +51,10 @@ int fwrite_xattr(CURL *curl, int fd)
   int i = 0;
   int err = 0;
   /* loop through all xattr-curlinfo pairs and abort on a set error */
-  while ( err == 0 && mappings[i].attr != NULL ) {
+  while(err == 0 && mappings[i].attr != NULL) {
     char *value = NULL;
     CURLcode rc = curl_easy_getinfo(curl, mappings[i].info, &value);
-    if ( rc == CURLE_OK && value ) {
+    if(rc == CURLE_OK && value) {
 #ifdef HAVE_FSETXATTR_6
       err = fsetxattr( fd, mappings[i].attr, value, strlen(value), 0, 0 );
 #elif defined(HAVE_FSETXATTR_5)