Skip to content

Commit e5b1a91

Browse files
authored
Merge pull request #108 from chrisws/12_20
12 20
2 parents aae8feb + 5ae7b9d commit e5b1a91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1112
-714
lines changed

ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2020-12-19 (12.20)
2+
SDL: Update editor popup appearance
3+
4+
2020-11-19 (12.20)
5+
COMMON: Fix to allow multiple modules and units within saem program
6+
7+
2020-11-13 (12.20)
8+
ANDROID: add option to preserve user data when app uninstalled
9+
10+
2020-11-10 (12.20)
11+
ANDROID: change path label when displaying project folder
12+
COMMON: ensure INT datatype is always 64 bits
13+
14+
2020-11-01 (12.20)
15+
CONSOLE: give error when file not found
16+
17+
2020-10-31 (12.20)
18+
SDL: implemented restoring the cursor position
19+
20+
2020-10-29 (12.20)
21+
COMMON: Implemented c-styles escape sequences
22+
23+
2020-10-27 (12.20)
24+
COMMON: add support for inline assignment of export variables
25+
COMMON: add support for unit alias names
26+
27+
2020-10-21 (12.20)
28+
ANDROID: upgrade to target android 29
29+
30+
2020-10-21 (12.20)
31+
COMMON: Fix to allow c-modules to be called from units
32+
133
2020-07-16 (12.19)
234
COMMON: Fix 'Print #' on Windows to use Windows line endings
335

autogen.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# This file is part of SmallBASIC
22
#
3-
# Copyright(C) 2001-2015 Chris Warren-Smith.
3+
# Copyright(C) 2001-2020 Chris Warren-Smith.
44
#
55
# This program is distributed under the terms of the GPL v2.0 or later
66
# Download the GNU Public License (GPL) from www.gnu.org
77
#
88

99
ln -sf README.md README
1010

11-
git submodule update --
11+
git submodule init
12+
git submodule update
1213

1314
pkg-config --version > /dev/null || echo "Please install pkg-config"
1415

configure.ac

