summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/interpreters/bas/Kconfig29
-rw-r--r--apps/interpreters/bas/fs.c24
-rw-r--r--apps/interpreters/bas/global.c11
-rw-r--r--apps/interpreters/bas/statement.c5
4 files changed, 66 insertions, 3 deletions
diff --git a/apps/interpreters/bas/Kconfig b/apps/interpreters/bas/Kconfig
index d47444151..90a8b1211 100644
--- a/apps/interpreters/bas/Kconfig
+++ b/apps/interpreters/bas/Kconfig
@@ -31,4 +31,33 @@ config INTERPRETERS_BAS
- Set CONFIG_LIBM=y in your .config file
if INTERPRETERS_BAS
+
+config INTERPRETER_BAS_HAVE_ENVIRON
+ bool
+ default n
+ depends on EXPERIMENTAL
+ ---help---
+ NuttX does not support the environ variable
+
+config INTERPRETER_BAS_HAVE_SYSCFG
+ bool
+ default n
+ depends on EXPERIMENTAL
+ ---help---
+ NuttX does not support the syscfg() function
+
+config INTERPRETER_BAS_HAVE_SIGINT
+ bool
+ default n
+ depends on EXPERIMENTAL
+ ---help---
+ NuttX does not support the SIGINT signal
+
+config INTERPRETER_BAS_HAVE_SIGQUIT
+ bool
+ default n
+ depends on EXPERIMENTAL
+ ---help---
+ NuttX does not support the SIGQUIT signal
+
endif
diff --git a/apps/interpreters/bas/fs.c b/apps/interpreters/bas/fs.c
index 1e933d441..4a762a0d1 100644
--- a/apps/interpreters/bas/fs.c
+++ b/apps/interpreters/bas/fs.c
@@ -1,5 +1,6 @@
/* BASIC file system interface. */
/* #includes */ /*{{{C}}}*//*{{{*/
+#include <nuttx/config.h>
#include "config.h"
#include <sys/time.h>
@@ -45,7 +46,12 @@ static int capacity;
static int used;
static struct termios origMode,rawMode;
static const int open_mode[4]={ 0, O_RDONLY, O_WRONLY, O_RDWR };
-static struct sigaction old_sigint, old_sigquit;
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
+static struct sigaction old_sigint;
+#endif
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT
+static struct sigaction old_sigquit;
+#endif
static int termchannel;
const char *FS_errmsg;
@@ -381,12 +387,14 @@ static void carriage_return(int chn) /*{{{*/
}
/*}}}*/
#endif
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
static void sigintr(int sig) /*{{{*/
{
FS_intr=1;
FS_allowIntr(0);
}
/*}}}*/
+#endif
int FS_opendev(int chn, int infd, int outfd) /*{{{*/
{
@@ -782,21 +790,33 @@ int FS_truncate(int chn) /*{{{*/
/*}}}*/
void FS_shellmode(int dev) /*{{{*/
{
+#if defined(CONFIG_INTERPRETER_BAS_HAVE_SIGINT) || defined(CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT)
struct sigaction interrupt;
+#endif
if (file[dev]->tty) tcsetattr(file[dev]->infd,TCSADRAIN,&origMode);
+#if defined(CONFIG_INTERPRETER_BAS_HAVE_SIGINT) || defined(CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT)
interrupt.sa_flags=0;
sigemptyset(&interrupt.sa_mask);
interrupt.sa_handler=SIG_IGN;
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
sigaction(SIGINT,&interrupt,&old_sigint);
+#endif
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT
sigaction(SIGQUIT,&interrupt,&old_sigquit);
+#endif
+#endif
}
/*}}}*/
void FS_fsmode(int chn) /*{{{*/
{
if (file[chn]->tty) tcsetattr(file[chn]->infd,TCSADRAIN,&rawMode);
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
sigaction(SIGINT,&old_sigint,(struct sigaction *)0);
+#endif
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT
sigaction(SIGQUIT,&old_sigquit,(struct sigaction *)0);
+#endif
}
/*}}}*/
void FS_xonxoff(int chn, int on) /*{{{*/
@@ -1421,6 +1441,7 @@ int FS_memOutput(int address, int value) /*{{{*/
/*}}}*/
void FS_allowIntr(int on) /*{{{*/
{
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
struct sigaction breakact;
breakact.sa_handler=on ? sigintr : SIG_IGN;
@@ -1428,5 +1449,6 @@ void FS_allowIntr(int on) /*{{{*/
sigaddset(&breakact.sa_mask,SIGINT);
breakact.sa_flags=0;
sigaction(SIGINT,&breakact,(struct sigaction *)0);
+#endif
}
/*}}}*/
diff --git a/apps/interpreters/bas/global.c b/apps/interpreters/bas/global.c
index 8206b5f94..243b7c1eb 100644
--- a/apps/interpreters/bas/global.c
+++ b/apps/interpreters/bas/global.c
@@ -1,5 +1,6 @@
/* Global variables and functions. */
/* #includes */ /*{{{C}}}*//*{{{*/
+#include <nuttx/config.h>
#include "config.h"
#include <sys/times.h>
@@ -38,7 +39,13 @@
#endif
/*}}}*/
+#ifndef CONFIG_INTERPRETER_BAS_HAVE_ENVIRON
extern char **environ;
+#endif
+
+#ifndef RAND_MAX
+# define RAND_MAX 32767
+#endif
static int wildcardmatch(const char *a, const char *pattern) /*{{{*/
{
@@ -1337,7 +1344,11 @@ static struct Value *fn_tan(struct Value *v, struct Auto *stack) /*{{{*/
/*}}}*/
static struct Value *fn_timei(struct Value *v, struct Auto *stack) /*{{{*/
{
+#ifdef CONFIG_INTERPRETER_BAS_HAVE_SYSCFG
return Value_new_INTEGER(v,(unsigned long)(times((struct tms*)0)/(sysconf(_SC_CLK_TCK)/100.0)));
+#else
+ return Value_new_INTEGER(v,(unsigned long)(times((struct tms*)0)/(CLK_TCK/100.0)));
+#endif
}
/*}}}*/
static struct Value *fn_times(struct Value *v, struct Auto *stack) /*{{{*/
diff --git a/apps/interpreters/bas/statement.c b/apps/interpreters/bas/statement.c
index 490e76a98..9e324b885 100644
--- a/apps/interpreters/bas/statement.c
+++ b/apps/interpreters/bas/statement.c
@@ -1,4 +1,5 @@
/* #includes */ /*{{{C}}}*//*{{{*/
+#include <unistd.h>
#include "config.h"
#include <unistd.h>
@@ -571,7 +572,7 @@ struct Value *stmt_DISPLAY(struct Value *value) /*{{{*/
if (eval(value,_("file name"))->type==V_ERROR || (pass!=DECLARE && Value_retype(value,V_STRING)->type==V_ERROR)) return value;
if (pass==INTERPRET && cat(value->u.string.character)==-1)
{
- char *msg=strerror(errno);
+ const char *msg=strerror(errno);
Value_destroy(value);
pc=statementpc;
@@ -1356,7 +1357,7 @@ struct Value *stmt_KILL(struct Value *value) /*{{{*/
if (eval(value,_("file name"))->type==V_ERROR || (pass!=DECLARE && Value_retype(value,V_STRING)->type==V_ERROR)) return value;
if (pass==INTERPRET && unlink(value->u.string.character)==-1)
{
- char *msg=strerror(errno);
+ const char *msg=strerror(errno);
Value_destroy(value);
pc=statementpc;