From: Michael Tremer Date: Sat, 12 Oct 2024 14:25:54 +0000 (+0000) Subject: parser: Make this less verbose X-Git-Tag: 0.9.30~1078 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb9cfb89fa50dd720da762cae1a09d0bd56f6ada;p=pakfire.git parser: Make this less verbose The parser generates so much logging output that I cannot find anything in the logs any more. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index 263001b7d..b7a4a0cb4 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -43,6 +43,9 @@ #include #include +// Enable to get more debugging output +//#define PAKFIRE_DEBUG_PARSER + struct pakfire_parser { struct pakfire_ctx* ctx; struct pakfire* pakfire; @@ -180,10 +183,12 @@ static struct pakfire_parser_declaration* pakfire_parser_get_declaration( if (!namespace) namespace = ""; +#ifdef PAKFIRE_DEBUG_PARSER if (*namespace) DEBUG(parser->pakfire, "%p: Looking up %s.%s\n", parser, namespace, name); else DEBUG(parser->pakfire, "%p: Looking up %s\n", parser, name); +#endif /* PAKFIRE_DEBUG_PARSER */ struct pakfire_parser_declaration* d; for (unsigned i = 0; i < parser->num_declarations; i++) { @@ -193,13 +198,17 @@ static struct pakfire_parser_declaration* pakfire_parser_get_declaration( // Return if namespace and name match if ((strcmp(d->namespace, namespace) == 0) && (strcmp(d->name, name) == 0)) { +#ifdef PAKFIRE_DEBUG_PARSER DEBUG(parser->pakfire, "%p: Found result = %s\n", parser, d->value); +#endif /* PAKFIRE_DEBUG_PARSER */ return d; } } +#ifdef PAKFIRE_DEBUG_PARSER DEBUG(parser->pakfire, "%p: Nothing found\n", parser); +#endif /* PAKFIRE_DEBUG_PARSER */ return NULL; } @@ -458,7 +467,9 @@ static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char** if (r) goto ERROR; +#ifdef PAKFIRE_DEBUG_PARSER DEBUG(parser->pakfire, "Expanding command: %s\n", command); +#endif /* PAKFIRE_DEBUG_PARSER */ // Update argv argv[2] = (const char*)command; @@ -564,7 +575,9 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser, if (r) goto ERROR; +#ifdef PAKFIRE_DEBUG_PARSER DEBUG(parser->pakfire, "Expanding variable: %s\n", variable); +#endif /* PAKFIRE_DEBUG_PARSER */ // Search for a declaration of this variable const char* repl = pakfire_parser_get_raw(parser, namespace, (const char*)variable); @@ -586,12 +599,14 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser, } } +#ifdef PAKFIRE_DEBUG_PARSER // What is its value? if (repl) { DEBUG(parser->pakfire, "Replacing %%{%s} with '%s'\n", variable, repl); } else { DEBUG(parser->pakfire, "Replacing %%{%s} with an empty string\n", variable); } +#endif /* PAKFIRE_DEBUG_PARSER */ // Replace all occurrences char* tmp = pakfire_string_replace(*buffer, (const char*)pattern, (repl) ? repl : "");