diff --git a/common/parser.c b/common/parser.c index 97e354b..fd578c7 100644 --- a/common/parser.c +++ b/common/parser.c @@ -6,9 +6,8 @@ { int nargs = 0; -#ifdef DEBUG_PARSER - printf ("parse_line: \"%s\"\n", line); -#endif + pr_debug("parse_line: \"%s\"\n", line); + while (nargs < CONFIG_MAXARGS) { /* skip any white space */ @@ -18,9 +17,9 @@ if (*line == '\0') { /* end of line, no more args */ argv[nargs] = NULL; -#ifdef DEBUG_PARSER - printf ("parse_line: nargs=%d\n", nargs); -#endif + + pr_debug("parse_line: nargs=%d\n", nargs); + return (nargs); } @@ -33,9 +32,9 @@ if (*line == '\0') { /* end of line, no more args */ argv[nargs] = NULL; -#ifdef DEBUG_PARSER - printf ("parse_line: nargs=%d\n", nargs); -#endif + + pr_debug("parse_line: nargs=%d\n", nargs); + return (nargs); } @@ -43,10 +42,8 @@ } printf ("** Too many args (max. %d) **\n", CONFIG_MAXARGS); + pr_debug("parse_line: nargs=%d\n", nargs); -#ifdef DEBUG_PARSER - printf ("parse_line: nargs=%d\n", nargs); -#endif return (nargs); } @@ -61,13 +58,13 @@ /* 1 = waiting for '(' or '{' */ /* 2 = waiting for ')' or '}' */ /* 3 = waiting for ''' */ -#ifdef DEBUG_PARSER +#ifdef DEBUG char *output_start = output; - - printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input), - input); #endif + pr_debug("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input), + input); + prev = '\0'; /* previous character */ while (inputcnt && outputcnt) { @@ -153,10 +150,8 @@ if (outputcnt) *output = 0; -#ifdef DEBUG_PARSER - printf ("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n", + pr_debug("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n", strlen (output_start), output_start); -#endif } /**************************************************************************** @@ -185,8 +180,8 @@ int argc, inquotes; int rc = 0; -#ifdef DEBUG_PARSER - printf ("[RUN_COMMAND] cmd[%p]=\"", cmd); +#ifdef DEBUG + pr_debug("[RUN_COMMAND] cmd[%p]=\"", cmd); puts (cmd ? cmd : "NULL"); /* use puts - string may be loooong */ puts ("\"\n"); #endif @@ -202,13 +197,13 @@ strcpy (cmdbuf, cmd); - /* Process separators and check for invalid + /* + * Process separators and check for invalid * repeatable commands */ -#ifdef DEBUG_PARSER - printf ("[PROCESS_SEPARATORS] %s\n", cmd); -#endif + pr_debug("[PROCESS_SEPARATORS] %s\n", cmd); + while (*str) { /* @@ -235,11 +230,11 @@ str = sep + 1; /* start of command for next pass */ *sep = '\0'; } - else + else { str = sep; /* no more commands for next pass */ -#ifdef DEBUG_PARSER - printf ("token: \"%s\"\n", token); -#endif + } + + pr_debug("token: \"%s\"\n", token); /* find macros in this token and replace them */ process_macros (token, finaltoken);