Skip to content

Commit d37914f

Browse files
committed
Merge pull request #10 from chrisws/android
Android
2 parents b84aab6 + 862a027 commit d37914f

File tree

48 files changed

+753
-130
lines changed

Some content is hidden

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

48 files changed

+753
-130
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2014-06-14
2+
Fix crash evaluating "a \\ b"
3+
Fix INPUT command in FLTK for scrolled display
4+
5+
2014-06-11
6+
Android changes:
7+
- Run by URL/QrCode.
8+
- Implemented BEEP/SOUND
9+
- Screen layout adjusts when virtual keypad displayed
10+
11+
2014-04-20
12+
Released Windows version 0.11.5
13+
114
2013-12-30
215
Fix android display clip handling
316
Fix android import from IDE

README

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ SmallBASIC is a fast and easy to learn BASIC language interpreter ideal for ever
55
1. Setup .bashrc:
66

77
export PATH=$PATH:~/android-sdk/adt-bundle-linux-x86_64-20131030/sdk/platform-tools
8-
export ANDROID_SDK_ROOT=~/android-sdk/adt-bundle-linux-x86_64-20131030/sdk
8+
export ANDROID_SDK_ROOT=~/android-sdk/adt-bundle-linux-x86_64-20140321/sdk
99
export TARGET_DEVICE=arm
1010
export PLATFORM_PREFIX=~/android-sdk/android-ext/
1111
export PATH=${PLATFORM_PREFIX}/bin:${PATH}
12-
export NDK=~/android-sdk/android-ndk-r9b
12+
export NDK=~/android-sdk/android-ndk-r9d
1313
export NDK_PLATFORM=android-9
1414
export ANDROID_LOG_TAGS="DEBUG:I smallbasic:I AndroidRuntime:E *:S"
1515

@@ -20,13 +20,13 @@ First, prepare the cross-compiler from the NDK:
2020
--platform=$NDK_PLATFORM --install-dir=$PLATFORM_PREFIX
2121

2222
Then use it to cross-compile the tools:
23-
cd libpng-1.6.6/
23+
cd libpng-1.6.12/
2424
CFLAGS="-std=gnu99" ./configure --host=arm-linux-androideabi --prefix=/png
2525
make
2626
make install DESTDIR=$(pwd)
2727

28-
cd freetype-2.4.10/
29-
CFLAGS="-std=gnu99" ./configure --host=arm-linux-androideabi --prefix=/freetype --without-zlib --without-png
28+
cd freetype-2.5.3/
29+
CFLAGS="-std=gnu99" ./configure --host=arm-linux-androideabi --prefix=/freetype --without-zlib --without-png --without-harfbuzz
3030
make
3131
make install DESTDIR=$(pwd)
3232

@@ -117,27 +117,18 @@ alias adebug="adb -d logcat -c && adb -d logcat"
117117

118118
== Setup instructions for building FLTK version under a fresh ubuntu system
119119

120-
1. Install tools using synaptic package manager. Be sure to accept all included
121-
dependencies. Note, some of these are only required for building FLTK to
122-
completion but are not actually used in SmallBASIC:
123-
124-
* subversion
125-
* autotools-dev
126-
* autogen
127-
* autoconf
128-
* libxft-dev
129-
* g++
130-
* libxi-dev
131-
* libgl1-mesa-dev
132-
* libglut3-dev
133-
* libsdl1.2-dev
134-
* libreadline-dev
120+
1. Install tools. Be sure to accept all included dependencies. Note, some
121+
of these are only required for building FLTK to completion but are not
122+
actually used in SmallBASIC:
123+
124+
sudo apt-get install subversion autotools-dev autogen autoconf \
125+
libxft-dev g++ libxi-dev libgl1-mesa-dev libglut3-dev libsdl1.2-dev libreadline-dev
135126

136127
2. Download code from subversion:
137128

138129
$ mkdir src && cd src
139-
$ svn co http://svn.easysw.com/public/fltk/fltk/trunk fltk-2.0
140-
$ svn co https://smallbasic.svn.sourceforge.net/svnroot/smallbasic/trunk/smallbasic
130+
$ svn co http://seriss.com/public/fltk/fltk/trunk fltk-2.0 <press enter for username+password>
131+
$ git clone git://git.code.sf.net/p/smallbasic/git smallbasic-git
141132
$ cd fltk-2.0
142133
$ make (needs to complete at least up to building tests)
143134
$ sudo make install

