Skip to content

Commit

Permalink
Merge pull request #108 from chrisws/12_20
Browse files Browse the repository at this point in the history
12 20
  • Loading branch information
chrisws authored Jan 8, 2021
2 parents aae8feb + 5ae7b9d commit e5b1a91
Show file tree
Hide file tree
Showing 55 changed files with 1,112 additions and 714 deletions.
32 changes: 32 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
2020-12-19 (12.20)
SDL: Update editor popup appearance

2020-11-19 (12.20)
COMMON: Fix to allow multiple modules and units within saem program

2020-11-13 (12.20)
ANDROID: add option to preserve user data when app uninstalled

2020-11-10 (12.20)
ANDROID: change path label when displaying project folder
COMMON: ensure INT datatype is always 64 bits

2020-11-01 (12.20)
CONSOLE: give error when file not found

2020-10-31 (12.20)
SDL: implemented restoring the cursor position

2020-10-29 (12.20)
COMMON: Implemented c-styles escape sequences

2020-10-27 (12.20)
COMMON: add support for inline assignment of export variables
COMMON: add support for unit alias names

2020-10-21 (12.20)
ANDROID: upgrade to target android 29

2020-10-21 (12.20)
COMMON: Fix to allow c-modules to be called from units

2020-07-16 (12.19)
COMMON: Fix 'Print #' on Windows to use Windows line endings

Expand Down
5 changes: 3 additions & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# This file is part of SmallBASIC
#
# Copyright(C) 2001-2015 Chris Warren-Smith.
# Copyright(C) 2001-2020 Chris Warren-Smith.
#
# This program is distributed under the terms of the GPL v2.0 or later
# Download the GNU Public License (GPL) from www.gnu.org
#

ln -sf README.md README

git submodule update --
git submodule init
git submodule update

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

Expand Down
11 changes: 2 additions & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl

AC_INIT([smallbasic], [12.19])
AC_INIT([smallbasic], [12.20])
AC_CONFIG_SRCDIR([configure.ac])

AC_CANONICAL_TARGET
Expand Down Expand Up @@ -59,8 +59,6 @@ function checkForWindows() {
*darwin*)
;;
*)
dnl backlinking support for modules
LDFLAGS="${LDFLAGS} -export-dynamic"
esac
AM_CONDITIONAL(WITH_WIN32, test x"$win32" = "xyes")
}
Expand Down Expand Up @@ -219,7 +217,6 @@ function buildSDL() {
AC_DEFINE(_SDL, 1, [Defined when building SDL version])
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])

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

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

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

