]> granicus.if.org Git - curl/commitdiff
--show-error: position indepdenent
authorDaniel Stenberg <daniel@haxx.se>
Sun, 16 Oct 2011 21:39:59 +0000 (23:39 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 16 Oct 2011 21:39:59 +0000 (23:39 +0200)
Previously we required that -S/--show-error was used _after_
-s/--silent. This was slightly confusing since we strive to make
arguments as position independent as possible.

Now, you can use them in any order and the result should still be the
same.

Bug: http://curl.haxx.se/bug/view.cgi?id=3424286
Reported by: Andreas Olsson

src/tool_cfgable.h
src/tool_getparam.c
src/tool_operate.c

index f27a8e24e92dc634cc9beba678d87bc1ea230d1c..adbb446270b81f1c6e4773a23dd6a6998a44322e 100644 (file)
@@ -64,7 +64,9 @@ struct Configurable {
   char *range;
   long low_speed_limit;
   long low_speed_time;
-  bool showerror;
+  int showerror; /* -1 == unset, default => show errors
+                    0 => -s is used to NOT show errors
+                    1 => -S has been used to show errors */
   char *userpwd;
   char *tls_username;
   char *tls_password;
index bb36b4246e43cdfe60af918feaeb7c26f815a78c..bd7375fd9deab2696515838894d2e653209c4d02 100644 (file)
@@ -1426,11 +1426,15 @@ ParameterError getparameter(char *flag,    /* f or -long-flag */
         config->mute = config->noprogress = TRUE;
       else
         config->mute = config->noprogress = FALSE;
-      config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
+      if(config->showerror < 0)
+        /* if still on the default value, set showerror to the reverse of
+           toggle. This is to allow -S and -s to be used in an independent
+           order but still have the same effect. */
+        config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
       break;
     case 'S':
       /* show errors */
-      config->showerror = toggle; /* toggle on if used with -s */
+      config->showerror = toggle?1:0; /* toggle on if used with -s */
       break;
     case 't':
       /* Telnet options */
index 481116ddf9c0547edd20fcb342293671c703ed6d..65f4b60b8533a94348187b2671128719d5f97139 100644 (file)
@@ -164,7 +164,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
 
   /* inits */
   config->postfieldsize = -1;
-  config->showerror = TRUE;
+  config->showerror = -1; /* will show errors */
   config->use_httpget = FALSE;
   config->create_dirs = FALSE;
   config->maxredirs = DEFAULT_MAXREDIRS;