common: Improve fucntion parse_debug_flag.
authorWerner Koch <wk@gnupg.org>
Tue, 23 Jun 2015 07:10:56 +0000 (09:10 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 23 Jun 2015 07:13:45 +0000 (09:13 +0200)
* common/miscellaneous.c (parse_debug_flag): Add hack not to call
exit.  Add "none" and "all" flags.

Signed-off-by: Werner Koch <wk@gnupg.org>
common/miscellaneous.c

index e840895..ec36f08 100644 (file)
@@ -440,7 +440,8 @@ parse_debug_flag (const char *string, unsigned int *debugvar,
       log_info ("available debug flags:\n");
       for (i=0; flags[i].name; i++)
         log_info (" %5u %s\n", flags[i].flag, flags[i].name);
-      exit (0);
+      if (flags[i].flag != 77)
+        exit (0);
     }
   else if (digitp (string))
     {
@@ -466,7 +467,17 @@ parse_debug_flag (const char *string, unsigned int *debugvar,
                     break;
                   }
               if (!flags[j].name)
-                log_info (_("unknown debug flag '%s' ignored\n"), words[i]);
+                {
+                  if (!strcmp (words[i], "none"))
+                    {
+                      *debugvar = 0;
+                      result = 0;
+                    }
+                  else if (!strcmp (words[i], "all"))
+                    result = ~0;
+                  else
+                    log_info (_("unknown debug flag '%s' ignored\n"), words[i]);
+                }
             }
         }
       xfree (words);