Skip to content

Commit a6db1a0

Browse files
authored
Merge pull request #86 from chrisws/0_12_17
0 12 17
2 parents 8db539b + efe04d2 commit a6db1a0

Some content is hidden

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

74 files changed

+901
-10351
lines changed

.gitmodules

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[submodule "src/lib/miniaudio"]
2+
path = src/lib/miniaudio
3+
url = https://github.com/dr-soft/miniaudio.git
4+
[submodule "src/lib/stb"]
5+
path = src/lib/stb
6+
url = https://github.com/nothings/stb.git
7+
[submodule "src/lib/lodepng"]
8+
path = src/lib/lodepng
9+
url = https://github.com/lvandeve/lodepng.git
10+
ignore = untracked
11+
[submodule "src/lib/jsmn"]
12+
path = src/lib/jsmn
13+
url = https://github.com/zserge/jsmn.git

ChangeLog

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
2019-08-23 (0.12.15)
1+
2019-12-21 (0.12.17)
2+
SDL: fix issue #81 - numlock handling
3+
4+
2019-12-15 (0.12.17)
5+
FLTK: add online samples command
6+
FLTK: fix tab resizing
7+
8+
2019-12-07 (0.12.17)
9+
FLTK: fix memory leaks
10+
FLTK: implement audio
11+
UI: add menu control key indicators
12+
13+
2019-11-30 (0.12.17)
14+
ANDROID: fix module access in newer android versions.
15+
UI: code cleanup
16+
17+
2019-11-30 (0.12.17)
18+
FLTK: fix color display
19+
FLTK: add clear console command
20+
COMMON: fix dirwalk error handling
21+
22+
2019-11-23 (0.12.17)
23+
COMMON: Fix select case by func. Closes #83
24+
COMMON: update dependencies
25+
26+
2019-08-23 (0.12.16)
227
ANDROID: fix ChromeOS crash when restarting over existing instance
328

429
2019-08-19 (0.12.15)

Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ covcheck-android:
3636

3737
clangcheck:
3838
(make clean -s && \
39+
scan-build ./configure && \
40+
scan-build -o scan make -s)
41+
42+
clangcheck-fltk:
43+
(make clean -s && \
44+
scan-build ./configure --enable-fltk && \
45+
scan-build -o scan make -s)
46+
47+
clangcheck-sdl:
48+
(make clean -s && \
3949
scan-build ./configure --enable-sdl && \
4050
scan-build -o scan make -s)
4151

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
For news please visit smallbasic.sourceforge.net
1+
For news please visit https://smallbasic.github.io

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
SmallBASIC is a fast and easy to learn BASIC language interpreter ideal for everyday calculations, scripts and prototypes. SmallBASIC includes trigonometric, matrices and algebra functions, a built in IDE, a powerful string library, system, sound, and graphic commands along with structured programming syntax
22

3+
### Initialise dependencies
4+
5+
```
6+
$ git submodule update --init
7+
```
8+
39
## Building the SDL version
410

511
Initial setup on linux

autogen.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
ln -sf README.md README
1010

11+
git submodule update --
12+
1113
pkg-config --version > /dev/null || echo "Please install pkg-config"
1214

1315
rm -f acinclude.m4

configure.ac

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

1313
AC_CANONICAL_TARGET
@@ -285,7 +285,7 @@ function buildConsole() {
285285
TARGET="Building Cygwin MinGW console version."
286286
AC_DEFINE(__MINGW32__, 1, [as above])
287287
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
288-
PACKAGE_LIBS="${PACKAGE_LIBS} -mconsole -lmingw32 -lwsock32 -lws2_32 -static-libgcc"
288+
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -mconsole -lmingw32 -lwsock32 -lws2_32 -static-libgcc"
289289
BUILD_SUBDIRS="src/common src/platform/console"
290290
fi
291291
AC_DEFINE(_Win32, 1, [Windows build])
@@ -352,6 +352,8 @@ function buildFLTK() {
352352
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} -mms-bitfields"
353353
PACKAGE_LIBS="-Wl,-Bstatic ${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
354354
AC_DEFINE(_Win32, 1, [Windows build])
355+
AC_DEFINE(_USE_MATH_DEFINES, 1, [for M_PI in math.h])
356+
AC_DEFINE(realpath(F, R), _fullpath(R, F, PATH_MAX), [add missing realpath for system.cpp])
355357
;;
356358

357359
*darwin*)

