Skip to content

Conversation

@andyprice
Copy link
Contributor

This function increments the code index by 2 when a line continuation is found, additional to the loop increment, so it skips over the next character following a line continuation.

In shader code like

#define FUN_FUN(n)\
void fun1() { return;\
}\
void fun2() { return; }
FUN_FUN(1.0)

the first } will visibly get skipped, causing an error. The 'v' in 'void' will also get missed, but as the next 'o' is enough to decide to end the loop, that is less obvious.

Simplify consume_line_continuations() to remove the unnecessary offset parameter and the extra loop index variable, and increment index the right amount.

This function increments the code index by 2 when a line continuation is
found, additional to the loop increment, so it skips over the next
character following a line continuation.

In shader code like

   #define FUN_FUN(n)\
   void fun1() { return;\
   }\
   void fun2() { return; }
   FUN_FUN(1.0)

the first } will visibly get skipped, causing an error. The 'v' in
'void' will also get missed, but as the next 'o' is enough to decide to
end the loop, that is less obvious.

Simplify consume_line_continuations() to remove the unnecessary offset
parameter and the extra loop index variable, and increment index the
right amount.
@andyprice andyprice requested a review from a team as a code owner November 7, 2025 01:28
@AThousandShips AThousandShips changed the title Fix consume_line_continuations() skipping characters Fix ShaderPreprocessor.consume_line_continuations() skipping characters Nov 7, 2025
@AThousandShips AThousandShips added this to the 4.6 milestone Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants