Skip to content

Commit bd83dd3

Browse files
committed
Merge pull request #27 from chrisws/0_11_19
0 11 19
2 parents 80984be + 4f6b8b7 commit bd83dd3

39 files changed

+484
-368
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2015-08-02
2+
Fix display output before DELAY
3+
Fix LET command problem found in 32bit linux
4+
Removed obsolete/unimplemented keywords WSPLIT, PLOT2, UNLOADLIB
5+
6+
2015-07-18
7+
Added IDE editor sdl/android
8+
Made a few minor performance improvements (SDL)
9+
110
2015-06-07
211
Fixed PRINT 1/1000 and other floating point rounding issues
312
Fixed problem with 59 char INPUT prompt

Makefile.am

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,14 @@ EXTRA_DIST = \
1414
NEWS \
1515
README \
1616
autogen.sh \
17-
src/platform/gtk/sbgtk.glade \
18-
src/platform/gtk/sbgtk.gladep \
19-
src/platform/gtk/debian/changelog \
20-
src/platform/gtk/debian/control \
21-
src/platform/gtk/debian/copyright \
22-
src/platform/gtk/debian/rules \
23-
src/platform/gtk/debian/sbasic.links \
24-
src/platform/sdl/fonts/BI1.c \
25-
src/platform/sdl/fonts/BI2.c \
26-
src/platform/sdl/fonts/BI5.c \
27-
src/platform/sdl/fonts/BI7.c \
28-
src/platform/sdl/fonts/psf2c.c \
2917
documentation/export_csv.bas \
3018
documentation/sbasic_ref.csv \
3119
documentation/HOWTO/HOWTO-DOCUMENT.TXT \
3220
documentation/HOWTO/HOWTO-PORT.TXT \
3321
documentation/HOWTO/DEVELOP.TXT \
3422
documentation/LICENSE \
3523
documentation/README \
36-
documentation/README.BCC \
37-
documentation/README.DEV \
38-
documentation/README.DOS \
39-
documentation/README.HELIO \
40-
documentation/README.PALM \
4124
documentation/README.UNIX \
42-
plugins/publish.bas \
43-
plugins/comment_in.bas \
44-
plugins/comment_out.bas \
45-
plugins/dos2unix.bas \
46-
plugins/indent.bas \
47-
plugins/help.bas \
48-
translator/SB.g \
49-
translator/Makefile \
50-
translator/Translator.java \
5125
images/logo.gif \
5226
images/sb16x16.png \
5327
images/sb32x32.png \