Lines changed: 2 additions & 9 deletions
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.19])
10+
AC_INIT([smallbasic], [12.20])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET
@@ -59,8 +59,6 @@ function checkForWindows() {
5959
*darwin*)
6060
;;
6161
*)
62-
dnl backlinking support for modules
63-
LDFLAGS="${LDFLAGS} -export-dynamic"
6462
esac
6563
AM_CONDITIONAL(WITH_WIN32, test x"$win32" = "xyes")
6664
}
@@ -219,7 +217,6 @@ function buildSDL() {
219217
AC_DEFINE(_SDL, 1, [Defined when building SDL version])
220218
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
221219
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
222-
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
223220
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
224221

225222
BUILD_SUBDIRS="src/common src/platform/sdl"
@@ -235,7 +232,6 @@ function buildAndroid() {
235232
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
236233
AC_DEFINE(_ANDROID, 1, [Defined for Android build.])
237234
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
238-
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
239235
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
240236

241237
BUILD_SUBDIRS="src/platform/android"
@@ -260,7 +256,6 @@ function buildConsole() {
260256
)
261257

262258
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, test $win32 = yes)
263-
AC_DEFINE(BUILD_CONSOLE, 1, [Building a console based system.])
264259

265260
if test $win32 = yes; then
266261
dnl test whether to build using mingw
@@ -287,7 +282,7 @@ function buildConsole() {
287282
TARGET="Building Cygwin MinGW console version."
288283
AC_DEFINE(__MINGW32__, 1, [as above])
289284
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
290-
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -mconsole -lmingw32 -lwsock32 -lws2_32 -static-libgcc"
285+
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -mconsole -lwsock32 -lws2_32 -static-libgcc"
291286
BUILD_SUBDIRS="src/common src/platform/console"
292287
fi
293288
AC_DEFINE(_Win32, 1, [Windows build])
@@ -320,7 +315,6 @@ function buildWeb() {
320315
BUILD_SUBDIRS="src/common src/platform/web"
321316
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, false)
322317
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
323-
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
324318
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
325319
AC_DEFINE(USE_TERM_IO, 0, [dont use the termios library.])
326320
AC_DEFINE(IMPL_DEV_ENV, 1, [Driver implements dev_env funcs])
@@ -374,7 +368,6 @@ function buildFLTK() {
374368
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
375369
AC_DEFINE(_FLTK, 1, [Defined for FLTK build.])
376370
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
377-
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
378371
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
379372

380373
BUILD_SUBDIRS="src/common src/platform/fltk"

debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
smallbasic (12.20) unstable; urgency=low
2+
* Various see web site
3+
4+
-- Chris Warren-Smith <[email protected]> Fri, 16 Oct 2020 09:45:25 +1000
5+
16
smallbasic (0.12.19) unstable; urgency=low
27
* Various see web site
38

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
' example: using a unit, 0.9
22
'
33

4-
Import Tau, PreDef
4+
Import Tau as taz, PreDef
55

6-
? "Tau's exported variable: ", tau.expvar
7-
? "Function fooF : ", tau.fooF("Hi")
6+
? "Tau's exported variable: ", taz.expvar
7+
? "Function fooF : ", taz.fooF("Hi")
88
? "Procedure fooP : "
9-
tau.fooP "Hi"
9+
taz.fooP "Hi"
1010

1111
' reverse var-update
12-
tau.expvar = "message from main"
13-
tau.print_expvar
14-
? tau.expvar
15-
tau.build_ta
16-
? tau.ta
12+
taz.expvar = "message from main"
13+
taz.print_expvar
14+
? taz.expvar
15+
taz.build_ta
16+
? taz.ta
1717
'tau.cerr
1818

1919
rem check system-variables
@@ -31,12 +31,19 @@ foyer.name= "my name is PI"
3131
? "end"
3232

3333
for i = 0 to 1000
34-
tau.addRoom(foyer,x)
35-
jj = tau.calcRoomSize(foyer,x)
34+
taz.addRoom(foyer,x)
35+
jj = taz.calcRoomSize(foyer,x)
3636
next i
3737

3838
sub addRoom(the_thing, d)
3939
print the_thing.name, d
4040
end
4141

4242
addRoom(foyer,x)
43+
44+
if (Taz.LIGHTGRAY != rgb(200, 200, 200)) then
45+
print "Error importing inline assigned export variable"
46+
endif
47+
if (Taz.YELLOW != rgb(253, 249, 0)) then
48+
print "Error importing inline assigned export variable"
49+
endif

samples/distro-examples/tests/strings.bas

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ if expect != seq(0, 2*pi, 360/15+1) then throw "SEQ error"
177177
s="Hello\033There"
178178
if (27 != asc(mid(s, 6, 1))) then throw "err"
179179
rem Non escaping '\' should appear verbatim
180-
s= "a\c\e"
180+
s= "a\\c\\e"
181181
if mid(s, 2, 1) != "\\" then throw s
182182
if mid(s, 4, 1) != "\\" then throw s
183183

@@ -189,3 +189,12 @@ for c in s1
189189
next c
190190
if (s1 <> s2) then throw s2
191191

192+
if (asc("\a") != 7) then throw "err1"
193+
if (asc("\b") != 8) then throw "err2"
194+
if (asc("\e") != 27) then throw "err3"
195+
if (asc("\f") != 12) then throw "err4"
196+
if (asc("\n") != 10) then throw "err5"
197+
if (asc("\r") != 13) then throw "err6"
198+
if (asc("\t") != 9) then throw "err7"
199+
if (asc("\v") != 11) then throw "err8"
200+

samples/distro-examples/tests/tau.bas

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ Import TauChild
33

44
Export expvar, foof, foop
55
export addRoom,calcRoomSize
6-
export print_expvar, ta, build_ta, cerr
6+
export print_expvar, ta, build_ta, cerr
77

88
expvar = "Tau's exported variable"
99

10+
export const LIGHTGRAY = rgb(200, 200, 200)
11+
export const GRAY = rgb(130, 130, 130)
12+
export const DARKGRAY = rgb(80, 80, 80), const YELLOW = rgb(253, 249, 0)
13+
1014
func fooF(x)
1115
foof = "Tau's fooF("+x+") is here"
1216
end

src/common/bc.c

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,36 @@
99

1010
#include "common/bc.h"
1111
#include "common/smbas.h"
12+
#include "common/str.h"
13+
14+
/*
15+
* string escape codes
16+
*/
17+
const char escapes[][2] = {
18+
{'a', 0x07},
19+
{'b', 0x08},
20+
{'e', 0x1b},
21+
{'f', 0x0c},
22+
{'n', 0x0a},
23+
{'r', 0x0d},
24+
{'t', 0x09},
25+
{'v', 0x0b},
26+
};
27+
28+
/*
29+
* whether the character is an escape
30+
*/
31+
int bc_is_escape(char c, char *value) {
32+
int len = sizeof(escapes) / sizeof(escapes[0]);
33+
int result = 0;
34+
for (int i = 0; i < len && !result; i++) {
35+
if (escapes[i][0] == c) {
36+
*value = escapes[i][1];
37+
result = 1;
38+
}
39+
}
40+
return result;
41+
}
1242

1343
/*
1444
* Create a bytecode segment
@@ -182,23 +212,18 @@ void bc_add_strn(bc_t *bc, const char *str, int len) {
182212
* returns a pointer of src to the next "element"
183213
*/
184214
char *bc_store_string(bc_t *bc, char *src) {
185-
char *p = src;
186-
char *np = NULL;
215+
// skip past opening quotes
216+
char *p = src + 1;
187217
char *base = src + 1;
188-
int len = 0;
218+
char escape = 0;
219+
cstr cs;
220+
cstr_init(&cs, 5);
189221

190-
// skip past opening quotes
191-
p++;
192222
while (*p) {
193223
if ((*p == '\\' && ((*(p + 1) == '\"') || *(p + 1) == '\\'))
194224
|| *p == V_JOIN_LINE) {
195225
// escaped quote " or escaped escape
196-
int seglen = p - base;
197-
np = np ? realloc(np, len + seglen + 1) : malloc(seglen + 1);
198-
strncpy(np + len, base, seglen);
199-
// add next segment
200-
len += seglen;
201-
np[len] = 0;
226+
cstr_append_i(&cs, base, p - base);
202227

203228
if (*p == V_JOIN_LINE) {
204229
// skip null newline
@@ -211,6 +236,11 @@ char *bc_store_string(bc_t *bc, char *src) {
211236

212237
// include " (or \ ) in next segment
213238
base = ++p;
239+
} else if (*p == '\\' && bc_is_escape(*(p + 1), &escape)) {
240+
char code[] = {escape, '\0'};
241+
cstr_append_i(&cs, base, p - base);
242+
cstr_append_i(&cs, code, 1);
243+
base = (++p) + 1;
214244
} else if (*p == V_QUOTE) {
215245
// revert hidden quote
216246
*p = '\"';
@@ -220,17 +250,14 @@ char *bc_store_string(bc_t *bc, char *src) {
220250
*p = '\n';
221251
} else if (*p == '\"') {
222252
// end of string detected
223-
int seglen = p - base;
224-
np = np ? realloc(np, len + seglen + 1) : malloc(seglen + 1);
225-
memcpy(np + len, base, seglen);
226-
bc_add_strn(bc, np, len + seglen);
227-
free(np);
253+
cstr_append_i(&cs, base, p - base);
254+
bc_add_strn(bc, cs.buf, cs.length);
228255
p++;
229-
return p;
256+
break;
230257
}
231258
p++;
232259
}
233-
free(np);
260+
free(cs.buf);
234261
return p;
235262
}
236263

0 commit comments

Comments
 (0)