@@ -2188,64 +2188,45 @@ static void processListLanguagesOption (
21882188 exit (0 );
21892189}
21902190
2191- static void processListPseudoTagsOptions (
2192- const char * const option CTAGS_ATTR_UNUSED ,
2193- const char * const parameter CTAGS_ATTR_UNUSED )
2194- {
2195- printPtags (localOption .withListHeader , localOption .machinable , stdout );
2196- exit (0 );
2197- }
2198-
2199- static void processListRegexFlagsOptions (
2200- const char * const option CTAGS_ATTR_UNUSED ,
2201- const char * const parameter )
2202- {
2203- printRegexFlags (localOption .withListHeader , localOption .machinable , parameter , stdout );
2204- exit (0 );
2205- }
2206-
2207- static void processListMultilineRegexFlagsOptions (
2208- const char * const option CTAGS_ATTR_UNUSED ,
2209- const char * const parameter )
2210- {
2211- printMultilineRegexFlags (localOption .withListHeader , localOption .machinable , parameter , stdout );
2212- exit (0 );
2213- }
2214-
2215- static void processListMultitableRegexFlagsOptions (
2216- const char * const option CTAGS_ATTR_UNUSED ,
2217- const char * const parameter )
2218- {
2219- printMultitableRegexFlags (localOption .withListHeader , localOption .machinable , parameter , stdout );
2220- exit (0 );
2221- }
2222-
2223- static void processListLangdefFlagsOptions (
2224- const char * const option CTAGS_ATTR_UNUSED ,
2225- const char * const parameter CTAGS_ATTR_UNUSED )
2226- {
2227- printLangdefFlags (localOption .withListHeader , localOption .machinable , stdout );
2228- exit (0 );
2229- }
2230-
2231- static void processListKinddefFlagsOptions (
2232- const char * const option CTAGS_ATTR_UNUSED ,
2233- const char * const parameter CTAGS_ATTR_UNUSED )
2234- {
2235- printKinddefFlags (localOption .withListHeader , localOption .machinable , stdout );
2236- exit (0 );
2237- }
2191+ #define defineListFunctionForOption (target ,proc ) \
2192+ attr__noreturn \
2193+ static void processList##target##Option ( \
2194+ const char *const option CTAGS_ATTR_UNUSED, \
2195+ const char *const parameter CTAGS_ATTR_UNUSED) \
2196+ { \
2197+ proc (localOption.withListHeader, localOption.machinable, stdout); \
2198+ exit (0); \
2199+ } attr__noreturn static void processList##target##Option ( \
2200+ const char *const option CTAGS_ATTR_UNUSED, \
2201+ const char *const parameter CTAGS_ATTR_UNUSED) /* So we cat put ';' at the end of macro expansion. */
2202+
2203+ #define defineListFunctionForOptionWithParameter (target ,proc ) \
2204+ attr__noreturn \
2205+ static void processList##target##Option ( \
2206+ const char *const option CTAGS_ATTR_UNUSED, \
2207+ const char *const parameter) \
2208+ { \
2209+ proc (localOption.withListHeader, localOption.machinable, parameter, stdout); \
2210+ exit (0); \
2211+ } attr__noreturn static void processList##target##Option ( \
2212+ const char *const option CTAGS_ATTR_UNUSED, \
2213+ const char *const parameter) /* So we cat put ';' at the end of macro expansion. */
2214+
2215+ defineListFunctionForOption (PseudoTags , printPtags );
2216+
2217+ defineListFunctionForOptionWithParameter (RegexFlags , printRegexFlags );
2218+ defineListFunctionForOptionWithParameter (MultilineRegexFlags , printMultilineRegexFlags );
2219+ defineListFunctionForOptionWithParameter (MultitableRegexFlags , printMultitableRegexFlags );
2220+
2221+ defineListFunctionForOption (LangdefFlags , printLangdefFlags );
2222+ defineListFunctionForOption (KinddefFlags , printKinddefFlags );
2223+ defineListFunctionForOption (FielddefFlags , printFielddefFlags );
2224+
2225+ defineListFunctionForOption (OutputFormats , printOutputFormats );
22382226
2239- static void processListFielddefFlagsOptions (
2240- const char * const option CTAGS_ATTR_UNUSED ,
2241- const char * const parameter CTAGS_ATTR_UNUSED )
2242- {
2243- printFielddefFlags (localOption .withListHeader , localOption .machinable , stdout );
2244- exit (0 );
2245- }
22462227
22472228attr__noreturn
2248- static void processListRolesOptions (const char * const option CTAGS_ATTR_UNUSED ,
2229+ static void processListRolesOption (const char * const option CTAGS_ATTR_UNUSED ,
22492230 const char * const parameter )
22502231{
22512232 const char * sep ;
@@ -2268,7 +2249,7 @@ static void processListRolesOptions (const char *const option CTAGS_ATTR_UNUSED,
22682249 {
22692250 vString * vstr = vStringNewInit (parameter );
22702251 vStringCatS (vstr , (sep ? "*" : ".*" ));
2271- processListRolesOptions (option , vStringValue (vstr ));
2252+ processListRolesOption (option , vStringValue (vstr ));
22722253 /* The control should never reached here. */
22732254 }
22742255
@@ -2294,7 +2275,7 @@ static void processListRolesOptions (const char *const option CTAGS_ATTR_UNUSED,
22942275 exit (0 );
22952276}
22962277
2297- static void processListSubparsersOptions (const char * const option CTAGS_ATTR_UNUSED ,
2278+ static void processListSubparsersOption (const char * const option CTAGS_ATTR_UNUSED ,
22982279 const char * const parameter )
22992280{
23002281 langType lang ;
@@ -2327,13 +2308,6 @@ static void processListOperators (const char *const option CTAGS_ATTR_UNUSED,
23272308 exit (0 );
23282309}
23292310
2330- static void processListOutputFormatsOption (const char * const option CTAGS_ATTR_UNUSED ,
2331- const char * const parameter CTAGS_ATTR_UNUSED )
2332- {
2333- printOutputFormats (localOption .withListHeader , localOption .machinable , stdout );
2334- exit (0 );
2335- }
2336-
23372311static void freeSearchPathList (searchPathList * * pathList )
23382312{
23392313 stringListClear (* pathList );
@@ -2918,13 +2892,13 @@ static parametricOption ParametricOptions [] = {
29182892 { "list-maps" , processListMapsOption , true, STAGE_ANY },
29192893 { "list-map-extensions" , processListMapExtensionsOption , true, STAGE_ANY },
29202894 { "list-map-patterns" , processListMapPatternsOption , true, STAGE_ANY },
2921- { "list-mline-regex-flags" , processListMultilineRegexFlagsOptions , true, STAGE_ANY },
2895+ { "list-mline-regex-flags" , processListMultilineRegexFlagsOption , true, STAGE_ANY },
29222896 { "list-output-formats" , processListOutputFormatsOption , true, STAGE_ANY },
29232897 { "list-params" , processListParametersOption , true, STAGE_ANY },
2924- { "list-pseudo-tags" , processListPseudoTagsOptions , true, STAGE_ANY },
2925- { "list-regex-flags" , processListRegexFlagsOptions , true, STAGE_ANY },
2926- { "list-roles" , processListRolesOptions , true, STAGE_ANY },
2927- { "list-subparsers" , processListSubparsersOptions , true, STAGE_ANY },
2898+ { "list-pseudo-tags" , processListPseudoTagsOption , true, STAGE_ANY },
2899+ { "list-regex-flags" , processListRegexFlagsOption , true, STAGE_ANY },
2900+ { "list-roles" , processListRolesOption , true, STAGE_ANY },
2901+ { "list-subparsers" , processListSubparsersOption , true, STAGE_ANY },
29282902 { "maxdepth" , processMaxRecursionDepthOption , true, STAGE_ANY },
29292903 { "optlib-dir" , processOptlibDir , false, STAGE_ANY },
29302904 { "options" , processOptionFile , false, STAGE_ANY },
@@ -2946,10 +2920,10 @@ static parametricOption ParametricOptions [] = {
29462920#ifdef HAVE_JANSSON
29472921 { "_interactive" , processInteractiveOption , true, STAGE_ANY },
29482922#endif
2949- { "_list-fielddef-flags" , processListFielddefFlagsOptions , true, STAGE_ANY },
2950- { "_list-kinddef-flags" , processListKinddefFlagsOptions , true, STAGE_ANY },
2951- { "_list-langdef-flags" , processListLangdefFlagsOptions , true, STAGE_ANY },
2952- { "_list-mtable-regex-flags" , processListMultitableRegexFlagsOptions , true, STAGE_ANY },
2923+ { "_list-fielddef-flags" , processListFielddefFlagsOption , true, STAGE_ANY },
2924+ { "_list-kinddef-flags" , processListKinddefFlagsOption , true, STAGE_ANY },
2925+ { "_list-langdef-flags" , processListLangdefFlagsOption , true, STAGE_ANY },
2926+ { "_list-mtable-regex-flags" , processListMultitableRegexFlagsOption , true, STAGE_ANY },
29532927 { "_list-operators" , processListOperators , true, STAGE_ANY },
29542928#ifdef DO_TRACING
29552929 { "_trace" , processTraceOption , false, STAGE_ANY },
0 commit comments