debian/changelog

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

samples/distro-examples/tests/output/trycatch.out

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,5 @@ open failed FS(2): NO SUCH FILE OR DIRECTORY
44
after try
55
catch by error name
66
outer after try
7-
8-
9-
* RTE-ERROR AT ../../../samples/distro-examples/tests/trycatch.bas:200 *
10-
Description:
11-
Division by zero
12-
13-
Stack:
14-
TRY: 199
15-
TRY: 198
16-
TRY: 197
17-
TRY: 196
18-
TRY: 195
19-
IF: 194
20-
IF: 193
21-
IF: 192
22-
SUB: 216
7+
Error: Division by zero
8+
End of test

samples/distro-examples/tests/trycatch.bas

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ if 1 == 1 then
213213
fi
214214
end
215215

216-
stack_test
216+
try
217+
stack_test
218+
catch e
219+
print "Error: " + e
220+
end try
217221

218222
sub manageFiles()
219223
sub renameFile()
@@ -229,7 +233,6 @@ sub manageFiles()
229233
viewFile()
230234
end
231235

232-
233236
try
234237
try
235238
throw "!!!error!!!"
@@ -244,3 +247,21 @@ if (inner == "!!!error!!!") then
244247
throw "inner still in scope"
245248
endif
246249

250+
rem test for select case <udf>
251+
func num(n)
252+
return n
253+
end
254+
select case num(10)
255+
case 10
256+
rem success!
257+
case else
258+
throw "fail"
259+
end select
260+
select case round(pi)
261+
case 3
262+
rem "success!"
263+
case else
264+
throw "fail"
265+
end select
266+
267+
print "End of test"

src/common/Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ noinst_LIBRARIES = libsb_common.a
3939

4040
libsb_common_a_SOURCES = \
4141
../lib/match.c ../lib/match.h \
42-
../lib/jsmn.c ../lib/jsmn.h \
43-
../lib/lodepng.c ../lib/lodepng.h \
4442
../lib/str.c ../lib/str.h \
4543
../lib/matrix.c \
4644
../lib/xpm.c \

