Skip to content

Commit d0fc8b5

Browse files
committed
regression fixed
1 parent 089bbf5 commit d0fc8b5

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

basic

32 Bytes
Binary file not shown.

basic.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,20 @@ static struct value eval_function(const char *name, char **p)
11271127
arg = eval_expr(p);
11281128
skip_spaces(p);
11291129

1130-
/* Most functions expect exactly one argument in parentheses, but some
1131-
* (like MID$) can accept multiple. We leave ')' handling to each case.
1130+
/* Functions that accept multiple arguments (MID$, LEFT$, RIGHT$) parse
1131+
* their full argument list themselves and are responsible for consuming
1132+
* the closing ')'. For all other intrinsics we expect exactly one
1133+
* argument and consume ')' here so the caller resumes after it.
11321134
*/
1135+
if (code != FN_MID && code != FN_LEFT && code != FN_RIGHT) {
1136+
if (**p == ')') {
1137+
(*p)++;
1138+
} else {
1139+
runtime_error("Missing ')'");
1140+
return make_num(0.0);
1141+
}
1142+
skip_spaces(p);
1143+
}
11331144

11341145
switch (code) {
11351146
case FN_SIN:
@@ -1265,6 +1276,8 @@ static struct value eval_function(const char *name, char **p)
12651276
return make_str("\033[7m");
12661277
case 146: /* reverse off */
12671278
return make_str("\033[27m");
1279+
case 13: /* carriage return -> newline */
1280+
return make_str("\n");
12681281
/* Base colors */
12691282
case 144: /* black */
12701283
return make_str("\033[30m");

tests/print_semicolons.bas

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
REM Test PRINT / semicolon / escape-sequence behaviour
2+
3+
REM CASE 1: Plain text with and without semicolons
4+
PRINT "A"
5+
PRINT "B";
6+
PRINT "C"
7+
8+
REM CASE 2: Color escapes and names, all with semicolons
9+
PRINT CHR$(28);
10+
PRINT "RED";
11+
PRINT CHR$(5);
12+
13+
REM CASE 3: Color escapes and names, last one without semicolon
14+
PRINT CHR$(159);
15+
PRINT "CYAN"
16+
17+
REM CASE 4: Explicitly use carriage return
18+
PRINT "A";CHR$(13);"B";CHR$(13);"C"
19+
20+
END
21+

0 commit comments

Comments
 (0)