Skip to content

Commit 3a59e22

Browse files
committed
COMMON: fix backslash escape regression
1 parent f5f4773 commit 3a59e22

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

samples/distro-examples/tests/strings.bas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ if expect != seq(0, 2*pi, 360/15+1) then throw "SEQ error"
176176

177177
s="Hello\033There"
178178
if (27 != asc(mid(s, 6, 1))) then throw "err"
179-
s="This\033T\ha\t\The\"Other"
180-
rem ThisnT\ha\t\The"Other - non escaping '\' should appear verbatim
181-
if len(s) != 21 then throw "escape error"
182-
s="Hello\03There"
183-
if len(s) != 13 then throw "escape error"
179+
rem Non escaping '\' should appear verbatim
180+
s= "a\c\e"
181+
if mid(s, 2, 1) != "\\" then throw s
182+
if mid(s, 4, 1) != "\\" then throw s
183+

src/common/scan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,7 +3920,7 @@ char *comp_load(const char *file_name) {
39203920
}
39213921

39223922
const char *format_numeric_text(const char *str, char **output) {
3923-
const char *result = str;
3923+
const char *result = str + 1;
39243924
int value = 0;
39253925
int digits = 0;
39263926

@@ -3934,7 +3934,7 @@ const char *format_numeric_text(const char *str, char **output) {
39343934
**output = value;
39353935
} else {
39363936
**output = *str;
3937-
result = str;
3937+
result = str + 1;
39383938
}
39393939

39403940
(*output)++;
@@ -4151,7 +4151,7 @@ char *comp_format_text(const char *source) {
41514151
// new line auto-ends the quoted string
41524152
quotes = !quotes;
41534153
} else if (*p == '\\') {
4154-
p = format_numeric_text(p + 1, &ps);
4154+
p = format_numeric_text(p, &ps);
41554155
continue;
41564156
}
41574157
*ps++ = *p++;

0 commit comments

Comments
 (0)