src/common/blib.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,9 @@ uint8_t get_dimensions(int32_t **lbound, int32_t **ubound) {
175175
* DIM var([lower TO] uppper [, ...])
176176
*/
177177
void cmd_dim(int preserve) {
178-
int exitf = 0;
179-
180178
do {
181179
byte code = code_peek();
182180
if (code == kwTYPE_LINE || code == kwTYPE_EOC) {
183-
exitf = 1;
184181
break;
185182
}
186183
if (code_peek() == kwTYPE_SEP) {
@@ -227,7 +224,7 @@ void cmd_dim(int preserve) {
227224
}
228225
free(lbound);
229226
free(ubound);
230-
} while (!exitf && !prog_error);
227+
} while (!prog_error);
231228
}
232229

233230
/**
@@ -487,8 +484,6 @@ void cmd_erase() {
487484
if (prog_error) {
488485
break;
489486
}
490-
byte code = code_peek();
491-
492487
if (code_isvar()) {
493488
var_p = code_getvarptr();
494489
} else {
@@ -504,7 +499,7 @@ void cmd_erase() {
504499
}
505500

506501
// next
507-
code = code_peek();
502+
byte code = code_peek();
508503
if (code == kwTYPE_SEP) {
509504
par_getcomma();
510505
} else {
@@ -518,7 +513,6 @@ void cmd_erase() {
518513
*/
519514
void cmd_print(int output) {
520515
byte last_op = 0;
521-
byte exitf = 0;
522516
byte use_format = 0;
523517
intptr_t handle = 0;
524518
var_t var;
@@ -603,7 +597,7 @@ void cmd_print(int output) {
603597
}
604598

605599
// PRINT
606-
do {
600+
while (!prog_error) {
607601
code = code_peek();
608602
if (code == kwTYPE_SEP) {
609603
code_skipnext();
@@ -615,7 +609,6 @@ void cmd_print(int output) {
615609
}
616610
} else {
617611
if (kw_check_evexit(code) || code == kwTYPE_LEVEL_END) {
618-
exitf = 1;
619612
break;
620613
}
621614

@@ -643,11 +636,10 @@ void cmd_print(int output) {
643636
}
644637
v_free(&var);
645638
};
646-
647639
if (prog_error) {
648640
return;
649641
}
650-
} while (exitf == 0);
642+
};
651643

652644
if (last_op == 0) {
653645
pv_write("\n", output, handle);

src/common/blib_db.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,14 +806,17 @@ void dirwalk(char *dir, char *wc, bcip_t use_ip, int depth) {
806806
join_path(path, ++dir);
807807
dir = path;
808808
} else if (dir[0] == '~') {
809-
strlcpy(path, getenv("HOME"), sizeof(path));
810-
join_path(path, ++dir);
811-
dir = path;
809+
const char *home = getenv("HOME");
810+
if (home != NULL) {
811+
strlcpy(path, home, sizeof(path));
812+
join_path(path, ++dir);
813+
dir = path;
814+
}
812815
}
813816

814817
DIR *dfd = opendir(dir);
815818
if (dfd == NULL) {
816-
log_printf("DIRWALK: can't open %s", dir);
819+
log_printf(ERR_DIRWALK_CANT_OPEN, dir);
817820
return;
818821
}
819822

@@ -827,14 +830,18 @@ void dirwalk(char *dir, char *wc, bcip_t use_ip, int depth) {
827830
continue;
828831
}
829832
if (strlen(dir) + strlen(dp->d_name) + 2 > OS_PATHNAME_SIZE) {
830-
rt_raise("DIRWALK: name %s/%s too long", dir, dp->d_name);
833+
rt_raise(ERR_DIRWALK_NAME, dir, dp->d_name);
831834
} else {
832835
// check filename
833836
int callusr;
834837
int contf = 1;
835838
struct stat st;
836839

837840
if (!wc) {
841+
if (code_peek() == kwTYPE_EOC) {
842+
rt_raise(ERR_DIRWALK_MISSING_USE);
843+
break;
844+
}
838845
callusr = 1;
839846
} else {
840847
callusr = wc_match(wc, dp->d_name);

src/common/device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
//
88
// Copyright(C) 2000 Nicholas Christopoulos
99

10+
#include "config.h"
11+
12+
#include "include/osd.h"
1013
#include "common/device.h"
1114
#include "common/smbas.h"
1215
#include "common/messages.h"
1316
#include "common/keymap.h"
14-
#include "common/osd.h"
1517
#include "common/inet.h"
1618

1719
#ifdef __MINGW32__

src/common/extlib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ typedef struct {
5757
} slib_t;
5858

5959
static slib_t slib_table[MAX_SLIBS];
60-
static int slib_count;
61-
static int extprocsize;
62-
static int extproccount;
63-
static int extfuncsize;
64-
static int extfunccount;
60+
static uint32_t slib_count;
61+
static uint32_t extprocsize;
62+
static uint32_t extproccount;
63+
static uint32_t extfuncsize;
64+
static uint32_t extfunccount;
6565
static ext_func_node_t *extfunctable;
6666
static ext_proc_node_t *extproctable;
6767

@@ -159,7 +159,7 @@ int slib_add_external_proc(const char *proc_name, int lib_id) {
159159
/**
160160
* Add an external function to the list
161161
*/
162-
int slib_add_external_func(const char *func_name, int lib_id) {
162+
int slib_add_external_func(const char *func_name, uint32_t lib_id) {
163163
// scan for conflicts
164164
for (int i = 0; i < extfunccount; i++) {
165165
if (strcmp(extfunctable[i].name, func_name) == 0) {

0 commit comments

Comments
 (0)