Skip to content

Commit 80984be

Browse files
committed
Merge pull request #26 from smallbasic/SB_0_11_19
0 11 19
2 parents 1f2e22d + d62c436 commit 80984be

Some content is hidden

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

49 files changed

+4219
-687
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2015-06-07
2+
Fixed PRINT 1/1000 and other floating point rounding issues
3+
Fixed problem with 59 char INPUT prompt
4+
Added missing PEN(12) support
5+
Added multi-item case selection (suggestion by James Grimaldi)
6+
SDL: Updated display of file anchor links
7+
SDL: Fix drag-drop from explorer to launch programs
8+
19
2015-01-25
210
Added timer func support
311
Improved syntax error messages

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ SmallBASIC is a fast and easy to learn BASIC language interpreter ideal for ever
1212
$ make
1313
```
1414
or for cross-compiling under linux:
15-
./configure --host=i686-w64-mingw32 --prefix=/devsw/mingw --enable-sdl
16-
Note: requires building SDL2 and freetype-2 into the prefix folder
15+
```
16+
$ sudo apt-get install mingw-w64
17+
$ ./configure --host=i686-w64-mingw32 --prefix=/devsw/mingw --enable-sdl
18+
```
19+
Note: requires building SDL2 and freetype-2 into the prefix folder
1720

1821
## Building the non-graphical console version (cygwin or linux)
1922
```
@@ -24,13 +27,12 @@ SmallBASIC is a fast and easy to learn BASIC language interpreter ideal for ever
2427
$./configure --host=i686-w64-mingw32 && make
2528
```
2629
Windows 64 bit mingw console:
27-
30+
```
2831
$./configure --host=x86_64-w64-mingw32 && make
29-
32+
```
3033
## Building the Android port
3134

32-
1. Setup .bashrc:
33-
35+
1. Setup .bashrc
3436
```
3537
export PATH=$PATH:~/android-sdk/depot_tools:~/android-sdk/android-sdk-linux/platform-tools/
3638
export ANDROID_SDK_ROOT=~/android-sdk/android-sdk-linux
@@ -42,8 +44,7 @@ export NDK_PLATFORM=android-19
4244
export ANDROID_LOG_TAGS="DEBUG:I smallbasic:I AndroidRuntime:E *:S"
4345
```
4446

45-
2. Build FreeType:
46-
47+
2. Build FreeType
4748
First, prepare the cross-compiler from the NDK:
4849
```
4950
$NDK_PATH/build/tools/make-standalone-toolchain.sh \
@@ -56,10 +57,12 @@ Then use it to cross-compile the tools:
5657
make
5758
make install DESTDIR=$(pwd)
5859
```
60+
5961
3. setup config.h
6062
```
6163
./configure --enable-android
6264
```
65+
6366
4. Build the native activity
6467
```
6568
$ cd src/platform/andoid/jni && $NDK/ndk-build NDK_DEBUG=0

configure.ac

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

1313
AC_CANONICAL_TARGET
@@ -168,7 +168,6 @@ function buildFLTK() {
168168
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
169169
AC_DEFINE(IMPL_DEV_ENV, 1, [Driver implements dev_env funcs])
170170
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
171-
AC_DEFINE(OS_PREC64, 1, [64 bit variables])
172171

173172
BUILD_SUBDIRS="src/common src/platform/fltk"
174173
AC_SUBST(BUILD_SUBDIRS)
@@ -211,7 +210,6 @@ function buildSDL() {
211210
PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2)
212211
AC_SUBST(FONTCONFIG_CFLAGS)
213212
AC_SUBST(FONTCONFIG_LIBS)
214-
AC_DEFINE(OS_PREC64, 1, [64 bit variables])
215213

216214
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} ${FONTCONFIG_CFLAGS}"
217215

@@ -242,6 +240,7 @@ function buildSDL() {
242240
BUILD_SUBDIRS="src/common src/platform/sdl"
243241
AC_SUBST(BUILD_SUBDIRS)
244242
(cd ide/android/assets && xxd -i main.bas > ../../../src/platform/sdl/main_bas.h)
243+
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
245244
}
246245

