Re: wpp: Stop parsing single and double quoted string constants after a first newline character.
Il 14 marzo 2012 23:02, Józef Kucia <joseph.kucia(a)gmail.com> ha scritto:
@@ -679,11 +649,23 @@ void pp_writestring(const char *format, ...) } } <pp_iqs,pp_dqs,pp_sqs>\\. add_string(ppy_text, ppy_leng); -<pp_iqs,pp_dqs,pp_sqs>\n { +<pp_iqs>\n { newline(1); add_string(ppy_text, ppy_leng); ppy_warning("Newline in string constant encountered (started line %d)", string_start()); } +<pp_dqs>\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; + } +<pp_sqs>\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
I'm not sure this is legit. If I'm reading the C spec correctly, a character or string constant can be only terminated by ' or " respectively. Although it can't contain unescaped newline characters either, so it looks like we are actually in the realm of "undefined behavior". So, I guess this change will only have any effect on non-standard complying sources, and in the specific case of asm-style comments, it brings us the behavior we want. On the other hand, it also actually turns an error (unexpected end of file) into a warning, which may be troublesome in general. I hope it doesn't break anything else... (You can take this email as "okay for me, but someone else may know better")
On Thu, Mar 15, 2012 at 12:55 PM, Matteo Bruni <matteo.mystral(a)gmail.com> wrote:
So, I guess this change will only have any effect on non-standard complying sources, and in the specific case of asm-style comments, it brings us the behavior we want. On the other hand, it also actually turns an error (unexpected end of file) into a warning, which may be troublesome in general. I hope it doesn't break anything else...
I guess the safest way is to make it optional. As a result, the old behavior will be kept for other users of wpp and only D3DCompiler will be affected by this change.
Please forget this patch. It's superseded by another.
participants (2)
-
Józef Kucia -
Matteo Bruni