More global variable name changes for NuttX coding standards compatibility. Make sure that g_bas_end is initially false

This commit is contained in:
Gregory Nutt 2014-11-08 11:23:13 -06:00
parent 021de85bfe
commit 6e013e76fc
5 changed files with 36 additions and 27 deletions

View File

@ -65,6 +65,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
@ -72,8 +76,6 @@
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -149,10 +151,10 @@ static int g_run_restricted;
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
int bas_argc; int g_bas_argc;
char *bas_argv0; char *g_bas_argv0;
char **bas_argv; char **g_bas_argv;
int bas_end; bool g_bas_end;
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
@ -2445,10 +2447,10 @@ void bas_interpreter(void)
{ {
runline(line + 1); runline(line + 1);
Token_destroy(line); Token_destroy(line);
if (FS_istty(STDCHANNEL) && bas_end > 0) if (FS_istty(STDCHANNEL) && g_bas_end)
{ {
FS_putChars(STDCHANNEL, _("END program\n")); FS_putChars(STDCHANNEL, _("END program\n"));
bas_end = 0; g_bas_end = false;
} }
} }
else else

View File

@ -59,6 +59,12 @@
#ifndef __APPS_EXAMPLES_BAS_BAS_H #ifndef __APPS_EXAMPLES_BAS_BAS_H
#define __APPS_EXAMPLES_BAS_BAS_H #define __APPS_EXAMPLES_BAS_BAS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdbool.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@ -70,10 +76,10 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
extern int bas_argc; extern int g_bas_argc;
extern char *bas_argv0; extern char *g_bas_argv0;
extern char **bas_argv; extern char **g_bas_argv;
extern int bas_end; extern bool g_bas_end;
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes

View File

@ -600,14 +600,14 @@ static struct Value *fn_command(struct Value *v, struct Auto *stack)
int i; int i;
Value_new_STRING(v); Value_new_STRING(v);
for (i = 0; i < bas_argc; ++i) for (i = 0; i < g_bas_argc; ++i)
{ {
if (i) if (i)
{ {
String_appendChar(&v->u.string, ' '); String_appendChar(&v->u.string, ' ');
} }
String_appendChars(&v->u.string, bas_argv[i]); String_appendChars(&v->u.string, g_bas_argv[i]);
} }
return v; return v;
@ -626,14 +626,14 @@ static struct Value *fn_commandi(struct Value *v, struct Auto *stack)
Value_new_STRING(v); Value_new_STRING(v);
if (a == 0) if (a == 0)
{ {
if (bas_argv0 != (char *)0) if (g_bas_argv0 != (char *)0)
{ {
String_appendChars(&v->u.string, bas_argv0); String_appendChars(&v->u.string, g_bas_argv0);
} }
} }
else if (a <= bas_argc) else if (a <= g_bas_argc)
{ {
String_appendChars(&v->u.string, bas_argv[a - 1]); String_appendChars(&v->u.string, g_bas_argv[a - 1]);
} }
return v; return v;
@ -653,14 +653,14 @@ static struct Value *fn_commandd(struct Value *v, struct Auto *stack)
Value_new_STRING(v); Value_new_STRING(v);
if (a == 0) if (a == 0)
{ {
if (bas_argv0 != (char *)0) if (g_bas_argv0 != (char *)0)
{ {
String_appendChars(&v->u.string, bas_argv0); String_appendChars(&v->u.string, g_bas_argv0);
} }
} }
else if (a <= bas_argc) else if (a <= g_bas_argc)
{ {
String_appendChars(&v->u.string, bas_argv[a - 1]); String_appendChars(&v->u.string, g_bas_argv[a - 1]);
} }
return v; return v;

View File

@ -177,9 +177,10 @@ int bas_main(int argc, char *argv[])
exit(2); exit(2);
} }
bas_argc = argc - optind; g_bas_argc = argc - optind;
bas_argv = &argv[optind]; g_bas_argv = &argv[optind];
bas_argv0 = runFile; g_bas_argv0 = runFile;
g_bas_end = false;
bas_init(backslash_colon, restricted, uppercase, lpfd); bas_init(backslash_colon, restricted, uppercase, lpfd);
if (runFile) if (runFile)

View File

@ -1315,8 +1315,8 @@ struct Value *stmt_END(struct Value *value)
{ {
if (g_pass == INTERPRET) if (g_pass == INTERPRET)
{ {
g_pc = g_pc.token->u.endpc; g_pc = g_pc.token->u.endpc;
bas_end = 1; g_bas_end = true;
} }
if (g_pass == DECLARE || g_pass == COMPILE) if (g_pass == DECLARE || g_pass == COMPILE)