247246
function buildTizen() {
@@ -279,6 +278,8 @@ function buildAndroid() {
279278

280279
TEST_DIR="src/platform/android"
281280
AC_SUBST(TEST_DIR)
281+
282+
(cd documentation && g++ -o build_kwp build_kwp.cpp && ./build_kwp > ../src/ui/kwp.h)
282283
}
283284

284285
function buildConsole() {
@@ -309,7 +310,6 @@ function buildConsole() {
309310
AC_DEFINE(DEV_EVENTS_OSD, 0, [dev_events() implemented using osd_events().])
310311
AC_DEFINE(_CygWin, 1, [Building a minimal dev_null based command-line version.])
311312
AC_DEFINE(__CYGWIN__, 1, [as above])
312-
AC_DEFINE(OS_PREC64, 1, [64 bit variables])
313313
AC_DEFINE(INET_UNSUP, 1, [inet not supported.])
314314
PACKAGE_LIBS="${PACKAGE_LIBS} -lm -lgcc"
315315
BUILD_SUBDIRS="src/common src/platform/unix"
@@ -328,7 +328,6 @@ function buildConsole() {
328328
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
329329
AC_DEFINE(USE_TERM_IO, 0, [Uses terminal-io functions.])
330330
AC_DEFINE(DEV_EVENTS_OSD, 0, [dev_events() implemented using osd_events().])
331-
AC_DEFINE(OS_PREC64, 1, [64 bit variables])
332331
PACKAGE_LIBS="${PACKAGE_LIBS} -lm -ldl -lpthread"
333332
BUILD_SUBDIRS="src/common src/platform/unix"
334333
TEST_DIR="src/platform/unix"

documentation/build_kwp.cpp

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
/**
2+
* builds the kwp.cxx (keyword tables)
3+
*/
4+
#include <stdio.h>
5+
#include <string.h>
6+
#include <ctype.h>
7+
#include <stdlib.h>
8+
#include <unistd.h>
9+
#include "../src/ui/strlib.h"
10+
11+
#define code_t int
12+
#define fcode_t int
13+
#define pcode_t int
14+
15+
struct keyword_s {
16+
char name[16];
17+
code_t code;
18+
};
19+
20+
struct opr_keyword_s {
21+
char name[16];
22+
code_t code;
23+
code_t opr;
24+
};
25+
26+
struct func_keyword_s {
27+
char name[16];
28+
fcode_t fcode;
29+
};
30+
31+
struct proc_keyword_s {
32+
char name[16];
33+
pcode_t pcode;
34+
};
35+
36+
struct spopr_keyword_s {
37+
char name[16];
38+
code_t code;
39+
};
40+
41+
42+
#include "../src/common/kw.h"
43+
#include "../src/languages/keywords.en.c"
44+
45+
struct HelpItem {
46+
char package[20];
47+
char keyword[20];
48+
char id[20];
49+
char signature[128];
50+
char help[1024];
51+
};
52+
53+
int compareHelpItem(const void *p1, const void *p2) {
54+
HelpItem **i1 = (HelpItem **)p1;
55+
HelpItem **i2 = (HelpItem **)p2;
56+
int result = strcasecmp((*i1)->package, (*i2)->package);
57+
if (result == 0) {
58+
result = strcasecmp((*i1)->keyword, (*i2)->keyword);
59+
}
60+
return result;
61+
}
62+
63+
bool isKeyword(const char *keyword) {
64+
bool result = false;
65+
66+
for (int i = 0; !result && keyword_table[i].name[0] != '\0'; i++) {
67+
if (strcasecmp(keyword_table[i].name, keyword) == 0) {
68+
result = true;
69+
}
70+
}
71+
72+
for (int i = 0; !result && proc_table[i].name[0] != '\0'; i++) {
73+
if (strcasecmp(proc_table[i].name, keyword) == 0) {
74+
result = true;
75+
}
76+
}
77+
78+
for (int i = 0; !result && func_table[i].name[0] != '\0'; i++) {
79+
if (strcasecmp(func_table[i].name, keyword) == 0) {
80+
result = true;
81+
}
82+
}
83+
return result;
84+
}
85+
86+
void logMissing(strlib::List<HelpItem *> *helpItems) {
87+
for (int i = 0; keyword_table[i].name[0] != '\0'; i++) {
88+
bool found = false;
89+
List_each(HelpItem *, it, *helpItems) {
90+
HelpItem *next = (*it);
91+
if (strcasecmp(keyword_table[i].name, next->keyword) == 0) {
92+
found = true;
93+
break;
94+
}
95+
}
96+
if (!found && keyword_table[i].name[0] != '$') {
97+
fprintf(stderr, "Missing KEYWORD doc: %s\n", keyword_table[i].name);
98+
}
99+
}
100+
for (int i = 0; proc_table[i].name[0] != '\0'; i++) {
101+
bool found = false;
102+
List_each(HelpItem *, it, *helpItems) {
103+
HelpItem *next = (*it);
104+
if (strcasecmp(proc_table[i].name, next->keyword) == 0) {
105+
found = true;
106+
break;
107+
}
108+
}
109+
if (!found) {
110+
fprintf(stderr, "Missing PROC doc: %s\n", proc_table[i].name);
111+
}
112+
}
113+
for (int i = 0; func_table[i].name[0] != '\0'; i++) {
114+
bool found = false;
115+
List_each(HelpItem *, it, *helpItems) {
116+
HelpItem *next = (*it);
117+
if (strcasecmp(func_table[i].name, next->keyword) == 0) {
118+
found = true;
119+
break;
120+
}
121+
}
122+
if (!found) {
123+
fprintf(stderr, "Missing FUNC doc: %s\n", func_table[i].name);
124+
}
125+
}
126+
}
127+
128+
bool readHelpReference(strlib::List<HelpItem *> *helpItems) {
129+
FILE *fp = fopen("sbasic_ref.csv", "r");
130+
if (!fp) {
131+
fprintf(stderr, "Failed to open sbasic_ref.csv");
132+
return false;
133+
}
134+
135+
char lineBuffer[2048];
136+
while (1) {
137+
if (fgets(lineBuffer, sizeof(lineBuffer), fp) == NULL) {
138+
break;
139+
}
140+
HelpItem *item = new HelpItem();
141+
int len = strlen(lineBuffer);
142+
int currentCol = 0;
143+
int start = 0;
144+
bool quoted = false;
145+
146+
for (int i = 0; i < len; i++) {
147+
if (lineBuffer[i] == '\"' && lineBuffer[i + 1] == '\"') {
148+
// change CSV escape to C escape "" -> \"
149+
lineBuffer[i] = '\\';
150+
i += 1;
151+
} else if (lineBuffer[i] == '\"') {
152+
quoted = !quoted;
153+
} else if (!quoted && (i + 1 == len || lineBuffer[i] == ',')) {
154+
int fieldLen = i - start;
155+
if (lineBuffer[start] == '\"') {
156+
start += 1;
157+
fieldLen -= 2;
158+
}
159+
switch (currentCol) {
160+
case 0:
161+
// package
162+
strncpy(item->package, lineBuffer + start, fieldLen);
163+
item->package[fieldLen] = '\0';
164+
break;
165+
case 1:
166+
// type
167+
break;
168+
case 2:
169+
// keyword
170+
strncpy(item->keyword, lineBuffer + start, fieldLen);
171+
item->keyword[fieldLen] = '\0';
172+
break;
173+
case 3:
174+
// nodeID
175+
strncpy(item->id, lineBuffer + start, fieldLen);
176+
item->id[fieldLen] = '\0';
177+
break;
178+
case 4:
179+
// signature
180+
strncpy(item->signature, lineBuffer + start, fieldLen);
181+
item->signature[fieldLen] = '\0';
182+
break;
183+
case 5:
184+
// text
185+
strncpy(item->help, lineBuffer + start, fieldLen);
186+
item->help[fieldLen] = '\0';
187+
break;
188+
}
189+
currentCol++;
190+
start = i + 1;
191+
}
192+
}
193+
if (isKeyword(item->keyword)) {
194+
helpItems->add(item);
195+
} else {
196+
fprintf(stderr, "OBSOLETE %s\n", item->keyword);
197+
}
198+
}
199+
fclose(fp);
200+
helpItems->sort(compareHelpItem);
201+
logMissing(helpItems);
202+
return true;
203+
}
204+
205+
int main(int argc, char *argv[]) {
206+
strlib::List<HelpItem *> helpItems;
207+
if (!readHelpReference(&helpItems)) {
208+
exit(1);
209+
}
210+
211+
fprintf(stdout, "/* automagicaly generated file */\n");
212+
fprintf(stdout, "struct KEYWORD_HELP {\n");
213+
fprintf(stdout, " const char *package;\n");
214+
fprintf(stdout, " const char *keyword;\n");
215+
fprintf(stdout, " const char *signature;\n");
216+
fprintf(stdout, " const char *help;\n");
217+
fprintf(stdout, "} keyword_help[] = {\n");
218+
List_each(HelpItem *, it, helpItems) {
219+
HelpItem *item = (*it);
220+
fprintf(stdout, "{\"%s\",\"%s\",\"%s\",\"%s\"},\n", item->package,
221+
item->keyword, item->signature, item->help);
222+
}
223+
fprintf(stdout, "};\n");
224+
fprintf(stdout, "const int keyword_help_len = %d;\n", helpItems.size());
225+
return 0;
226+
}

0 commit comments

Comments
 (0)