Skip to content

Commit 602f875

Browse files
authored
Merge pull request #113 from chrisws/12_21
12 21
2 parents fd6252a + 5ea5c44 commit 602f875

File tree

27 files changed

+312
-206
lines changed

27 files changed

+312
-206
lines changed

ChangeLog

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
2021-04-02 (12.21)
2+
ANDROID: Added range checking for the web services port
3+
4+
2021-03-28 (12.21)
5+
COMMON: Fix CIRCLE command to ensure radius uses the WINDOW coordinate system
6+
COMMON: Fix to ensure the default VIEW is maintained during resizing
7+
8+
2021-03-21 (12.21)
9+
COMMON: Fix square bracket field access issue
10+
11+
2021-02-23 (12.21)
12+
COMMON: Fix crash when line length limit exceeded
13+
14+
2021-01-18 (12.21)
15+
COMMON: Handle octal escapes correctly
16+
117
2020-12-19 (12.20)
218
SDL: Update editor popup appearance
319

420
2020-11-19 (12.20)
5-
COMMON: Fix to allow multiple modules and units within saem program
21+
COMMON: Fix to allow multiple modules and units within same program
622

723
2020-11-13 (12.20)
824
ANDROID: add option to preserve user data when app uninstalled

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
77
dnl Download the GNU Public License (GPL) from www.gnu.org
88
dnl
99

10-
AC_INIT([smallbasic], [12.20])
10+
AC_INIT([smallbasic], [12.21])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET

samples/distro-examples/tests/array.bas

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,17 @@ next i
313313
m[1,2,3,4,5,6]=999
314314
if (999 <> m[1,2,3,4,5,6]) then
315315
throw "e"
316-
endif
316+
endif
317+
318+
REM test that "[0, 0]" in anims[0].framePoses[0, 0].translation is not scanned as a codearray
319+
dim amims(0 to 1)
320+
dim j(0 to 1, 0 to 1)
321+
j[0, 0].translation = [1,2,3]
322+
k.framePoses = j
323+
anims << k
324+
sub xfunc(argx)
325+
local xx=[1,2,3]
326+
if xx!=argx then throw "err"
327+
end
328+
z=anims[0].framePoses[0, 0].translation
329+
xfunc(anims[0].framePoses[0, 0].translation)

src/common/bc.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ int bc_is_escape(char c, char *value) {
4040
return result;
4141
}
4242

43+
/*
44+
* whether the character is octal escape
45+
*/
46+
int bc_is_octal(char *str, char *output) {
47+
char *next = str + 1;
48+
int result = 0;
49+
int digits = 0;
50+
int value = 0;
51+
52+
while (isdigit(*next) && digits < 4) {
53+
value = (value << 3) + (*next - '0');
54+
digits++;
55+
next++;
56+
}
57+
if (digits == 3 && value < 256) {
58+
*output = value;
59+
result = 1;
60+
}
61+
return result;
62+
}
63+
4364
/*
4465
* Create a bytecode segment
4566
*/
@@ -240,7 +261,15 @@ char *bc_store_string(bc_t *bc, char *src) {
240261
char code[] = {escape, '\0'};
241262
cstr_append_i(&cs, base, p - base);
242263
cstr_append_i(&cs, code, 1);
264+
// skip single escape character
243265
base = (++p) + 1;
266+
} else if (*p == '\\' && bc_is_octal(p, &escape)) {
267+
char code[] = {escape, '\0'};
268+
cstr_append_i(&cs, base, p - base);
269+
cstr_append_i(&cs, code, 1);
270+
// skip octal digits
271+
p += 3;
272+
base = p + 1;
244273
} else if (*p == V_QUOTE) {
245274
// revert hidden quote
246275
*p = '\"';

src/common/device.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,13 @@ void panic(const char *fmt, ...);
10691069
*/
10701070
void lwrite(const char *buf);
10711071

1072+
/**
1073+
* @ingroup dev_f
1074+
*
1075+
* resize the window coordinate system
1076+
*/
1077+
void dev_resize(int width, int height);
1078+
10721079
#if defined(__cplusplus)
10731080
}
10741081
#endif

src/common/scan.c

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,10 @@ int comp_is_code_array(bc_t *bc, char *p) {
11101110
}
11111111
p++;
11121112
}
1113+
if (*p == '.') {
1114+
// a[1].foo is not a code array
1115+
result = 0;
1116+
}
11131117
if (!count) {
11141118
result = 1;
11151119
}
@@ -1331,10 +1335,11 @@ void comp_expression(char *expr, byte no_parser) {
13311335
// string
13321336
ptr = bc_store_string(&bc, ptr);
13331337
} else if (*ptr == '[') {
1334-
// code-defined array
1338+
// potential code-defined array
13351339
ptr++;
13361340
level++;
1337-
if (comp_is_code_array(&bc, ptr)) {
1341+
// can't be a code array if this is already part of a variable
1342+
if ((bc.size == 0 || bc.ptr[0] != kwTYPE_VAR) && comp_is_code_array(&bc, ptr)) {
13381343
// otherwise treat as array index
13391344
bc_add_fcode(&bc, kwCODEARRAY);
13401345
}
@@ -3942,29 +3947,6 @@ char *comp_load(const char *file_name) {
39423947
return buf;
39433948
}
39443949

3945-
const char *format_numeric_text(const char *str, char **output) {
3946-
const char *result = str + 1;
3947-
int value = 0;
3948-
int digits = 0;
3949-
3950-
while (isdigit(*result)) {
3951-
value = (value << 3) + (*result - '0');
3952-
digits++;
3953-
result++;
3954-
}
3955-
3956-
if (digits == 3 && value > V_JOIN_LINE && value < 256) {
3957-
**output = value;
3958-
} else {
3959-
**output = *str;
3960-
result = str + 1;
3961-
}
3962-
3963-
(*output)++;
3964-
3965-
return result;
3966-
}
3967-
39683950
/**
39693951
* format source-code text
39703952
*
@@ -4173,9 +4155,6 @@ char *comp_format_text(const char *source) {
41734155
}
41744156
// new line auto-ends the quoted string
41754157
quotes = !quotes;
4176-
} else if (*p == '\\') {
4177-
p = format_numeric_text(p, &ps);
4178-
continue;
41794158
}
41804159
*ps++ = *p++;
41814160
}
@@ -4677,6 +4656,7 @@ int comp_pass1(const char *section, const char *text) {
46774656

46784657
char *ps = new_text;
46794658
char *p = ps;
4659+
int line_size = 0;
46804660
while (*p) {
46814661
if (*p == '\n') {
46824662
// proceed
@@ -4695,11 +4675,17 @@ int comp_pass1(const char *section, const char *text) {
46954675
break;
46964676
}
46974677
ps = p + 1;
4678+
line_size = 0;
46984679
}
46994680
if (comp_error) {
47004681
break;
47014682
}
47024683
p++;
4684+
if (++line_size >= SB_SOURCELINE_SIZE) {
4685+
*p = '\0';
4686+
sc_raise(ERR_LINE_LENGTH, p - 50);
4687+
break;
4688+
}
47034689
}
47044690
}
47054691

0 commit comments

Comments
 (0)