From 72948b2751a4394823636acd3c076445122ffa61 Mon Sep 17 00:00:00 2001 From: bjk Date: Sat, 30 Jul 2005 15:46:52 +0000 Subject: [PATCH] Fix for modules which take no options at all. Getopt() was terminating the options list and treating other options as arguments. Verbosity (-v) is done per-module unless specified twice (-vv). --- src/ui.c | 17 ++++++++++++++--- src/ui.h | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ui.c b/src/ui.c index b09a250..bd4ef37 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,4 +1,4 @@ -/* $Id: ui.c,v 2.4 2005-07-30 15:21:21 bjk Exp $ */ +/* $Id: ui.c,v 2.5 2005-07-30 15:46:52 bjk Exp $ */ /* Copyright (C) 2001-2005 Ben Kibbey @@ -219,8 +219,12 @@ static int open_module(char *filename, int *index) if (chain_output) SET_FLAG(modules[*index].flags, MODULE_OUTPUT); + if (verbose) + SET_FLAG(modules[*index].flags, MODULE_VERBOSE); + chaining = 0; chain_output = 1; + verbose = (verbose < 2) ? 0 : 2; return 0; } @@ -325,7 +329,7 @@ static int junction(const char *arg) continue; } - ret |= (*m_exec) (&s, pw, multichar, verbose, tf); + ret |= (*m_exec) (&s, pw, multichar, TEST_FLAG(modules[i].flags, MODULE_VERBOSE), tf); if (!TEST_FLAG(modules[i].flags, MODULE_CHAINED) || (TEST_FLAG(modules[i].flags, MODULE_CHAINED) && TEST_FLAG(modules[i].flags, MODULE_OUTPUT))) { output(s, delimchar, @@ -712,7 +716,7 @@ int main(int argc, char *argv[]) usefile = 1; break; case 'v': - verbose = 1; + verbose++; break; case 'X': chain_output = 0; @@ -727,6 +731,13 @@ int main(int argc, char *argv[]) if (init_module_options(argc, argv, i)) want_help = 1; + /* + * For modules which have no options at all (to keep getopt + * from interpreting the rest as arguments. + */ + if (strcmp(argv[optind], "--") == 0) + optind++; + break; case 'h': default: diff --git a/src/ui.h b/src/ui.h index 89d528d..57ea0c8 100644 --- a/src/ui.h +++ b/src/ui.h @@ -1,4 +1,4 @@ -/* $Id: ui.h,v 2.2 2005-07-30 12:59:46 bjk Exp $ */ +/* $Id: ui.h,v 2.3 2005-07-30 15:46:52 bjk Exp $ */ /* Copyright (C) 2001-2005 Ben Kibbey @@ -58,6 +58,7 @@ #define MODULE_OUTPUT 0x002 #define MODULE_CHAINED 0x004 #define MODULE_CHAINABLE 0x008 +#define MODULE_VERBOSE 0x010 #define SET_FLAG(var, f) (var |= f) #define TEST_FLAG(var, f) (var & f) -- 2.11.4.GIT