configure.ac

Lines changed: 1 addition & 1 deletion
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.5])
10+
AC_INIT([smallbasic], [0.11.6])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET

ide/android/AndroidManifest.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="net.sourceforge.smallbasic"
44
android:installLocation="preferExternal"
5-
android:versionCode="5"
6-
android:versionName="0.11.5">
5+
android:versionCode="6"
6+
android:versionName="0.11.6">
77
<!-- This is the platform API where NativeActivity was introduced. -->
88
<uses-sdk android:minSdkVersion="9" />
99

@@ -12,7 +12,7 @@
1212
android:hasCode="true"
1313
android:hardwareAccelerated="true"
1414
android:icon="@drawable/ic_launcher">
15-
<!-- Our activity is the built-in NativeActivity framework class.
15+
<!-- Our activity is based on the built-in NativeActivity framework class.
1616
This will take care of integrating with our NDK code. -->
1717
<activity android:name="net.sourceforge.smallbasic.MainActivity"
1818
android:label="@string/app_name"
@@ -46,6 +46,12 @@
4646
<data android:pathPattern=".*\\..*\\..*\\.bas" />
4747
<data android:pathPattern=".*\\..*\\..*\\..*\\.bas" />
4848
</intent-filter>
49+
<intent-filter>
50+
<action android:name="android.intent.action.VIEW"/>
51+
<category android:name="android.intent.category.DEFAULT"/>
52+
<category android:name="android.intent.category.BROWSABLE" />
53+
<data android:scheme="smallbasic" />
54+
</intent-filter>
4955
</activity>
5056
</application>
5157
<!-- Permissions -->

ide/android/assets/main.bas

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ sub about()
3030
print "(_ ._ _ _.|||_) /\ (_ |/ "
3131
print "__)| | |(_||||_)/--\__)|\_"
3232
print
33-
print "Version 0.11.5"
33+
print "Version 0.11.6"
3434
print
35-
print "Copyright (c) 2002-2013 Chris Warren-Smith"
35+
print "Copyright (c) 2002-2014 Chris Warren-Smith"
3636
print "Copyright (c) 2000-2006 Nic Christopoulos" + chr(10)
3737
print "http://smallbasic.sourceforge.net" + chr(10)
3838
print "SmallBASIC comes with ABSOLUTELY NO WARRANTY. ";
@@ -78,9 +78,12 @@ sub setup()
7878
end
7979

8080
sub serverInfo()
81-
serverSocket = env("serverSocket")
82-
if (len(serverSocket) > 0) then
83-
print boldOff + "Web Service port: " + boldOn + serverSocket
81+
local serverSocket = env("serverSocket")
82+
local ipAddr = env("IP_ADDR")
83+
84+
if (len(serverSocket) > 0 && len(ipAddr)) then
85+
serverSocket = ipAddr + ":" + serverSocket
86+
print boldOff + "Web Service: " + boldOn + serverSocket
8487
print boldOff + "Access token: " + boldOn + env("serverToken")
8588
print boldOff
8689
fi

ide/android/build.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project name="SmallBASIC" default="help">
3+
4+
<!-- Build requires the following setup:
5+
ln -s jni -> ../../src/platform/android/jni
6+
ln -s libs -> ../../src/platform/android/libs/
7+
ln -s obj -> ../../src/platform/android/obj/
8+
src -> ../../src/platform/android/src/
9+
-->
310

411
<!-- The local.properties file is created and updated by the 'android' tool.
512
It contains the path to the SDK. It should *NOT* be checked into

