From: Robert Schwebel <r.schwebel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/5] parser: use debug macros
Date: Mon, 1 Nov 2010 09:26:19 +0100 [thread overview]
Message-ID: <1288599979-3905-6-git-send-email-r.schwebel@pengutronix.de> (raw)
In-Reply-To: <1288599979-3905-1-git-send-email-r.schwebel@pengutronix.de>
Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
---
common/parser.c | 51 +++++++++++++++++++++++----------------------------
1 files changed, 23 insertions(+), 28 deletions(-)
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 @@ static int parse_line (char *line, char *argv[])
{
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 @@ static int parse_line (char *line, char *argv[])
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 @@ static int parse_line (char *line, char *argv[])
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 @@ static int parse_line (char *line, char *argv[])
}
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,12 +58,12 @@ static void process_macros (const char *input, char *output)
/* 1 = waiting for '(' or '{' */
/* 2 = waiting for ')' or '}' */
/* 3 = waiting for ''' */
-#ifdef DEBUG_PARSER
+#ifdef DEBUG
char *output_start = output;
+#endif
- printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input),
+ pr_debug("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input),
input);
-#endif
prev = '\0'; /* previous character */
@@ -153,10 +150,8 @@ static void process_macros (const char *input, char *output)
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 run_command (const char *cmd, int flag)
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 @@ int run_command (const char *cmd, int flag)
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 @@ int run_command (const char *cmd, int flag)
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);
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2010-11-01 8:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-01 8:26 Some patches Robert Schwebel
2010-11-01 8:26 ` [PATCH 1/5] devinfo: use subtree only with devinfo Robert Schwebel
2010-11-01 8:26 ` [PATCH 2/5] sandbox: use devfs functions only if defined Robert Schwebel
2010-11-01 8:26 ` [PATCH 3/5] digest: align menu Robert Schwebel
2010-11-01 8:26 ` [PATCH 4/5] allno: make simple shell the default Robert Schwebel
2010-11-01 10:44 ` Sascha Hauer
2010-11-01 11:01 ` Robert Schwebel
2010-11-01 8:26 ` Robert Schwebel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288599979-3905-6-git-send-email-r.schwebel@pengutronix.de \
--to=r.schwebel@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox