From f3e56f4e4ff773de95fa2c9daf979734d826fc33 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 31 Dec 2014 21:30:59 -0600 Subject: Redo option parsing infrastructure so #define FORCE_FLAGS can unzero flag macros for a disabled command (needed when multiple commands share infrastructure with a common set of flags). This means the flag space is no longer packed, but leaves gaps where the zeroes go. (Actual flag bit positions are the same for all configs.) Since the option parsing needs to know where the holes are, the OPTSTR values are now generated as part of flags.h with ascii 1 values for the disabled values. (So generated/oldflags.h went away.) This also means that the option string argument for OLDTOY() went away, it now uses the same arguments as the NEWTOY() it references. --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index eefebf9e..dfab2f2a 100644 --- a/main.c +++ b/main.c @@ -10,7 +10,8 @@ #undef NEWTOY #undef OLDTOY #define NEWTOY(name, opts, flags) {#name, name##_main, opts, flags}, -#define OLDTOY(name, oldname, opts, flags) {#name, oldname##_main, opts, flags}, +#define OLDTOY(name, oldname, flags) \ + {#name, oldname##_main, OPTSTR_##oldname, flags}, struct toy_list toy_list[] = { #include "generated/newtoys.h" @@ -57,7 +58,7 @@ struct toy_list *toy_find(char *name) #undef NEWTOY #undef OLDTOY #define NEWTOY(name, opts, flags) opts || -#define OLDTOY(name, oldname, opts, flags) opts || +#define OLDTOY(name, oldname, flags) OPTSTR_##oldname || static const int NEED_OPTIONS = #include "generated/newtoys.h" 0; // Ends the opts || opts || opts... -- cgit v1.2.3