diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l index 8d979dc..e622c2b 100644 --- a/libs/wpp/ppl.l +++ b/libs/wpp/ppl.l @@ -261,6 +261,8 @@ static void add_string(const char *str, int len); static char *get_string(void); static void put_string(void); static int string_start(void); +static int end_single_quoted_string(void); +static int end_double_quoted_string(void); /* Macro functions */ static void push_macro(pp_entry_t *ppp); static macexpstackentry_t *top_macro(void); @@ -612,41 +614,9 @@ void pp_writestring(const char *format, ...) \" pp_incl_state.seen_junk++; new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_dqs); \' pp_incl_state.seen_junk++; new_string(); add_string(ppy_text, ppy_leng); yy_push_state(pp_sqs); [^"\\\n]+ add_string(ppy_text, ppy_leng); -\" { - add_string(ppy_text, ppy_leng); - yy_pop_state(); - switch(yy_current_state()) - { - case pp_pp: - case pp_define: - case pp_mbody: - case pp_inc: - case RCINCL: - if (yy_current_state()==RCINCL) yy_pop_state(); - ppy_lval.cptr = get_string(); - return tDQSTRING; - case pp_line: - ppy_lval.cptr = get_string(); - return tDQSTRING; - default: - put_string(); - } - } +\" add_string(ppy_text, ppy_leng); if(end_double_quoted_string()) return tDQSTRING; [^'\\\n]+ add_string(ppy_text, ppy_leng); -\' { - add_string(ppy_text, ppy_leng); - yy_pop_state(); - switch(yy_current_state()) - { - case pp_if: - case pp_define: - case pp_mbody: - ppy_lval.cptr = get_string(); - return tSQSTRING; - default: - put_string(); - } - } +\' add_string(ppy_text, ppy_leng); if(end_single_quoted_string()) return tSQSTRING; [^\>\\\n]+ add_string(ppy_text, ppy_leng); \> { add_string(ppy_text, ppy_leng); @@ -679,11 +649,23 @@ void pp_writestring(const char *format, ...) } } \\. add_string(ppy_text, ppy_leng); -\n { +\n { newline(1); add_string(ppy_text, ppy_leng); ppy_warning("Newline in string constant encountered (started line %d)", string_start()); } +\n { + newline(-1); + add_string(ppy_text, ppy_leng); + ppy_warning("Newline in double quoted string constant encountered (started line %d)", string_start()); + if(end_double_quoted_string()) return tDQSTRING; + } +\n { + newline(-1); + add_string(ppy_text, ppy_leng); + ppy_warning("Newline in single quoted string constant encountered (started line %d)", string_start()); + if(end_single_quoted_string()) return tSQSTRING; + } /* * Identifier scanning @@ -1285,6 +1267,45 @@ static int string_start(void) return str_startline; } +/* Returns 1 if single quoted string token should be returned */ +static int end_single_quoted_string(void) +{ + yy_pop_state(); + switch(yy_current_state()) + { + case pp_if: + case pp_define: + case pp_mbody: + ppy_lval.cptr = get_string(); + return 1; + default: + put_string(); + } + return 0; +} + +/* Returns 1 if double quoted string token should be returned */ +static int end_double_quoted_string(void) +{ + yy_pop_state(); + switch(yy_current_state()) + { + case pp_pp: + case pp_define: + case pp_mbody: + case pp_inc: + case RCINCL: + if (yy_current_state()==RCINCL) yy_pop_state(); + ppy_lval.cptr = get_string(); + return 1; + case pp_line: + ppy_lval.cptr = get_string(); + return 1; + default: + put_string(); + } + return 0; +} /* *-------------------------------------------------------------------------