diff --git a/src/scan.l b/src/scan.l index d5fe347e2..7444c22f8 100644 --- a/src/scan.l +++ b/src/scan.l @@ -102,20 +102,22 @@ extern const char *escaped_qstart, *escaped_qend; posix_compat = true; #define START_CODEBLOCK(x) do { \ - /* Emit the needed line directive... */\ - if (indented_code == false) { \ - linenum++; \ - line_directive_out(NULL, 1); \ - } \ - add_action(M4QSTART); \ - yy_push_state(CODEBLOCK); \ - if ((indented_code = x)) ACTION_ECHO; \ - } while(0) + /* Emit the needed line directive... */\ + if (indented_code == false) { \ + linenum++; \ + line_directive_out(NULL, 1); \ + } \ + add_action(M4QSTART); \ + yy_push_state(CODEBLOCK); \ + if ((indented_code = x)) ACTION_ECHO; \ +} while(0) + #define END_CODEBLOCK do { \ - yy_pop_state();\ + yy_pop_state();\ add_action(M4QEND); \ - if (!indented_code) line_directive_out(NULL, 0);\ - } while (0) + if (!indented_code) line_directive_out(NULL, 0);\ +} while (0) + %} %option caseless nodefault noreject stack noyy_top_state @@ -486,17 +488,18 @@ COMMENT,CODE_COMMENT>{ ^{WS} START_CODEBLOCK(true); /* indented code in prolog */ - ^{NOT_WS}.* { /* non-indented code */ - if ( bracelevel <= 0 ) - { /* not in %{ ... %} */ - yyless( 0 ); /* put it all back */ - yy_set_bol( 1 ); - mark_prolog(); - BEGIN(SECT2); - } - else - ACTION_ECHO; - } + ^{NOT_WS}.* { + /* non-indented code */ + if ( bracelevel <= 0 ) { + /* not in %{ ... %} */ + yyless( 0 ); /* put it all back */ + yy_set_bol( 1 ); + mark_prolog(); + BEGIN(SECT2); + } else { + START_CODEBLOCK(true); + } + } . ACTION_ECHO; {NL} ++linenum; ACTION_ECHO; @@ -903,30 +906,28 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ "/*" ACTION_ECHO; yy_push_state( CODE_COMMENT ); { - "reject" { - ACTION_ECHO; - CHECK_REJECT(yytext); - } - "yymore" { - ACTION_ECHO; - CHECK_YYMORE(yytext); - } + "reject" { + ACTION_ECHO; + CHECK_REJECT(yytext); + } + "yymore" { + ACTION_ECHO; + CHECK_YYMORE(yytext); + } } - . ACTION_ECHO; - {NL} { - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 || - (doing_codeblock && indented_code) ) - { - if ( doing_rule_action ) - add_action( "\tYY_BREAK]""]\n" ); - - doing_rule_action = doing_codeblock = false; - BEGIN(SECT2); - } - } + . ACTION_ECHO; + {NL} { + ++linenum; + ACTION_ECHO; + if (bracelevel == 0 || (doing_codeblock && indented_code)) { + if ( doing_rule_action ) + add_action( "\tYY_BREAK]""]\n" ); + + doing_rule_action = doing_codeblock = false; + BEGIN(SECT2); + } + } } @@ -935,38 +936,36 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ "{" ACTION_ECHO; ++bracelevel; "}" ACTION_ECHO; --bracelevel; [^[:alpha:]_{}\"'/\n\[\]]+ ACTION_ECHO; - [\[\]] ACTION_ECHO; - {NAME} ACTION_ECHO; + [\[\]] ACTION_ECHO; + {NAME} ACTION_ECHO; "'"([^\'\\\n]|\\.)"'" ACTION_ECHO; /* character constant */ "'" ACTION_ECHO; yy_push_state(CHARACTER_CONSTANT); \" ACTION_ECHO; BEGIN(ACTION_STRING); - {NL} { + {NL} { ++linenum; ACTION_ECHO; - if ( bracelevel == 0 ) - { + if (bracelevel == 0) { if ( doing_rule_action ) - add_action( "\tYY_BREAK]""]\n" ); + add_action( "\tYY_BREAK]""]\n" ); - doing_rule_action = false; - BEGIN(SECT2); - } - } - . ACTION_ECHO; + doing_rule_action = false; + BEGIN(SECT2); + } + } } { - [^\]\"\\\n\[MmY]+ ACTION_ECHO; + [^\]\"\\\n\[]+ ACTION_ECHO; \" ACTION_ECHO; BEGIN(ACTION); } { - [^\[\]\'\\\nMmY]+ ACTION_ECHO; - \' ACTION_ECHO; yy_pop_state(); + [^\[\]\'\\\n]+ ACTION_ECHO; + \' ACTION_ECHO; yy_pop_state(); } { \\. ACTION_ECHO; - {NL} ++linenum; ACTION_ECHO; - . ACTION_ECHO; + {NL} ++linenum; ACTION_ECHO; + [\]\['"] ACTION_ECHO; } <> { @@ -991,8 +990,8 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ { {M4QSTART} fputs(escaped_qstart, yyout); {M4QEND} fputs(escaped_qend, yyout); - [^\[\]\n]*(\n?) ECHO; - .|\n ECHO; + [^\[\]]* ECHO; + [][] ECHO; <> { sectnum = 0; yyterminate(); @@ -1001,8 +1000,8 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ { {M4QSTART} fprintf(yyout, "[""[%s]""]", escaped_qstart); {M4QEND} fprintf(yyout, "[""[%s]""]", escaped_qend); - [^\[\]\n]*(\n?) ECHO; - (.|\n) ECHO; + [^][]* ECHO; + [][] ECHO; <> { sectnum = 0; yyterminate();