From 8fc9de8d6bf663f7c8419b42dab01f590a694d59 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 18 Apr 2013 14:40:43 +0200 Subject: Allow marking options as ignored. * jnlib/argparse.h (ARGPARSE_OPT_IGNORE): New. (ARGPARSE_TYPE_MASK): New, for internal use. (ARGPARSE_ignore): New. * jnlib/argparse.c (optfile_parse, arg_parse): Replace remaining constants by macros. (optfile_parse): Implement ARGPARSE_OPT_IGNORE. (arg_parse): Exclide ignore options from --dump-options. -- In addition to the ignore-invalid-option (commit 41d56433) it is often useful to mark options in a configuration which as NOP. For example options which have no more function at all but can be expected to be found in existing conf files. Such an option (or command) may now be given as ARGPARSE_ignore (300, "obsolete-option") The 300 is merely used as a non-valid single option name much like group names or the 500+n values used for long options. Signed-off-by: Werner Koch (cherry picked from commit 54c54e2824aab5716a187bbbf6dff8860d6a6056) Resolved conflicts: common/argparse.c: Fixed. --- common/argparse.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'common/argparse.h') diff --git a/common/argparse.h b/common/argparse.h index a36218fc8..29c7b6252 100644 --- a/common/argparse.h +++ b/common/argparse.h @@ -94,7 +94,10 @@ typedef struct #define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */ #define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */ #define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */ -#define ARGPARSE_OPT_COMMAND (1<<8) /* The argument is a command. */ +#define ARGPARSE_OPT_IGNORE (1<<6) /* Ignore command or option. */ +#define ARGPARSE_OPT_COMMAND (1<<7) /* The argument is a command. */ + +#define ARGPARSE_TYPE_MASK 7 /* Mask for the type values (internal). */ /* A set of macros to make option definitions easier to read. */ #define ARGPARSE_x(s,l,t,f,d) \ @@ -161,6 +164,8 @@ typedef struct #define ARGPARSE_c(s,l,d) \ { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) } +#define ARGPARSE_ignore(s,l) \ + { (s), (l), (ARGPARSE_OPT_IGNORE), "@" } #define ARGPARSE_group(s,d) \ { (s), NULL, 0, (d) } -- cgit v1.2.3