if test $win32 = yes; then
dnl test whether to build using mingw
Expand All @@ -287,7 +282,7 @@ function buildConsole() {
TARGET="Building Cygwin MinGW console version."
AC_DEFINE(__MINGW32__, 1, [as above])
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -mconsole -lmingw32 -lwsock32 -lws2_32 -static-libgcc"
PACKAGE_LIBS="${PACKAGE_LIBS} -Wl,-Bstatic -mconsole -lwsock32 -lws2_32 -static-libgcc"
BUILD_SUBDIRS="src/common src/platform/console"
fi
AC_DEFINE(_Win32, 1, [Windows build])
Expand Down Expand Up @@ -320,7 +315,6 @@ function buildWeb() {
BUILD_SUBDIRS="src/common src/platform/web"
AM_CONDITIONAL(WITH_CYGWIN_CONSOLE, false)
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
AC_DEFINE(USE_TERM_IO, 0, [dont use the termios library.])
AC_DEFINE(IMPL_DEV_ENV, 1, [Driver implements dev_env funcs])
Expand Down Expand Up @@ -374,7 +368,6 @@ function buildFLTK() {
AC_DEFINE(_UnixOS, 1, [Building under Unix like systems.])
AC_DEFINE(_FLTK, 1, [Defined for FLTK build.])
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
AC_DEFINE(IMPL_DEV_DELAY, 1, [Driver implements dev_delay()])
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])

BUILD_SUBDIRS="src/common src/platform/fltk"
Expand Down
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
smallbasic (12.20) unstable; urgency=low
* Various see web site

-- Chris Warren-Smith <[email protected]> Fri, 16 Oct 2020 09:45:25 +1000

smallbasic (0.12.19) unstable; urgency=low
* Various see web site

Expand Down
29 changes: 18 additions & 11 deletions samples/distro-examples/tests/call_tau.bas
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
' example: using a unit, 0.9
'

Import Tau, PreDef
Import Tau as taz, PreDef

? "Tau's exported variable: ", tau.expvar
? "Function fooF : ", tau.fooF("Hi")
? "Tau's exported variable: ", taz.expvar
? "Function fooF : ", taz.fooF("Hi")
? "Procedure fooP : "
tau.fooP "Hi"
taz.fooP "Hi"

' reverse var-update
tau.expvar = "message from main"
tau.print_expvar
? tau.expvar
tau.build_ta
? tau.ta
taz.expvar = "message from main"
taz.print_expvar
? taz.expvar
taz.build_ta
? taz.ta
'tau.cerr

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

for i = 0 to 1000
tau.addRoom(foyer,x)
jj = tau.calcRoomSize(foyer,x)
taz.addRoom(foyer,x)
jj = taz.calcRoomSize(foyer,x)
next i

sub addRoom(the_thing, d)
print the_thing.name, d
end

addRoom(foyer,x)

if (Taz.LIGHTGRAY != rgb(200, 200, 200)) then
print "Error importing inline assigned export variable"
endif
if (Taz.YELLOW != rgb(253, 249, 0)) then
print "Error importing inline assigned export variable"
endif
11 changes: 10 additions & 1 deletion samples/distro-examples/tests/strings.bas
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ if expect != seq(0, 2*pi, 360/15+1) then throw "SEQ error"
s="Hello\033There"
if (27 != asc(mid(s, 6, 1))) then throw "err"
rem Non escaping '\' should appear verbatim
s= "a\c\e"
s= "a\\c\\e"
if mid(s, 2, 1) != "\\" then throw s
if mid(s, 4, 1) != "\\" then throw s

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

if (asc("\a") != 7) then throw "err1"
if (asc("\b") != 8) then throw "err2"
if (asc("\e") != 27) then throw "err3"
if (asc("\f") != 12) then throw "err4"
if (asc("\n") != 10) then throw "err5"
if (asc("\r") != 13) then throw "err6"
if (asc("\t") != 9) then throw "err7"
if (asc("\v") != 11) then throw "err8"

6 changes: 5 additions & 1 deletion samples/distro-examples/tests/tau.bas
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ Import TauChild

Export expvar, foof, foop
export addRoom,calcRoomSize
export print_expvar, ta, build_ta, cerr
export print_expvar, ta, build_ta, cerr

expvar = "Tau's exported variable"

export const LIGHTGRAY = rgb(200, 200, 200)
export const GRAY = rgb(130, 130, 130)
export const DARKGRAY = rgb(80, 80, 80), const YELLOW = rgb(253, 249, 0)

func fooF(x)
foof = "Tau's fooF("+x+") is here"
end
Expand Down
63 changes: 45 additions & 18 deletions src/common/bc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@

#include "common/bc.h"
#include "common/smbas.h"
#include "common/str.h"

/*
* string escape codes
*/
const char escapes[][2] = {
{'a', 0x07},
{'b', 0x08},
{'e', 0x1b},
{'f', 0x0c},
{'n', 0x0a},
{'r', 0x0d},
{'t', 0x09},
{'v', 0x0b},
};

/*
* whether the character is an escape
*/
int bc_is_escape(char c, char *value) {
int len = sizeof(escapes) / sizeof(escapes[0]);
int result = 0;
for (int i = 0; i < len && !result; i++) {
if (escapes[i][0] == c) {
*value = escapes[i][1];
result = 1;
}
}
return result;
}

/*
* Create a bytecode segment
Expand Down Expand Up @@ -182,23 +212,18 @@ void bc_add_strn(bc_t *bc, const char *str, int len) {
* returns a pointer of src to the next "element"
*/
char *bc_store_string(bc_t *bc, char *src) {
char *p = src;
char *np = NULL;
// skip past opening quotes
char *p = src + 1;
char *base = src + 1;
int len = 0;
char escape = 0;
cstr cs;
cstr_init(&cs, 5);

// skip past opening quotes
p++;
while (*p) {
if ((*p == '\\' && ((*(p + 1) == '\"') || *(p + 1) == '\\'))
|| *p == V_JOIN_LINE) {
// escaped quote " or escaped escape
int seglen = p - base;
np = np ? realloc(np, len + seglen + 1) : malloc(seglen + 1);
strncpy(np + len, base, seglen);
// add next segment
len += seglen;
np[len] = 0;
cstr_append_i(&cs, base, p - base);

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

// include " (or \ ) in next segment
base = ++p;
} else if (*p == '\\' && bc_is_escape(*(p + 1), &escape)) {
char code[] = {escape, '\0'};
cstr_append_i(&cs, base, p - base);
cstr_append_i(&cs, code, 1);
base = (++p) + 1;
} else if (*p == V_QUOTE) {
// revert hidden quote
*p = '\"';
Expand All @@ -220,17 +250,14 @@ char *bc_store_string(bc_t *bc, char *src) {
*p = '\n';
} else if (*p == '\"') {
// end of string detected
int seglen = p - base;
np = np ? realloc(np, len + seglen + 1) : malloc(seglen + 1);
memcpy(np + len, base, seglen);
bc_add_strn(bc, np, len + seglen);
free(np);
cstr_append_i(&cs, base, p - base);
bc_add_strn(bc, cs.buf, cs.length);
p++;
return p;
break;
}
p++;
}
free(np);
free(cs.buf);
return p;
}

Expand Down
Loading

0 comments on commit e5b1a91

Please sign in to comment.