diff --git a/ChangeLog b/ChangeLog index 11710f8f..44d06298 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-08-11 + Cleanup system var handling, removed os_ver + 2014-08-09 Renamed command "#UNIT-PATH:" to "UNITPATH" Renamed command "#INC:" to "INCLUDE" diff --git a/Makefile.am b/Makefile.am index f1e44d3b..d9344301 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,58 +7,67 @@ SUBDIRS = @BUILD_SUBDIRS@ -EXTRA_DIST = \ - AUTHORS \ - ChangeLog \ - configure.in \ - NEWS \ - README \ - autogen.sh \ - src/platform/gtk/sbgtk.glade \ - src/platform/gtk/sbgtk.gladep \ - src/platform/gtk/debian/changelog \ - src/platform/gtk/debian/control \ - src/platform/gtk/debian/copyright \ - src/platform/gtk/debian/rules \ - src/platform/gtk/debian/sbasic.links \ - src/platform/sdl/fonts/BI1.c \ - src/platform/sdl/fonts/BI2.c \ - src/platform/sdl/fonts/BI5.c \ - src/platform/sdl/fonts/BI7.c \ - src/platform/sdl/fonts/psf2c.c \ - documentation/export_csv.bas \ - documentation/sbasic_ref.csv \ - documentation/HOWTO/HOWTO-DOCUMENT.TXT \ - documentation/HOWTO/HOWTO-PORT.TXT \ - documentation/HOWTO/DEVELOP.TXT \ - documentation/LICENSE \ - documentation/README \ - documentation/README.BCC \ - documentation/README.DEV \ - documentation/README.DOS \ - documentation/README.HELIO \ - documentation/README.PALM \ - documentation/README.UNIX \ - plugins/publish.bas \ - plugins/comment_in.bas \ - plugins/comment_out.bas \ - plugins/dos2unix.bas \ - plugins/indent.bas \ - plugins/help.bas \ - translator/SB.g \ - translator/Makefile \ - translator/Translator.java \ - images/logo.gif \ - images/sb16x16.png \ - images/sb32x32.png \ - images/sb-desktop-16x16.png \ - images/sb-desktop-32x32.png \ - ide/smallbasic.lang \ - ide/small-basic-mode.el \ - ide/smallbasic.syn \ - rpm/README \ +EXTRA_DIST = \ + AUTHORS \ + ChangeLog \ + configure.in \ + NEWS \ + README \ + autogen.sh \ + src/platform/gtk/sbgtk.glade \ + src/platform/gtk/sbgtk.gladep \ + src/platform/gtk/debian/changelog \ + src/platform/gtk/debian/control \ + src/platform/gtk/debian/copyright \ + src/platform/gtk/debian/rules \ + src/platform/gtk/debian/sbasic.links \ + src/platform/sdl/fonts/BI1.c \ + src/platform/sdl/fonts/BI2.c \ + src/platform/sdl/fonts/BI5.c \ + src/platform/sdl/fonts/BI7.c \ + src/platform/sdl/fonts/psf2c.c \ + documentation/export_csv.bas \ + documentation/sbasic_ref.csv \ + documentation/HOWTO/HOWTO-DOCUMENT.TXT \ + documentation/HOWTO/HOWTO-PORT.TXT \ + documentation/HOWTO/DEVELOP.TXT \ + documentation/LICENSE \ + documentation/README \ + documentation/README.BCC \ + documentation/README.DEV \ + documentation/README.DOS \ + documentation/README.HELIO \ + documentation/README.PALM \ + documentation/README.UNIX \ + plugins/publish.bas \ + plugins/comment_in.bas \ + plugins/comment_out.bas \ + plugins/dos2unix.bas \ + plugins/indent.bas \ + plugins/help.bas \ + translator/SB.g \ + translator/Makefile \ + translator/Translator.java \ + images/logo.gif \ + images/sb16x16.png \ + images/sb32x32.png \ + images/sb-desktop-16x16.png \ + images/sb-desktop-32x32.png \ + ide/smallbasic.lang \ + ide/small-basic-mode.el \ + ide/smallbasic.syn \ + rpm/README \ rpm/SPECS/opensuse.spec +install-exec-hook: + (mkdir -p $(DESTDIR)$(pkgdatadir) && \ + mkdir -p $(DESTDIR)$(pkgdatadir)/plugins && \ + mkdir -p $(DESTDIR)$(pkgdatadir)/ide && \ + mkdir -p $(DESTDIR)$(pkgdatadir)/samples && \ + cp documentation/sbasic_ref.csv $(DESTDIR)$(pkgdatadir) && \ + cp plugins/*.* $(DESTDIR)$(pkgdatadir)/plugins && \ + cp ide/*.* $(DESTDIR)$(pkgdatadir)/ide) + deb: fakeroot dpkg-buildpackage diff --git a/debian/changelog b/debian/changelog index 8bf8438b..fe007f3c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +smallbasic (0.11.12) unstable; urgency=low + * Fixed/implemented INCLUDE command + + -- Chris Warren-Smith Sat, 11 August 2014 09:45:25 +1000 + smallbasic (0.11.11) unstable; urgency=low * Built using common code from the android project and SDL diff --git a/samples/distro-examples/tests/call_tau.bas b/samples/distro-examples/tests/call_tau.bas index eb1ad431..aead7e19 100644 --- a/samples/distro-examples/tests/call_tau.bas +++ b/samples/distro-examples/tests/call_tau.bas @@ -20,5 +20,3 @@ rem check system-variables predef.prsys - - diff --git a/samples/distro-examples/tests/output/call_tau.out b/samples/distro-examples/tests/output/call_tau.out index 30d58299..01e233eb 100644 --- a/samples/distro-examples/tests/output/call_tau.out +++ b/samples/distro-examples/tests/output/call_tau.out @@ -10,11 +10,4 @@ message from main message from tau [1,2,3,4] Predefined Variables -OS VER =0x0 -OS NAME=Unix/Linux version 3.13.0-32-generic (buildd@kissel) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 -SB VER =0x0 PI =3.14159265358979 -XMAX =161 -YMAX =42 -CWD =/home/chrisws/src/SmallBASIC/src/platform/unix/ -HOME =/home/chrisws/ diff --git a/samples/distro-examples/tests/predef.bas b/samples/distro-examples/tests/predef.bas index 51f7be69..a42af1a1 100644 --- a/samples/distro-examples/tests/predef.bas +++ b/samples/distro-examples/tests/predef.bas @@ -4,15 +4,5 @@ export prsys sub prsys ? cat(1);"Predefined Variables";cat(0) -? "OS VER =0x"; HEX$(osver) -? "OS NAME="; osname -? "SB VER =0x"; HEX$(sbver) ? "PI ="; pi -? "XMAX ="; xmax -? "YMAX ="; ymax -? "CWD ="; CWD -? "HOME ="; HOME end - - - diff --git a/src/common/brun.c b/src/common/brun.c index 37a561d3..9831e6c1 100755 --- a/src/common/brun.c +++ b/src/common/brun.c @@ -591,32 +591,16 @@ void setsysvar_str(int index, const char *value) { */ void exec_setup_predefined_variables() { char homedir[OS_PATHNAME_SIZE + 1]; -#if defined(_UnixOS) - int l; -#endif // needed here (otherwise task will not updated) ctask->has_sysvars = 1; - setsysvar_int(SYSVAR_OSVER, os_ver); setsysvar_str(SYSVAR_OSNAME, OS_NAME); setsysvar_str(SYSVAR_SBVER, SB_STR_VER); setsysvar_num(SYSVAR_PI, SB_PI); - - // Change from Haraszti - 30/3/2007 Thanks Atilla :) - // setsysvar_int(SYSVAR_XMAX, 159); - // setsysvar_int(SYSVAR_YMAX, 159); - // setsysvar_int(SYSVAR_BPP, 1); setsysvar_int(SYSVAR_XMAX, os_graf_mx - 1); setsysvar_int(SYSVAR_YMAX, os_graf_my - 1); - if (os_graphics) { - setsysvar_int(SYSVAR_BPP, os_color_depth); - } - else { - setsysvar_int(SYSVAR_BPP, 4); - } - // end of change - + setsysvar_int(SYSVAR_BPP, os_graphics ? os_color_depth : 4); setsysvar_int(SYSVAR_TRUE, -1); setsysvar_int(SYSVAR_FALSE, 0); setsysvar_int(SYSVAR_LINECHART, 1); @@ -631,7 +615,7 @@ void exec_setup_predefined_variables() { else { strcpy(homedir, "/tmp/"); } - l = strlen(homedir); + int l = strlen(homedir); if (homedir[l - 1] != OS_DIRSEP) { homedir[l] = OS_DIRSEP; homedir[l + 1] = '\0'; diff --git a/src/common/device.c b/src/common/device.c index e213ba21..e473344f 100644 --- a/src/common/device.c +++ b/src/common/device.c @@ -53,11 +53,6 @@ void termination_handler(int signum) { * initialize all drivers */ int dev_init(int mode, int flags) { -#if defined(_UnixOS) - int verfd; - // struct utsname uts; -#endif - #if defined(DRV_SOUND) drvsound_ok = drvsound_init(); #endif @@ -73,21 +68,6 @@ int dev_init(int mode, int flags) { os_graphics = mode; term_init(); // by default if (mode) { -#if defined(_UnixOS) - char buf[256]; - - if (term_israw()) { - setsysvar_str(SYSVAR_OSNAME, "Unix/RAW"); - } else { - if (getenv("TERM")) { - strcpy(buf, "Unix/Terminal:"); - strcat(buf, getenv("TERM")); - setsysvar_str(SYSVAR_OSNAME, buf); - } else { - setsysvar_str(SYSVAR_OSNAME, "Unix/Stream"); - } - } -#endif if (osd_devinit() == 0) { panic("osd_devinit() failed"); } @@ -107,95 +87,6 @@ int dev_init(int mode, int flags) { } else { dev_fgcolor = 7; dev_bgcolor = 0; -#if USE_TERM_IO - // term_settextcolor(dev_fgcolor, dev_bgcolor); -#endif - } - -#if defined(_UnixOS) - /* - if ( uname(&uts) == 0 ) { - // will use the POSIX's uname() - strcpy(tmp, "Unix/"); - strcat(tmp, uts.machine); - strcat(tmp, "/"); - strcat(tmp, uts.sysname); - setsysvar_str(SYSVAR_OSNAME, tmp); - } - else { - */ - // will try to read /proc/version - verfd = open("/proc/version", O_RDONLY); - if (verfd != -1) { - char *p; - char verstr[256]; - char tmp[300]; - int bytes; - - memset(verstr, 0, 256); - bytes = read(verfd, verstr, 255); - verstr[(bytes < 256) ? bytes : 255] = '\0'; - p = strchr(verstr, '\n'); - if (p) { - *p = '\0'; - } - close(verfd); - - // store name to system constant - strcpy(tmp, "Unix/"); - strcat(tmp, verstr); - setsysvar_str(SYSVAR_OSNAME, tmp); - - // build OSVER - if ((p = strstr(verstr, "ersion")) != NULL) { - long vi = 0; - int dg = 0; - - p += 6; - while (*p == ' ' || *p == '\t') { - p++; - } - while (*p) { - if (is_digit(*p)) { - vi = (vi << 4) + (*p - '0'); - dg++; - } else if (*p == '.') { - switch (dg) { - case 0: - vi = vi << 8; - break; - case 1: - vi = vi << 4; - break; - }; - - dg = 0; - } - else { - break; - } - - p++; - } // while (*p) - - os_ver = vi; - } // if ver - } // verfd - - setsysvar_int(SYSVAR_OSVER, os_ver); -#elif defined(_DOS) - os_ver = ((_osmajor << 16) | (_osminor)) << 8; - setsysvar_int(SYSVAR_OSVER, os_ver); -#else - setsysvar_int(SYSVAR_OSVER, os_ver); -#endif - - setsysvar_int(SYSVAR_XMAX, os_graf_mx - 1); - setsysvar_int(SYSVAR_YMAX, os_graf_my - 1); - if (os_graphics) { - setsysvar_int(SYSVAR_BPP, os_color_depth); - } else { - setsysvar_int(SYSVAR_BPP, 4); } #if USE_TERM_IO && !defined(__MINGW32__) diff --git a/src/common/device.h b/src/common/device.h index 5d4f7a20..5dfb7294 100644 --- a/src/common/device.h +++ b/src/common/device.h @@ -100,14 +100,8 @@ void g_line(int x1, int y1, int x2, int y2, void (*dotproc) (int, int)); * Globals are needed for speed and for memory-usage optimization * * @code - * dword os_ver; // OS version (ex: 0x330 for PalmOS 3.3) - * * byte os_charset; // System's charset (see os_charset_codes) * - * byte use_sony_clie; // True if the program runs under a Sony CLIE - * - * UInt16 sony_refHR; // Sony's HiRes lib ref - * * byte os_color; // True if the output has real colors (256+ colors) * * dword os_color_depth; // The number of bits of the supported colors @@ -144,18 +138,11 @@ enum os_charset_codes { }; #if !defined(DEVICE_MODULE) -extern dword os_ver; // OS version (ex: 0x330 for PalmOS 3.3) extern byte os_charset; -#if defined(SONY_CLIE) -extern byte use_sony_clie; // true if the program runs under a Sony CLIE -extern UInt16 sony_refHR; // Sony's HiRes lib ref -#endif - -extern byte os_color; // true if the output has real colors (256+ -// colors) +extern byte os_color; // true if the output has real colors (256+ colors) extern dword os_color_depth; // the number of bits of the supported colors -// (ex: 8 for 256 colors, 15 or 16 for 64K, 24 or 32 for 1.6M) + // (ex: 8 for 256 colors, 15 or 16 for 64K, 24 or 32 for 1.6M) extern byte os_graphics; // non-zero if the driver supports graphics extern int os_graf_mx; // graphic mode: maximum x extern int os_graf_my; // graphic mode: maximum y diff --git a/src/common/scan.c b/src/common/scan.c index f21a2fed..10b61a62 100644 --- a/src/common/scan.c +++ b/src/common/scan.c @@ -19,6 +19,12 @@ #include "common/messages.h" #include "languages/keywords.en.c" +char *comp_array_uds_field(char *p, bc_t * bc); +void comp_text_line(char *text); +addr_t comp_search_bc(addr_t ip, code_t code); +extern void expr_parser(bc_t * bc); +extern void sc_raise2(const char *fmt, int line, const char *buff); // sberr + #define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1) #define LEN_OPTION STRLEN(LCN_OPTION) #define LEN_IMPORT STRLEN(LCN_IMPORT_WRS) @@ -37,12 +43,6 @@ #define LEN_CSTR STRLEN(LCN_CSTR) #define LEN_COMMAND STRLEN(LCN_COMMAND) -char *comp_array_uds_field(char *p, bc_t * bc); -void comp_text_line(char *text); -addr_t comp_search_bc(addr_t ip, code_t code); -extern void expr_parser(bc_t * bc); -extern void sc_raise2(const char *fmt, int line, const char *buff); // sberr - #define SKIP_SPACES(p) \ while (*p == ' ' || *p == '\t') { \ p++; \ diff --git a/src/platform/android/jni/runtime.cpp b/src/platform/android/jni/runtime.cpp index 6e923437..9bd35a60 100644 --- a/src/platform/android/jni/runtime.cpp +++ b/src/platform/android/jni/runtime.cpp @@ -686,7 +686,6 @@ void maAlert(const char *title, const char *message, const char *button1, // sbasic implementation // int osd_devinit(void) { - setsysvar_str(SYSVAR_OSNAME, "Android"); runtime->clearSoundQueue(); runtime->setRunning(true); return 1; diff --git a/src/platform/fltk/EditorWidget.cxx b/src/platform/fltk/EditorWidget.cxx index c2db1454..eb8ab289 100644 --- a/src/platform/fltk/EditorWidget.cxx +++ b/src/platform/fltk/EditorWidget.cxx @@ -632,7 +632,7 @@ bool EditorWidget::checkSave(bool discard) { const char *msg = "The current file has not been saved.\n" "Would you like to save it now?"; int r = discard ? choice(msg, "Save", "Discard", "Cancel") : choice(msg, "Save", "Cancel", 0); - if (r == 0) { + if (discard ? (r == 2) : (r == 1)) { save_file(); // Save the file return !dirty; } diff --git a/src/platform/fltk/MainWindow.cxx b/src/platform/fltk/MainWindow.cxx index 504d3d30..9fb1b956 100644 --- a/src/platform/fltk/MainWindow.cxx +++ b/src/platform/fltk/MainWindow.cxx @@ -71,13 +71,8 @@ void updateForm(const char *s); void closeForm(); bool isFormActive(); -#if defined(WIN32) #define CHOICE_EXIT 2 #define CHOICE_BREAK 1 -#else -#define CHOICE_EXIT 0 -#define CHOICE_BREAK 1 -#endif // scan for fixed pitch fonts in the background struct ScanFont { @@ -446,7 +441,8 @@ void MainWindow::quit(fltk::Widget *w, void *eventData) { } exit(0); } else { - switch (choice("Terminate running program?", "*Exit", "Break", "Cancel")) { + int n = choice("Terminate running program?", "*Exit", "Break", "Cancel"); + switch (n) { case CHOICE_EXIT: exit(0); case CHOICE_BREAK: diff --git a/src/platform/fltk/dev_fltk.cxx b/src/platform/fltk/dev_fltk.cxx index a40d75e0..2a9cd0bf 100644 --- a/src/platform/fltk/dev_fltk.cxx +++ b/src/platform/fltk/dev_fltk.cxx @@ -96,10 +96,8 @@ int osd_devinit() { os_graf_mx = wnd->_out->w(); os_graf_my = wnd->_out->h(); - os_ver = FL_MAJOR_VERSION + FL_MINOR_VERSION + FL_PATCH_VERSION; os_color = 1; os_color_depth = 16; - setsysvar_str(SYSVAR_OSNAME, "FLTK"); if (SharedImage::first_image) { SharedImage::first_image->clear_cache(); }