Avoid macro preprocessing when filling the parse_table for better
readability.
* find/parser.c (PASTE, PARSE_OPTION, PARSE_POSOPT, PARSE_TEST,
PARSE_TEST_NP, PARSE_ACTION, PARSE_PUNCTUATION): Remove macros.
(parse_table): Replace macro-based filling with regular structure entries.
Group entries by types: regular options, positional options, punctuation,
tests and actions; loosely sort within each group.
Remove duplicate "atime" entry introduced in commit 7102a229fa.
While at it, change -help and -version from ARG_TEST to ARG_OPTION.
---
find/parser.c | 221 +++---
1 file changed, 102 insertions(+), 119 deletions(-)
diff --git a/find/parser.c b/find/parser.c
index f4b38d4c..03000645 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -191,28 +191,6 @@ static bool stream_is_tty(FILE *fp);
static bool parse_noop (const struct parser_table* entry,
char **argv, int *arg_ptr);
-#define PASTE(x,y) x##y
-
-
-#define PARSE_OPTION(what,suffix) \
- { (ARG_OPTION), (what), PASTE(parse_,suffix), nullptr }
-
-#define PARSE_POSOPT(what,suffix) \
- { (ARG_POSITIONAL_OPTION), (what), PASTE(parse_,suffix), nullptr }
-
-#define PARSE_TEST(what,suffix) \
- { (ARG_TEST), (what), PASTE(parse_,suffix), PASTE(pred_,suffix) }
-
-#define PARSE_TEST_NP(what,suffix) \
- { (ARG_TEST), (what), PASTE(parse_,suffix), nullptr }
-
-#define PARSE_ACTION(what,suffix) \
- { (ARG_ACTION), (what), PASTE(parse_,suffix), PASTE(pred_,suffix) }
-
-#define PARSE_PUNCTUATION(what,suffix) \
- { (ARG_PUNCTUATION), (what), PASTE(parse_,suffix), PASTE(pred_,suffix) }
-
-
/* Predicates we cannot handle in the usual way. If you add an entry
* to this table, double-check the switch statement in
* pred_sanity_check() to make sure that the new case is being
@@ -223,113 +201,118 @@ static struct parser_table const parse_entry_newerXY =
ARG_SPECIAL_PARSE, "newerXY",parse_newerXY, pred_newerXY /*
BSD */
};
-/* GNU find predicates that are not mentioned in POSIX.2 are marked `GNU'.
+/* GNU find predicates that are not mentioned in POSIX are marked `GNU'.
If they are in some Unix versions of find, they are marked `Unix'. */
static struct parser_table const parse_table[] =
{
- PARSE_PUNCTUATION("!", negate), /* POSIX */
- PARSE_PUNCTUATION("not", negate),/* GNU */
- PARSE_PUNCTUATION("(", openparen), /* POSIX */
- PARSE_PUNCTUATION(")", closeparen), /* POSIX */
- PARSE_PUNCTUATION(",", comma), /* GNU */
- PARSE_PUNCTUATION("a", and), /* POSIX */
- PARSE_TEST ("amin", amin), /* GNU */
- PARSE_PUNCTUATION("and", and), /* GNU */
- PARSE_TEST ("anewer",anewer),/* GNU */
- {ARG_TEST, "atime", parse_time, pred_atime}, /* POSIX
*/
- PARSE_TEST ("cmin", cmin), /* GNU */
- PARSE_TEST ("cnewer",cnewer),/* GNU */
- {ARG_TEST, "ctime", parse_time, pred_ctime}, /* POSIX
*/
- PARSE_TEST ("context", context), /* GNU */
- PARSE_POSOPT ("daystart", daystart), /* GNU */
- PARSE_ACTION ("delete",delete), /* GNU, Mac OS, FreeBSD
*/
- PARSE_OPTION ("d", d), /* Mac OS X, FreeBSD, NetBSD,
OpenBSD, but deprecated in favour of -depth */
- PARSE_OPTION ("depth", depth), /* POSIX */
- PARSE_TEST ("empty", empty), /* GNU */
- {ARG_ACTION, "exec",parse_exec, pred_exec}, /* POSIX */
- {ARG_TEST,"executable",parse_accesscheck,
pred_executable}, /* GNU, 4.3.0+ */
- PARSE_ACTION ("execdir", execdir), /* *BSD, GNU */
- PARSE_OPTION ("files0-from", files0_from), /* GNU */
- PARSE_ACTION ("fls", fls), /* GNU */
- PARSE_POSOPT ("follow",follow), /* GNU, Unix */
- PARSE_ACTION ("fprint",fprint),/* GNU */
- PARSE_ACTION ("fprint0", fprint0), /* GNU */
- {ARG_ACTION, "fprintf", parse_fprintf, pred_fprintf}, /* GNU */
- PARSE_TEST ("fstype",fstype), /* GNU, Unix */
- PARSE_TEST ("gid", gid), /* GNU */
- PARSE_TEST ("group", group), /* POSIX */
- PARSE_OPTION ("ignore_readdir_race", ignore_race), /* GNU */
- PARSE_TEST ("ilname",ilname),/* GNU */
- PARSE_TEST ("iname", iname), /* GNU */
- PARSE_TEST ("inum", inum),/* GNU, Unix */
- PARSE_TEST ("ipath", ipath), /* GNU, deprecated in
favour of iwholename */
- PARSE_TEST_N