Skip to content

Commit cbf8b04

Browse files
authored
Merge pull request #58 from chrisws/0_12_10
0 12 10
2 parents 71d286f + 59b0571 commit cbf8b04

Some content is hidden

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

59 files changed

+826
-485
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2017-11-28 (0.12.10)
2+
COMMON: Fix some coverty warnings
3+
4+
2017-11-17 (0.12.10)
5+
SDL: Fix debugger display issue
6+
17
2017-11-08 (0.12.10)
28
UI: Added ALT+= command
39
UI: Update ALT+. to work with error handling

Makefile.am

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@ leak-test:
1919
cppcheck:
2020
(cppcheck --quiet --enable=all src/common src/ui src/platform/android/jni src/platform/sdl)
2121

22+
covcheck:
23+
(make clean -s && \
24+
cov-build --dir cov-int ./configure --enable-sdl && \
25+
cov-build --dir cov-int make -s && \
26+
tar czvf smallbasic.tgz cov-int)
27+
28+
covcheck-android:
29+
(make clean -s && \
30+
cov-build --dir cov-int ./configure --enable-android && \
31+
cov-build --dir cov-int make check -s && \
32+
tar czvf smallbasic.tgz cov-int)
33+
34+
clangcheck:
35+
(make clean -s && \
36+
scan-build ./configure --enable-sdl && \
37+
scan-build -o scan make -s)
38+
39+
clangcheck-android:
40+
(make clean -s && \
41+
scan-build ./configure --enable-android && \
42+
scan-build -o scan make check -s)
43+
44+
check:
45+
(cd $(SUBDIRS) && make check)
46+
2247
release:
2348
(cd $(SUBDIRS) && make release)
2449