configure.ac

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,28 @@ function buildFLTK() {
140140
esac
141141

142142
FLTK_CXXFLAGS="${PACKAGE_CFLAGS} `fltk2-config --cxxflags` -fno-exceptions"
143-
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk2-config --ldflags --use-images`"
143+
PACKAGE_LIBS="${PACKAGE_LIBS} `fltk2-config --ldstaticflags --use-images`"
144144

145145
dnl do not depend on cygwin.dll under cygwin build
146146
case "${host_os}" in
147147
*mingw* | cygwin*)
148-
FLTK_CXXFLAGS="-I`cygpath -m /usr/local/include` ${FLTK_CXXFLAGS} -mms-bitfields"
149-
PACKAGE_LIBS="-L`cygpath -m /usr/local/lib` ${PACKAGE_LIBS} -lwsock32 -static-libgcc"
148+
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} -mms-bitfields"
149+
PACKAGE_LIBS="-Wl,-Bstatic ${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
150150
AC_DEFINE(_Win32, 1, [Windows build])
151+
;;
152+
153+
*)
154+
dnl check for sdl2-config for sound output
155+
AC_CHECK_PROG(have_sdl, sdl2-config, [yes], [no])
156+
if test "${have_sdl}" = "yes" ; then
157+
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} `sdl2-config --cflags`"
158+
PACKAGE_LIBS="${PACKAGE_LIBS} `sdl2-config --libs`"
159+
AC_DEFINE(HAVE_SDL, 1, [Windows build])
160+
fi
151161
esac
152162

153163
defaultConditionals
154164

155-
dnl check for sdl-config for sound output
156-
AC_CHECK_PROG(have_sdl, sdl-config, [yes], [no])
157-
if test "${have_sdl}" = "yes" ; then
158-
FLTK_CXXFLAGS="${FLTK_CXXFLAGS} `sdl-config --cflags`"
159-
PACKAGE_LIBS="${PACKAGE_LIBS} `sdl-config --libs`"
160-
AC_DEFINE(HAVE_SDL, 1, [Windows build])
161-
fi
162-
163165
dnl preconfigured values for FLTK build
164166
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
165167
AC_DEFINE(_FLTK, 1, [Defined for FLTK build.])
@@ -200,8 +202,8 @@ function buildSDL() {
200202
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -D__USE_MINGW_ANSI_STDIO"
201203

202204
dnl do not depend on cygwin.dll under cygwin build
203-
PACKAGE_CFLAGS="-I`cygpath -m /usr/local/include` ${PACKAGE_CFLAGS} -mms-bitfields"
204-
PACKAGE_LIBS="-L`cygpath -m /usr/local/lib` ${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
205+
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -mms-bitfields"
206+
PACKAGE_LIBS="${PACKAGE_LIBS} -lwsock32 -lws2_32 -static-libgcc -static-libstdc++"
205207
AC_DEFINE(_Win32, 1, [Windows build])
206208
;;
207209

@@ -218,7 +220,7 @@ function buildSDL() {
218220
PACKAGE_LIBS="${PACKAGE_LIBS} ${FONTCONFIG_LIBS}"
219221
esac
220222

221-
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} `sdl2-config --cflags` `freetype-config --cflags`"
223+
PACKAGE_CFLAGS="${PACKAGE_CFLAGS} `sdl2-config --cflags` `freetype-config --cflags` -fno-exceptions"
222224
case "${host_os}" in
223225
*mingw*)
224226
PACKAGE_LIBS="-Wl,-Bstatic ${PACKAGE_LIBS} `sdl2-config --static-libs` `freetype-config --libs`"

documentation/build_kwp.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ bool isKeyword(const char *keyword) {
8080
result = true;
8181
}
8282
}
83+
84+
for (int i = 0; !result && opr_table[i].name[0] != '\0'; i++) {
85+
if (strcasecmp(opr_table[i].name, keyword) == 0) {
86+
result = true;
87+
}
88+
}
89+
90+
for (int i = 0; !result && spopr_table[i].name[0] != '\0'; i++) {
91+
if (strcasecmp(spopr_table[i].name, keyword) == 0) {
92+
result = true;
93+
}
94+
}
95+
8396
return result;
8497
}
8598

documentation/sbasic_ref.csv

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ Math,function,DETERM,729,"DETERM (A[, toler])","Determinant of A. toler = tolera
2020
Math,function,ASECH,714,"ASECH (x)","Inverse secant."
2121
Console,command,AT,521,"AT x, y","Moves the console cursor to the specified position. x,y are in pixels."
2222
Console,command,BEEP,522,"BEEP","Generates a beep sound."
23-
Console,command,BUTTON,523,"BUTTON x, y, w, h, variable, caption [,type]","Creates a button widget for display on a FORM. Possible types are radio, checkbox, button, label, listbox and dropdown. The variable is for data transfer to set or retrieve the button state. Set w+h to a negative value to use the caption width plus the absolute amount. Pass a negtive x+y value to offset from the previous widget. listbox and dropdown can be initialised using an array variable or by passing a vertical bar (|) character separated list of values in varible or caption."
2423
Console,command,CLS,524,"CLS ","Clears the screen."
25-
Console,command,DOFORM,525,"DOFORM FLAG|VAR","Runs the form created with the BUTTON and TEXT commands. Must be called from within a loop to keep the form active. Pass a control variable to receive the value of the selected or clicked form control. Pass 0 to close the form."
26-
Console,command,HTML,526,"HTML, [title,] [x,y,w,h]","Display HTML text."
2724
Console,command,INPUT,527,"INPUT [prompt,|;] var[, var [, ...]]","Reads from ""keyboard"" text and stores it to a variable."
2825
Console,command,LINEINPUT,528,"LINEINPUT [#fileN] var","Reads a whole text line from file or console."
2926
Console,command,LINPUT,529,"LINPUT [#fileN] var","Reads a whole text line from file or console."
@@ -34,7 +31,6 @@ Console,command,PEN,533,"PEN ON|OFF","Enables/Disables the PEN/MOUSE mechanism."
3431
Console,command,PLAY,534,"PLAY string","Play musical notes."
3532
Console,command,PRINT,535,"PRINT [USING [format];] [expr|str [,|; [expr|str]] ...","Display text or the value of an expression."
3633
Console,command,SOUND,536,"SOUND freq, dur_ms [, vol] [BG]","Plays a sound."
37-
Console,command,TEXT,537,"TEXT x, y, w, h, variable","Create an input text widget for display using FORM. See BUTTON for special values for x, y, w, h"
3834
Console,function,CAT,538,"CAT (x)","Returns a console code. 0 = reset, 1 = bold, -1 bold-off, 2 = underline, -2 = underline-off, 3 = reverse, -3 = reverse-off."
3935
Console,function,INKEY,539,"INKEY","Returns the last key-code in keyboard buffer, or an empty string if there are no keys. Special key-codes like the function-keys (PC) or the hardware-buttons (PalmOS) are returned as 2-byte string."
4036
Console,function,TAB,540,"TAB (n)","Moves cursor position to the nth column."
@@ -119,8 +115,6 @@ Graphics,command,PSET,621,"PSET [STEP] x,y [, color| COLOR color]","Draw a pixel
119115
Graphics,command,RECT,622,"RECT [STEP] x,y [,|STEP x2,y2] [, color| COLOR color] [FILLED]","Draws a rectangular parallelogram."
120116
Graphics,command,VIEW,623,"VIEW [x1,y1,x2,y2 [,color [,border-color]]]","Defines a viewport. The viewport defined by VIEW is disabled by a VIEW command with no parameters."
121117
Graphics,command,WINDOW,624,"WINDOW [x1,y1,x2,y2]","The WINDOW command allows you to redefine the corners of the display screen as a pair of ""world"" coordinates."
122-
Graphics,function,IMAGEH,625,"IMAGEH #handle, index","Returns the height of the image in pixels."
123-
Graphics,function,IMAGEW,626,"IMAGEW #handle, index","Returns the width of the image in pixels."
124118
Graphics,function,PEN,627,"PEN (0..14)","Returns the PEN/MOUSE data."
125119
Graphics,function,POINT,628,"POINT (x [, y])","Returns the color of the pixel at x,y."
126120
Graphics,function,RGB,629,"RGB (r, g, b)","Returns the RGB color codes for the specified values. Takes values 0..255 for each of the color."
@@ -136,7 +130,7 @@ Language,function,IFF,638,"IFF expr","Inline version of IF. eg, animal = ""cat""
136130
Language,keyword,BYREF,639,"BYREF","Sub/func argument declaration. Changes to the variable will be passed back to the caller. Equivalent syntax to the @ character."
137131
Language,keyword,CASE,640,"CASE expr","Branch condition for a SELECT statement."
138132
Language,keyword,DEF,641,"DEF name[(par1[,...])] = expression","Defines a single line function. eg, DEF MySin(x) = SIN(x): ? MySin(pi/2)"
139-
Language,keyword,DO,642,"DO","FOR f IN files("*.txt") DO PRINT f"
133+
Language,keyword,DO,642,"DO","FOR f IN files(""*.txt"") DO PRINT f"
140134
Language,keyword,ELIF,643,"ELIF","foo = 2: if foo==1: ? ""one"": ELIF foo==2: ? ""two"": fi"
141135
Language,keyword,ELSE,644,"ELSE","foo = 2: if foo==1: ? ""one"": ELSE: ? ""not one"": fi"
142136
Language,keyword,ELSEIF,645,"ELSEIF","foo = 2: if foo==1: ? ""one"": ELSEIF foo==2: ? ""two"": fi"
@@ -247,9 +241,9 @@ String,command,SINPUT,768,"SINPUT src; var [, delim] [,var [, delim]] ...","Spli
247241
String,command,SPLIT,769,"SPLIT string, delimiters, words() [, pairs] [USE expr]","Returns the words of the specified string into array 'words'."
248242
String,command,SPRINT,770,"SPRINT var; [USING...;] ...","Create formated string and storing it to var. See also: PRINT command."
249243
String,function,ASC,771,"ASC (s)","Returns the ASCII code of first character of the string s."
250-
String,function,BCS,772,"BCS (s)","converts (B)ASIC-style strings to (C)-style (S)trings."
244+
String,function,BCS,772,"BCS (s)","Converts (B)ASIC-style strings to (C)-style (S)trings."
251245
String,function,BIN,773,"BIN (x)","Returns the binary value of x as string."
252-
String,function,CBS,774,"CBS (s)","converts (C)-style strings to (B)ASIC-style (S)trings."
246+
String,function,CBS,774,"CBS (s)","Converts (C)-style strings to (B)ASIC-style (S)trings."
253247
String,function,CHOP,775,"CHOP (source)","Chops off the last character of the string 'source' and returns the result."
254248
String,function,CHR,776,"CHR (x)","Returns one-char string of character with ASCII code x."
255249
String,function,DISCLOSE,777,"DISCLOSE (str[, pairs [, ignore-pairs]])","Discloses a string."
@@ -285,7 +279,6 @@ System,command,DELAY,806,"DELAY ms","Delay for a specified amount of millisecond
285279
System,command,ENV,807,"ENV expr","See ENVIRON."
286280
System,command,ENVIRON,808,"ENVIRON expr","Adds a variable to or deletes a variable from the current environment variable-table."
287281
System,command,PAUSE,809,"PAUSE [secs]","Pauses the execution for a specified length of time, or until user hit the keyboard."
288-
System,command,RTE,811,"RTE [info [, ...]]","Creates a Run-Time-Error. The parameters will be displayed on error-line."
289282
System,command,STKDUMP,812,"STKDUMP","Display internal execution stack."
290283
System,command,TROFF,813,"TROFF","See TRON."
291284
System,command,TRON,814,"TRON","When trace mechanism is ON, displays each line number as the program is executed."
@@ -296,3 +289,19 @@ System,function,RUN,818,"RUN cmdstr","Loads a secondary copy of system's shell a
296289
System,function,TICKS,819,"TICKS","Returns the system-ticks. The tick value is depended on operating system."
297290
System,function,TICKSPERSEC,820,"TICKSPERSEC","Returns the number of ticks per second."
298291
System,function,TIMER,821,"TIMER","Returns the number of seconds from midnight."
292+
Language,keyword,DECLARE,0,"DECLARE FUNC xxx","Forward declare SUB or FUNC. Obsolete QB compatibility"
293+
Language,keyword,TO,0,"FOR t = 1 TO 10","Specifies the loop counter end in a FOR loop"
294+
Language,keyword,STEP,0,"FOR t = 1 TO 10 STEP 2","Specifies the loop counter increment in a FOR loop"
295+
Language,keyword,USING,0,"PRINT USING","See PRINT, SPRINT"
296+
Language,keyword,USG,0,"PRINT USG","Synonym for USING"
297+
Language,keyword,AS,0,"AS #fileN","See: OPEN"
298+
Language,keyword,TRY,0,"TRY","The TRY statement introduces a TRY/CATCH BLOCK"
299+
Language,keyword,CATCH,0,"CATCH [var | expr]","The CATCH statement is used to CATCH an run-time error. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file. The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught. When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately."
300+
Language,keyword,END TRY,0,"END TRY","The END TRY statement marks the end of a TRY/CATCH block."
301+
Language,keyword,BG,0,"SOUND frq, dur [, vol] [BG]","Play sound in the background. This prevent the program from blocking while the sound plays."
302+
Language,function,THROW,0,"THROW","The THROW command (previously known as RTE) is used to initiate a catch-able error. If there is no surrounding TRY/CATCH block, THROW can be used to abort the program."
303+
Graphics,command,SHOWPAGE,0,"SHOWPAGE","This command is used to display pending graphics operations allowing for smooth animations."
304+
Data,function,ISMAP,0,"ISMAP (x)","Returns true if x is an MAP variable type. A MAP provides value-key pair access along with array or dotted notation. The MAP can be initialized from a String variable using the ARRAY command"
305+
Data,function,ISREF,0,"ISREF (x)","Returns true if x is a reference variable type. The REF variable type is a ""reference"" to another variable (like a pointer in c). You create a reference by assigning a variable with the BYREF keyword (or @ symbol)."
306+
Data,function,ARRAY,0,"ARRAY [var | expr]","Creates a ARRAY or MAP variable from the given string or expression"
307+
Console,command,FORM,0,"FORM","Create a form widget. "

src/common/brun.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,6 @@ static inline void bc_loop_call_proc() {
553553
case kwRANDOMIZE:
554554
cmd_randomize();
555555
break;
556-
case kwWSPLIT:
557-
cmd_wsplit();
558-
break;
559556
case kwSPLIT:
560557
cmd_split();
561558
break;
@@ -658,9 +655,6 @@ static inline void bc_loop_call_proc() {
658655
case kwCHMOD:
659656
cmd_chmod();
660657
break;
661-
case kwPLOT2:
662-
cmd_plot2();
663-
break;
664658
case kwPLOT:
665659
cmd_plot();
666660
break;

src/common/fmt.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// limits for use with 32bit integer algorithm
2828
#define FMT_xMIN 1e-8 // lowest limit to use the exp. format
2929
#define FMT_xMAX 1e+9 // highest limit to use the exp. format
30-
#define FMT_RND 7 // rounding on x digits
30+
#define FMT_RND 9 // rounding on x digits
3131
#define FMT_xRND 1e+9 // 1 * 10 ^ FMT_RND
3232
#define FMT_xRND2 1e+8 // 1 * 10 ^ (FMT_RND-1)
3333
#endif
@@ -81,14 +81,15 @@ void fptoa(var_num_t x, char *dest) {
8181
}
8282

8383
/*
84-
* remove rightest zeroes from the number
84+
* Convert to text then remove righmost zeroes from the string
8585
*/
86-
var_num_t rmzeros(var_num_t n) {
87-
var_int_t i = fint(n);
88-
while (i > 0 && i % 10 == 0) {
89-
i /= 10;
86+
void fptoa_rmzeros(var_num_t x, char *dest) {
87+
fptoa(x, dest);
88+
int end = strlen(dest);
89+
while (end > 0 && dest[end - 1] == '0') {
90+
end--;
9091
}
91-
return i;
92+
dest[end] = '\0';
9293
}
9394

9495
/*
@@ -192,7 +193,7 @@ void bestfta_p(var_num_t x, char *dest, var_num_t minx, var_num_t maxx) {
192193
*d++ = '0';
193194
}
194195

195-
fptoa(rmzeros(fpart), buf);
196+
fptoa_rmzeros(fpart, buf);
196197
strcpy(d, buf);
197198
d += strlen(buf);
198199
}

src/common/kw.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ enum proc_keywords {
199199
kwCIRCLE,
200200
kwRANDOMIZE,
201201
kwSPLIT,
202-
kwWSPLIT,
203202
kwWJOIN,
204203
kwPAUSE,
205204
kwDELAY,
@@ -233,7 +232,6 @@ enum proc_keywords {
233232
kwRMDIR,
234233
kwFLOCK,
235234
kwCHMOD,
236-
kwPLOT2,
237235
kwPLOT,
238236
kwSTKDUMP,
239237
kwSWAP,
@@ -243,7 +241,6 @@ enum proc_keywords {
243241
kwBSAVE,
244242
kwTIMEHMS,
245243
kwEXPRSEQ,
246-
kwUNLOADLIB,
247244
kwCALLCP,
248245
kwDEFINEKEY,
249246
kwSHOWPAGE,

src/common/scan.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,20 +2634,30 @@ void comp_text_line(char *text) {
26342634
return;
26352635
}
26362636
}
2637-
if (idx == kwLET) { // old-style keyword LET
2638-
char *p;
2637+
if (idx == kwLET) {
2638+
// old-style keyword LET
26392639
idx = -1;
2640-
p = (char *)comp_next_word(comp_bc_parm, comp_bc_name);
2641-
strcpy(comp_bc_parm, p);
2642-
} else if (idx == kwDECLARE) { // declaration
2643-
char *p;
2640+
char *p = (char *)comp_next_word(comp_bc_parm, comp_bc_name);
2641+
if (p > comp_bc_parm) {
2642+
// p is an offset of comp_bc_parm
2643+
int len = strlen(p);
2644+
memmove(comp_bc_parm, p, len);
2645+
comp_bc_parm[len] = '\0';
2646+
}
2647+
} else if (idx == kwDECLARE) {
2648+
// declaration
26442649
decl = 1;
2645-
p = (char *)comp_next_word(comp_bc_parm, comp_bc_name);
2650+
char *p = (char *)comp_next_word(comp_bc_parm, comp_bc_name);
26462651
idx = comp_is_keyword(comp_bc_name);
26472652
if (idx == -1) {
26482653
idx = comp_is_proc(comp_bc_name);
26492654
}
2650-
strcpy(comp_bc_parm, p);
2655+
if (p > comp_bc_parm) {
2656+
// p is an offset of comp_bc_parm
2657+
int len = strlen(p);
2658+
memmove(comp_bc_parm, p, len);
2659+
comp_bc_parm[len] = '\0';
2660+
}
26512661
if (idx != kwPROC && idx != kwFUNC) {
26522662
sc_raise(MSG_USE_DECL);
26532663
return;

src/common/sys.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,10 @@ typedef unsigned int bcip_t;
4747
#endif
4848

4949
#define DBL_EPSILON 0.00000000000001
50-
#define FLT_EPSILON 0.0000002
51-
52-
#if UINT_MAX != 0xffffffffU
53-
#define OS_PREC64
54-
typedef double var_num_t;
5550
#define EPSILON DBL_EPSILON
56-
#else
57-
typedef float var_num_t;
58-
#define EPSILON FLT_EPSILON
59-
#endif
51+
#define OS_PREC64
6052

53+
typedef double var_num_t;
6154
typedef long int var_int_t;
6255
#define VAR_NUM_FMT "%f"
6356
#define VAR_INT_FMT "%ld"

0 commit comments

Comments
 (0)