[apparmor] [patch 11/26] A few fixes/improvements to the lexer debug output
john.johansen at canonical.com
john.johansen at canonical.com
Tue Apr 15 17:22:18 UTC 2014
Signed-off-by: John Johansen <john.johansen at canonical.com>
---
parser/parser_lex.l | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
--- 2.9-test.orig/parser/parser_lex.l
+++ 2.9-test/parser/parser_lex.l
@@ -52,7 +52,7 @@
/* #define DEBUG */
#ifdef DEBUG
static int yy_top_state(void);
-#define PDEBUG(fmt, args...) printf("Lexer (Line %d) (state %s): " fmt, current_lineno, state_names[YY_START].c_str(), ## args)
+#define PDEBUG(fmt, args...) fprintf(stderr, "Lexer (Line %d) (state %s): " fmt, current_lineno, state_names[YY_START].c_str(), ## args)
#else
#define PDEBUG(fmt, args...) /* Do nothing */
#endif
@@ -70,7 +70,7 @@
#define RETURN_TOKEN(X) \
do { \
- DUMP_AND_DEBUG("Matched: %s\n", yytext); \
+ DUMP_AND_DEBUG("Matched: '%s' Returning(%s)\n", yytext, #X); \
return (X); \
} while (0)
@@ -276,12 +276,12 @@
char *filename = strndup(yytext, yyleng - 1);
include_filename(filename + 1, *filename == '<');
free(filename);
- yy_pop_state();
+ POP();
}
[^\<\>\" \t\n]+ { /* filename */
include_filename(yytext, 0);
- yy_pop_state();
+ POP();
}
}
@@ -425,7 +425,7 @@
\r?\n {
DUMP_PREPROCESS;
current_lineno++;
- yy_pop_state();
+ POP();
}
}
@@ -469,8 +469,7 @@
write { RETURN_TOKEN(TOK_WRITE); }
eavesdrop { RETURN_TOKEN(TOK_EAVESDROP); }
{OPEN_PAREN} {
- yy_push_state(LIST_VAL_MODE);
- RETURN_TOKEN(TOK_OPENPAREN);
+ PUSH_AND_RETURN(LIST_VAL_MODE, TOK_OPENPAREN);
}
(r|w|rw|wr)/([[:space:],]) {
yylval.mode = strdup(yytext);
@@ -488,8 +487,8 @@
}
#include/.*\r?\n {
- /* Don't use push here as we don't want #include echoed out. It needs
- * to be handled specially
+ /* Don't use PUSH() macro here as we don't want #include echoed out.
+ * It needs to be handled specially
*/
yy_push_state(INCLUDE);
}
@@ -576,7 +575,7 @@
<INITIAL,NETWORK_MODE,RLIMIT_MODE,MOUNT_MODE,DBUS_MODE>{
{END_OF_RULE} {
if (YY_START != INITIAL)
- yy_pop_state();
+ POP();
RETURN_TOKEN(TOK_END_OF_RULE);
}
More information about the AppArmor
mailing list