Skip to content

Commit b9920be

Browse files
committed
Fix preprocessing of code with double backslash in string or char literal
Fixes processing#4903
1 parent 6a639c1 commit b9920be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

java/src/processing/mode/java/pdex/SourceUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ static public void scrubCommentsAndStrings(StringBuilder p) {
266266
for (int i = 0; i <= length; i++) {
267267
char ch = (i < length) ? p.charAt(i) : 0;
268268
char pch = (i == 0) ? 0 : p.charAt(i-1);
269+
// Get rid of double backslash immediately, otherwise
270+
// the second backslash incorrectly triggers a new escape sequence
271+
if (pch == '\\' && ch == '\\') {
272+
p.setCharAt(i-1, ' ');
273+
p.setCharAt(i, ' ');
274+
pch = ' ';
275+
ch = ' ';
276+
}
269277
switch (state) {
270278
case OUT:
271279
switch (ch) {

0 commit comments

Comments
 (0)