<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body>
Oh. Thanks! This is embarrassing. I have no idea how did I manage to
miss it. Line continuations are so rare that only two games in my
shader-db use them -- Talos Principle and Serious Sam (both use
Serious Engine). And neither of them hit this condition. I probably
need to fuzz this thing or something.<br>
<br>
I'll send fixup.<br>
<br>
<div class="moz-cite-prefix">07.01.2017 22:53, Gustaw Smolarczyk
пишет:<br>
</div>
<blockquote
cite="mid:CAJN263KyX6SOfGz+LqHjBvfSFRomA1LoKsukyV0=i7Qv2ptZTg@mail.gmail.com"
type="cite">
<div dir="auto">
<div>7 sty 2017 20:04 "Vladislav Egorov" <<a
moz-do-not-send="true" href="mailto:vegorov180@gmail.com"><a class="moz-txt-link-abbreviated" href="mailto:vegorov180@gmail.com">vegorov180@gmail.com</a></a>>
napisał(a):<br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">To
find newlines the line continuations removal pass uses
strchr()<br>
twice -- first time to find '\n', second time to find
'\r'. Now,<br>
if the shader uses Unix line separators '\n', the file
could contain<br>
no '\r' at all, so each time it will scan to the end of
the shader.<br>
Use strpbrk() standard function instead that was
specifically created<br>
to search many characters at once.<br>
---<br>
src/compiler/glsl/glcpp/pp.c | 28
++++++++--------------------<br>
1 file changed, 8 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/glcpp/pp.c
b/src/compiler/glsl/glcpp/pp.c<br>
index c196868..c4c0196 100644<br>
--- a/src/compiler/glsl/glcpp/pp.c<br>
+++ b/src/compiler/glsl/glcpp/pp.c<br>
@@ -231,7 +231,6 @@ remove_line_continuations(<wbr>glcpp_parser_t
*ctx, const char *shader)<br>
{<br>
struct string_buffer sb;<br>
const char *backslash, *newline, *search_start;<br>
- const char *cr, *lf;<br>
char newline_separator[3];<br>
int collapsed_newlines = 0;<br>
int separator_len;<br>
@@ -266,23 +265,19 @@ remove_line_continuations(<wbr>glcpp_parser_t
*ctx, const char *shader)<br>
* examining the first encountered newline
terminator, and using the<br>
* same terminator for any newlines we insert.<br>
*/<br>
- cr = strchr(search_start, '\r');<br>
- lf = strchr(search_start, '\n');<br>
+ newline = strpbrk(search_start, "\r\n");<br>
<br>
newline_separator[0] = '\n';<br>
newline_separator[1] = '\0';<br>
newline_separator[2] = '\0';<br>
<br>
- if (cr == NULL) {<br>
+ if (newline == NULL) {<br>
/* Nothing to do. */<br>
- } else if (lf == NULL) {<br>
- newline_separator[0] = '\r';<br>
- } else if (lf == cr + 1) {<br>
- newline_separator[0] = '\r';<br>
- newline_separator[1] = '\n';<br>
- } else if (cr == lf + 1) {<br>
- newline_separator[0] = '\n';<br>
- newline_separator[1] = '\r';<br>
+ } else if (newline[1] == '\n' || newline[1] ==
'\r') {<br>
</blockquote>
</div>
</div>
</div>
<div dir="auto">What if we have \n\n ? Won't it match it as a
single newline?</div>
<div dir="auto"><br>
</div>
<div dir="auto">Regards,</div>
<div dir="auto">Gustaw</div>
</div>
</blockquote>
<br>
</body>
</html>