src/common/eval.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -426,38 +426,38 @@ void eval(var_t *r) {
426426
op = CODE(IP);
427427
IP++;
428428

429-
if (r->type == V_INT && left->type == V_INT) {
429+
if (r->type == V_INT && v_is_type(left, V_INT)) {
430430
if (op == '+') {
431431
r->v.i += left->v.i;
432432
} else {
433433
r->v.i = left->v.i - r->v.i;
434434
}
435-
} else if (r->type == V_NUM && left->type == V_NUM) {
435+
} else if (r->type == V_NUM && v_is_type(left, V_NUM)) {
436436
r->type = V_NUM;
437437
if (op == '+') {
438438
r->v.n += left->v.n;
439439
} else {
440440
r->v.n = left->v.n - r->v.n;
441441
}
442-
} else if (r->type == V_INT && left->type == V_NUM) {
442+
} else if (r->type == V_INT && v_is_type(left, V_NUM)) {
443443
r->type = V_NUM;
444444
if (op == '+') {
445445
r->v.n = r->v.i + left->v.n;
446446
} else {
447447
r->v.n = left->v.n - r->v.i;
448448
}
449-
} else if (r->type == V_NUM && left->type == V_INT) {
449+
} else if (r->type == V_NUM && v_is_type(left, V_INT)) {
450450
if (op == '+') {
451451
r->v.n += left->v.i;
452452
} else {
453453
r->v.n = left->v.i - r->v.n;
454454
}
455455
} else {
456-
if (r->type == V_ARRAY || left->type == V_ARRAY) {
456+
if (r->type == V_ARRAY || v_is_type(left, V_ARRAY)) {
457457
//
458458
// ARRAYS
459459
//
460-
if (r->type == V_ARRAY && left->type == V_ARRAY) {
460+
if (r->type == V_ARRAY && v_is_type(left, V_ARRAY)) {
461461
if (op == '+') {
462462
mat_add(r, left);
463463
} else {
@@ -499,11 +499,11 @@ void eval(var_t *r) {
499499
op = CODE(IP);
500500
IP++;
501501

502-
if (r->type == V_ARRAY || left->type == V_ARRAY) {
502+
if (r->type == V_ARRAY || v_is_type(left, V_ARRAY)) {
503503
//
504504
// ARRAYS
505505
//
506-
if (r->type == V_ARRAY && left->type == V_ARRAY) {
506+
if (r->type == V_ARRAY && v_is_type(left, V_ARRAY)) {
507507
if (op == '*') {
508508
mat_mul(left, r);
509509
} else {
@@ -769,13 +769,13 @@ void eval(var_t *r) {
769769
}
770770
}
771771
} else if (r->type == V_STR) {
772-
if (left->type == V_STR) {
772+
if (v_is_type(left, V_STR)) {
773773
if (left->v.p.ptr[0] != '\0') {
774774
ri = (strstr(r->v.p.ptr, left->v.p.ptr) != NULL);
775775
} else {
776776
ri = 0;
777777
}
778-
} else if (left->type == V_NUM || left->type == V_INT) {
778+
} else if (v_is_type(left, V_NUM) || v_is_type(left, V_INT)) {
779779
var_t *v;
780780

781781
v = v_clone(left);

src/common/extlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int slib_llopen(slib_t * lib) {
277277
return (lib->handle != NULL);
278278
#elif defined(__CYGWIN__)
279279
char win32Path[1024];
280-
cygwin_conv_to_full_win32_path(lib->fullname, win32Path);
280+
cygwin_conv_path(CCP_POSIX_TO_WIN_A, lib->fullname, win32Path, sizeof(win32Path));
281281
lib->handle = LoadLibrary(win32Path);
282282
if (lib->handle == NULL)
283283
panic("SB-LibMgr: error on loading %s\n", win32Path);

src/common/file.c

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,24 @@ int dev_freefilehandle() {
9292
}
9393

9494
/**
95-
*
95+
* returns a file pointer for the given BASIC handle
9696
*/
97-
dev_file_t *dev_getfileptr(int handle) {
98-
handle--; // Warning: BASIC's handles starting from 1
99-
100-
if (handle < 0 || handle >= OS_FILEHANDLES) {
101-
rt_raise(FSERR_HANDLE);
102-
return NULL;
97+
dev_file_t *dev_getfileptr(const int handle) {
98+
dev_file_t *result;
99+
if (!opt_file_permitted) {
100+
rt_raise(ERR_FILE_PERM);
101+
result = NULL;
102+
} else {
103+
// BASIC handles start from 1
104+
int hnd = handle - 1;
105+
if (hnd < 0 || hnd >= OS_FILEHANDLES) {
106+
rt_raise(FSERR_HANDLE);
107+
result = NULL;
108+
} else {
109+
result = &file_table[hnd];
110+
}
103111
}
104-
105-
return &file_table[handle];
112+
return result;
106113
}
107114

108115
/**
@@ -155,6 +162,11 @@ int dev_fopen(int sb_handle, const char *name, int flags) {
155162
dev_file_t *f;
156163
int i;
157164

165+
if (!opt_file_permitted) {
166+
rt_raise(ERR_FILE_PERM);
167+
return 0;
168+
}
169+
158170
if ((f = dev_getfileptr(sb_handle)) == NULL) {
159171
return 0;
160172
}
@@ -427,6 +439,11 @@ int dev_feof(int sb_handle) {
427439
int dev_fremove(const char *file) {
428440
int success, vfslib;
429441

442+
if (!opt_file_permitted) {
443+
rt_raise(ERR_FILE_PERM);
444+
return 0;
445+
}
446+
430447
// common for all, execute driver's function
431448
if ((vfslib = sblmgr_getvfs(file)) != -1) {
432449
success = sblmgr_vfsdirexec(lib_vfs_remove, vfslib, file + 5);
@@ -445,6 +462,11 @@ int dev_fremove(const char *file) {
445462
int dev_fexists(const char *file) {
446463
int vfslib;
447464

465+
if (!opt_file_permitted) {
466+
rt_raise(ERR_FILE_PERM);
467+
return 0;
468+
}
469+
448470
// common for all, execute driver's function
449471
if ((vfslib = sblmgr_getvfs(file)) != -1) {
450472
return sblmgr_vfsdirexec(lib_vfs_exist, vfslib, file + 5);
@@ -462,6 +484,11 @@ int dev_fcopy(const char *file, const char *newfile) {
462484
byte *buf;
463485
dword i, block_size, block_num, remain, file_len;
464486

487+
if (!opt_file_permitted) {
488+
rt_raise(ERR_FILE_PERM);
489+
return 0;
490+
}
491+
465492
if (dev_fexists(file)) {
466493
if (dev_fexists(newfile)) {
467494
if (!dev_fremove(newfile)) {
@@ -539,6 +566,10 @@ int dev_fcopy(const char *file, const char *newfile) {
539566
* returns true on success
540567
*/
541568
int dev_frename(const char *file, const char *newname) {
569+
if (!opt_file_permitted) {
570+
rt_raise(ERR_FILE_PERM);
571+
return 0;
572+
}
542573
if (dev_fcopy(file, newname)) {
543574
return dev_fremove(file);
544575
}
@@ -550,6 +581,10 @@ int dev_frename(const char *file, const char *newname) {
550581
* BUG: no drivers supported
551582
*/
552583
void dev_mkdir(const char *dir) {
584+
if (!opt_file_permitted) {
585+
rt_raise(ERR_FILE_PERM);
586+
return;
587+
}
553588
#if (defined(_Win32) || defined(__MINGW32__)) && !defined(__CYGWIN__)
554589
if (mkdir(dir) != 0) {
555590
err_file(errno);
@@ -566,6 +601,10 @@ void dev_mkdir(const char *dir) {
566601
* BUG: no drivers supported
567602
*/
568603
void dev_rmdir(const char *dir) {
604+
if (!opt_file_permitted) {
605+
rt_raise(ERR_FILE_PERM);
606+
return;
607+
}
569608
if (rmdir(dir) != 0) {
570609
err_file(errno);
571610
}
@@ -724,6 +763,11 @@ int dev_faccess(const char *file) {
724763
int vfslib;
725764
struct stat st;
726765

766+
if (!opt_file_permitted) {
767+
rt_raise(ERR_FILE_PERM);
768+
return 0;
769+
}
770+
727771
// common for all, execute driver's function
728772
if ((vfslib = sblmgr_getvfs(file)) != -1) {
729773
return sblmgr_vfsdirexec(lib_vfs_access, vfslib, file + 5);

src/common/inet.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
#include <config.h>
1515
#endif
1616

17-
#if defined(_Win32)
18-
#include <winsock.h>
19-
#else
2017
#include <string.h>
2118
#include <errno.h>
2219
#include <sys/types.h>
23-
#endif
2420

2521
typedef int socket_t;
2622

0 commit comments

Comments
 (0)