configure.ac

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ function buildSDL() {
164164
dnl do not depend on cygwin.dll under cygwin build
165165
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -mms-bitfields"
166166
PACKAGE_LIBS="${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
167-
PACKAGE_LIBS="-Wl,-Bstatic ${PACKAGE_LIBS} `sdl2-config --static-libs` `freetype-config --libs`"
167+
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -Wl,-Map=output.map"
168+
PACKAGE_LIBS="${PACKAGE_LIBS} `sdl2-config --static-libs` `freetype-config --libs`"
168169
AC_DEFINE(_Win32, 1, [Windows build])
169170
;;
170171

@@ -343,6 +344,10 @@ dnl change default aru setting to avoid warning
343344
ARFLAGS=cr
344345
AC_SUBST(ARFLAGS)
345346

347+
dnl check missing functions
348+
AC_CHECK_FUNC([strlcpy], [AC_DEFINE([HAVE_STRLCPY], [1], [Define if strlcpy exists.])])
349+
AC_CHECK_FUNC([strlcat], [AC_DEFINE([HAVE_STRLCAT], [1], [Define if strlcat exists.])])
350+
346351
AC_CONFIG_FILES([
347352
Makefile
348353
src/common/Makefile

ide/android/assets/main.bas

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const char_w = txtw(".")
77
const lineSpacing = 2 + char_h
88
const idxEdit = 6
99
const idxFiles = 7
10-
const sizeDateCol = rgb(100,100,100)
10+
const colGrey = rgb(100,100,100)
1111
const menu_gap = -(char_w / 2)
1212
const is_sdl = instr(sbver, "SDL") != 0
1313
const onlineUrl = "http://smallbasic.github.io/samples/index.bas"
@@ -24,6 +24,7 @@ const filesId = "_files"
2424
const setupId = "_setup"
2525
const aboutId = "_about"
2626
const backId = "_back"
27+
const scratchId = "_scratch"
2728

2829
func mk_bn(value, lab, fg)
2930
local bn
@@ -47,23 +48,34 @@ func mk_menu(value, lab, x)
4748
mk_menu = bn
4849
end
4950

50-
sub mk_scratch()
51+
func mk_scratch()
5152
local text
5253
local file = "scratch.bas"
54+
local result = false
5355

5456
if (not exist(file)) then
5557
dim text
5658
text << "rem Welcome to SmallBASIC"
5759
text << "rem"
58-
text << "rem Press F1 for keyword help."
59-
text << "rem Press and hold Ctrl then press 'h' for editor help."
60-
text << "rem Press and hold Ctrl then press 'r' to RUN this program."
60+
if (is_sdl) then
61+
text << "rem Press F1 for keyword help."
62+
text << "rem Press and hold Ctrl then press 'h' for editor help."
63+
text << "rem Press and hold Ctrl then press 'r' to RUN this program."
64+
text << "rem Click the right mouse button for menu options."
65+
else
66+
text << "rem Press the 3 vertical dots for menu options."
67+
endif
6168
try
6269
tsave file, text
70+
result = true
6371
catch e
64-
logprint "Failed to create scratch file: " + e
72+
local wnd = window()
73+
wnd.alert("Failed to create scratch file: " + e)
6574
end try
75+
else
76+
result = true
6677
endif
78+
return result
6779
end
6880

6981
sub do_okay_button()
@@ -93,14 +105,14 @@ sub do_about()
93105
print "(_ ._ _ _.|||_) /\ (_ |/ "
94106
print "__)| | |(_||||_)/--\__)|\_"
95107
endif
96-
print
108+
print
97109
color 7,0
98110
print "Version "; sbver
99111
print
100112
print "Copyright (c) 2002-2017 Chris Warren-Smith"
101113
print "Copyright (c) 1999-2006 Nic Christopoulos" + chr(10)
102114
print "https://smallbasic.sourceforge.io" + chr(10)
103-
color sizeDateCol,0
115+
color colGrey,0
104116
print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. ";
105117
print "This program is free software; you can use it ";
106118
print "redistribute it and/or modify it under the terms of the ";
@@ -285,7 +297,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
285297
bn.y = -1
286298
frm.inputs << bn
287299

288-
abbr = iff(char_w * 65 > xmax, true, false)
300+
abbr = iff(char_w * 38 > xmax, true, false)
289301
if (not abbr) then
290302
bn = mk_bn(sortSizeId, "[Size]", size_col)
291303
bn.type = "link"
@@ -322,7 +334,7 @@ sub listFiles(byref frm, path, sortDir, byref basList)
322334

323335
gap = 12 - len(str(node.size))
324336
n = iff(gap > 1, gap, 1)
325-
bn = mk_bn(0, node.size + space(n) + timestamp(node.mtime), sizeDateCol)
337+
bn = mk_bn(0, node.size + space(n) + timestamp(node.mtime), colGrey)
326338
bn.type = "label"
327339
bn.y = -1
328340
gap = 29 - len(name)
@@ -561,23 +573,21 @@ sub main
561573
local sortDir = env("sortDir")
562574
if (len(sortDir) == 0) then sortDir = 0
563575

564-
if (command == "welcome" && len(files("*.bas")) == 0) then
565-
mk_scratch()
566-
endif
567-
568576
func makeUI(path, sortDir)
569-
local frm, bn_files, bn_online, bn_setup, bn_about, bn_new
577+
local frm, bn_files, bn_online, bn_setup, bn_about, bn_new, bn_scratch
570578
local basList
571579
dim basList
572580

573581
bn_files = mk_menu(filesId, "File", 0)
574582
bn_online = mk_menu(onlineUrl, "Online", menu_gap)
583+
bn_scratch = mk_menu(scratchId, "Scratch", menu_gap)
575584
bn_setup = mk_menu(setupId, "Setup", menu_gap)
576585
bn_about = mk_menu(aboutId, "About", menu_gap)
577586
bn_online.isExit = true
578587

579588
frm.inputs << bn_files
580589
frm.inputs << bn_online
590+
frm.inputs << bn_scratch
581591
if (!is_sdl) then
582592
frm.inputs << bn_setup
583593
endif
@@ -629,6 +639,10 @@ sub main
629639
managefiles()
630640
endif
631641
frm = makeUI(path, sortDir)
642+
elif frm.value == scratchId then
643+
if (mk_scratch())
644+
frm.close("scratch.bas")
645+
endif
632646
elif frm.value == backId then
633647
cls
634648
go_back()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
rem recherche
2+
Rem reg1s roum1gu1eres 2017
3+
view (10,470,10,600)
4+
X=xmax/2
5+
y=ymax/2
6+
c=36
7+
p=2
8+
d=xmax/4
9+
d_dir=-1
10+
while 1
11+
cls
12+
for a=1 to 1200 'originally 360
13+
pset (0.06) (x+d*cos((a/150) -345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/180)) color 3
14+
pset (0.06) (x+d*cos((a/147.27)-345)*sin(a/c)),(y+d*sin(360-(a/p))*cos(a/150)) color 3
15+
pset (0.06) (x+d*cos((a/144)-345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/147.27)) color 3
16+
pset (0.06) (x+d*cos((a/140)-345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/144)) color 3
17+
pset (0.06) (x+d*cos((a/135)-345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/140)) color 3
18+
pset (0.06) (x+d*cos((a/128.5)-345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/135)) color 3
19+
'pset (0.06) (x+d*cos((a/120)-345)*sin(a/c)), (y+d*sin(360-(a/c))*cos(a/120)) color 6
20+
pset (0.06) (x+d*cos((a/90)-345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/108)) color 3
21+
pset (0.06) (x+d*cos((a/60)-345)*sin(a/c)), (y+d*sin(360-(a/p))*cos(a/90)) color 3
22+
pset x+(d*cos(a/359)*sin(a/c)), y+(d*sin(a)*cos(a/p)*sin(a/359)) color 7
23+
pset x-(d*cos(a/359)), y+(d*sin(a)*cos(a/359)) color 7
24+
'pset x+d*cos(a/359), y-d*sin(a/c)*cos(a/359) color 2
25+
pset x-(d*cos(a/359)*sin(a/32)), y+(d*sin(a)*cos(a/c+c)*sin(a/359)) color 7
26+
pset x-d*cos(a/24)*sin(a/32), y+d*sin(a)*cos(a/8)*sin(a) color 7
27+
next a
28+
showpage
29+
p = 1 + (p + 1) mod 400
30+
c = 1 + (c + 1) mod 200
31+
d += d_dir
32+
if (d < -1200) then
33+
d_dir = 1
34+
else if (d > 1200) then
35+
d_dir = -1
36+
endif
37+
wend
38+
pause

samples/distro-examples/tests/array.bas

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,16 @@ if (stack != [1,2]) then throw "stack err"
281281
queue=[11,12,13,14,15,16]
282282
delete queue, 0, 3
283283
if (queue != [14,15,16]) then throw "queue err"
284+
285+
rem --- handle comments inside JSON block
286+
camera = {
287+
x: 512, rem position on the map
288+
y: 800, rem y position on the map
289+
height: 78, rem height of the camera
290+
angle: 0, rem direction of the camera
291+
horizon: 100, rem horizon position (look up and down)
292+
distance: 800 rem distance of map
293+
}
294+
if (camera.x != 512) then throw "invalid x"
295+
if (camera.height != 78) then throw "invalid height"
296+
if (camera.distance != 800) then throw "invalid distance"

samples/distro-examples/tests/eval-test.bas

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,11 @@ moves_called = false
362362
for i in s.moves()
363363
next i
364364

365+
gg = 99
366+
gosub plus1
367+
if (gg != 100) then throw "err"
368+
end
369+
label plus1
370+
gg += 1
371+
return
372+

samples/distro-examples/tests/matrices.bas

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,8 @@ C=LinEqn(a,b)
3939
print "[x; y; z] = "; C
4040
?
4141

42+
rem -- handling for dot product and multiplication of two 1D arrays
43+
a1=[1,2,4]
44+
a2=[1,4,5]
45+
if (a1 * a2 != [1,8,20]) then throw "err"
46+
if (a1 % a2 != 29) then throw "err"

src/common/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ libsb_common_a_SOURCES = \
4141
../lib/match.c ../lib/match.h \
4242
../lib/jsmn.c ../lib/jsmn.h \
4343
../lib/lodepng.c ../lib/lodepng.h \
44+
../lib/str.c ../lib/str.h \
4445
../lib/matrix.c \
4546
../lib/xpm.c \
4647
bc.c bc.h \

src/common/bc.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,13 @@ void bc_add_creal(bc_t *bc, var_num_t v) {
173173
* add one command and one string (see: bc_store_string)
174174
*/
175175
void bc_add_strn(bc_t *bc, const char *str, int len) {
176-
if (len > BC_MAX_STORE_SIZE) {
177-
sc_raise("String: buffer size limit exceeded");
178-
} else {
179-
bc_add_code(bc, kwTYPE_STR);
180-
bc_add_dword(bc, len);
181-
if (bc->count + len >= bc->size) {
182-
bc_resize(bc, bc->size + BC_ALLOC_INCR + len);
183-
}
184-
memcpy(bc->ptr + bc->count, str, len);
185-
bc->count += len;
176+
bc_add_code(bc, kwTYPE_STR);
177+
bc_add_dword(bc, len);
178+
if (bc->count + len >= bc->size) {
179+
bc_resize(bc, bc->size + BC_ALLOC_INCR + len);
186180
}
181+
memcpy(bc->ptr + bc->count, str, len);
182+
bc->count += len;
187183
}
188184

189185
/*
@@ -239,6 +235,7 @@ char *bc_store_string(bc_t *bc, char *src) {
239235
}
240236
p++;
241237
}
238+
free(np);
242239
return p;
243240
}
244241

0 commit comments

Comments
 (0)