|
|
@@ -36,7 +36,7 @@ |
|
|
|
/* */ |
|
|
|
/* Version 3.20 by Howard Wulf, AF5NE */ |
|
|
|
/* */ |
|
|
|
/* Version 3.20b by Ken Martin */ |
|
|
|
/* Version 3.20d by Ken Martin */ |
|
|
|
/* */ |
|
|
|
/*---------------------------------------------------------------*/ |
|
|
|
|
|
|
@@ -83,7 +83,7 @@ static char *Banner[] = { |
|
|
|
" ## ## ## ## ## ## ## ## ##", |
|
|
|
" ######## ## ## ###### #### ###### ", |
|
|
|
" ", |
|
|
|
"Bywater BASIC Interpreter, version 3.20b ", |
|
|
|
"Bywater BASIC Interpreter, version 3.20d ", |
|
|
|
"Copyright (c) 1993, Ted A. Campbell ", |
|
|
|
"Copyright (c) 1995-1997 , Jon B. Volkoff ", |
|
|
|
"Copyright (c) 2014-2017 , Howard Wulf, AF5NE ", |
|
|
@@ -243,7 +243,7 @@ break_mes (int x /* Parameter 'x' is never used */ ) |
|
|
|
assert( My->CurrentVersion != NULL ); |
|
|
|
|
|
|
|
|
|
|
|
if (My->ERR < 0) /* in break_mes(), do not make a bad situation worse */ |
|
|
|
if (My->ERR < 0) /* in break_mes(), do not make a bad situation worse */ |
|
|
|
{ |
|
|
|
/* an error has already ben reported */ |
|
|
|
} |
|
|
@@ -644,8 +644,8 @@ process_basic_line (char *buffer) |
|
|
|
else if (is_numconst (buffer) == TRUE) |
|
|
|
{ |
|
|
|
/*-----------------------------------------------------------------*/ |
|
|
|
/* Another possibility: if buffer is a numeric constant, */ |
|
|
|
/* then delete the indicated line number (JBV) */ |
|
|
|
/* Another possibility: if buffer is a numeric constant, */ |
|
|
|
/* then delete the indicated line number (JBV) */ |
|
|
|
/*-----------------------------------------------------------------*/ |
|
|
|
/* 100 */ |
|
|
|
int LineNumber; |
|
|
@@ -700,7 +700,40 @@ execute_profile (char *FileName) |
|
|
|
assert (FileName != NULL); |
|
|
|
|
|
|
|
My->NextValidLineNumber = MINLIN; |
|
|
|
|
|
|
|
#ifdef LINUX |
|
|
|
/* Begin 20200806 ChipMaster@YeOlPiShack.net Patch -- |
|
|
|
* |
|
|
|
* on *nix check the current folder, user's home folder and then /etc for |
|
|
|
* the profile script |
|
|
|
* |
|
|
|
* WARN: I assume that $HOME and FileName are reasonably sized. If one |
|
|
|
* or the other are oversized then an attempt to load a weird-named |
|
|
|
* script will happen. |
|
|
|
* |
|
|
|
* 1 to open [profile.bas] |
|
|
|
* 2 to open [/home/$USER/profile.bas] |
|
|
|
* 3 to open [/etc/profile.bas] |
|
|
|
* */ |
|
|
|
char pname[1024]; |
|
|
|
pname[0]=pname[sizeof(pname)-1]=0; |
|
|
|
profile = fopen (FileName, "r"); |
|
|
|
if(profile == NULL) { |
|
|
|
strncpy(pname, getenv("HOME"), sizeof(pname)-1); |
|
|
|
if(pname[0]) { |
|
|
|
strncat(strcat(pname, "/"), FileName, sizeof(pname)-strlen(pname)-1); |
|
|
|
profile = fopen (pname, "r"); |
|
|
|
} |
|
|
|
} |
|
|
|
if(profile == NULL) { |
|
|
|
strncat(strcpy(pname, "/etc/"), FileName, sizeof(pname)-6); |
|
|
|
profile = fopen(pname, "r"); |
|
|
|
} |
|
|
|
#else |
|
|
|
profile = fopen (FileName, "r"); |
|
|
|
#endif |
|
|
|
/* End 20200806 Patch */ |
|
|
|
|
|
|
|
if (profile == NULL) |
|
|
|
{ |
|
|
|
/* NOT FOUND */ |
|
|
@@ -728,8 +761,10 @@ execute_profile (char *FileName) |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
The profile only exists to allow executing OPTION ... commands. No other use is supported. |
|
|
|
The profile only exists to allow executing OPTION ... commands. |
|
|
|
No other use is supported. |
|
|
|
*/ |
|
|
|
|
|
|
|
{ |
|
|
|
char *tbuf; |
|
|
|
int tlen; |
|
|
@@ -831,12 +866,14 @@ main (int argc, char **argv) |
|
|
|
execute_profile (PROFILENAME); |
|
|
|
#endif |
|
|
|
|
|
|
|
/* check to see if there is a program file: but do this only the first time around! */ |
|
|
|
/* check to see if there is a program file: but do |
|
|
|
* this only the first time around! */ |
|
|
|
for (i = 1; i < argc; i++) |
|
|
|
{ |
|
|
|
/* |
|
|
|
SYNTAX: bwbasic [ --profile profile.bas ] [ --tape tapefile.inp ] [ program.bas ] |
|
|
|
*/ |
|
|
|
SYNTAX: |
|
|
|
bwbasic [ --profile profile.bas ] [ --tape tapefile.inp ] [ program.bas ] |
|
|
|
*/ |
|
|
|
if (bwb_stricmp (argv[i], "--profile") == 0 |
|
|
|
|| bwb_stricmp (argv[i], "-p") == 0 |
|
|
|
|| bwb_stricmp (argv[i], "/profile") == 0 |
|
|
@@ -936,8 +973,8 @@ bwb_interact (void) |
|
|
|
if (My->AutomaticLineNumber > 0 && My->AutomaticLineIncrement > 0) |
|
|
|
{ |
|
|
|
/* AUTO 100, 10 */ |
|
|
|
char *zbuf; /* end of the prompt, start of the response */ |
|
|
|
int zlen; /* length of the prompt */ |
|
|
|
char *zbuf; /* end of the prompt, start of the response */ |
|
|
|
int zlen; /* length of the prompt */ |
|
|
|
char LineExists; |
|
|
|
LineType *l; |
|
|
|
|
|
|
@@ -962,7 +999,7 @@ bwb_interact (void) |
|
|
|
zlen = bwb_strlen (tbuf); |
|
|
|
bwx_input (tbuf, FALSE, zbuf, tlen - zlen); |
|
|
|
zbuf[-1] = ' '; /* remove LineExists indicator */ |
|
|
|
CleanLine (zbuf); /* JBV */ |
|
|
|
CleanLine (zbuf); /* JBV */ |
|
|
|
if (is_empty_string (zbuf)) |
|
|
|
{ |
|
|
|
/* empty response */ |
|
|
@@ -972,7 +1009,7 @@ bwb_interact (void) |
|
|
|
An empty response with an existing line, |
|
|
|
causes AUTO to continue with the next line, |
|
|
|
leaving the current line intact. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
My->AutomaticLineNumber += My->AutomaticLineIncrement; |
|
|
|
} |
|
|
|
else |
|
|
@@ -980,7 +1017,7 @@ bwb_interact (void) |
|
|
|
/* |
|
|
|
An empty response with a non-existing line, |
|
|
|
causes AUTO to terminate. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
My->AutomaticLineNumber = 0; |
|
|
|
My->AutomaticLineIncrement = 0; |
|
|
|
} |
|
|
@@ -1124,22 +1161,20 @@ bwb_fload (char *FileName) |
|
|
|
FILE *file; |
|
|
|
char *tbuf; |
|
|
|
int tlen; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Magic_Word = "%INCLUDE "; /* SYNTAX: %INCLUDE literal.file.name */ |
|
|
|
Magic_Length = bwb_strlen (Magic_Word); |
|
|
|
tbuf = My->MaxLenBuffer; |
|
|
|
tlen = MAXLEN; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
Just in case you are wondering... |
|
|
|
Although this handles the most common cases, it does not handle all possible cases. |
|
|
|
Although this handles the most common cases, it does not |
|
|
|
handle all possible cases. |
|
|
|
The correct solution is to provide the actual filename (with extension), |
|
|
|
as it exists in the operating system. |
|
|
|
*/ |
|
|
|
|
|
|
|
file = nice_open (FileName); |
|
|
|
if (file == NULL) |
|
|
|
{ |
|
|
@@ -1255,7 +1290,8 @@ FindClassicStatementEnd (char *C) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/* not a special case, so split on the first unquoted OptionCommentChar or OptionStatementChar */ |
|
|
|
/* not a special case, so split on the first unquoted |
|
|
|
* OptionCommentChar or OptionStatementChar */ |
|
|
|
while (*C != NulChar) |
|
|
|
{ |
|
|
|
if (*C == My->CurrentVersion->OptionQuoteChar) |
|
|
@@ -1381,10 +1417,6 @@ ImportClassicIfThenElse (char *InBuffer) |
|
|
|
Input = InBuffer; |
|
|
|
Output = OutBuffer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (My->CurrentVersion->OptionStatementChar == NulChar) |
|
|
|
{ |
|
|
|
/* DO NOTHING: All IFs must be STANDARD or STRUCTURED */ |
|
|
@@ -1710,8 +1742,8 @@ bwb_ladd (char *buffer, LineType * p, int IsUser) |
|
|
|
} |
|
|
|
else if (IS_CHAR (BreakChar, My->CurrentVersion->OptionCommentChar)) |
|
|
|
{ |
|
|
|
/* ThisStatment will turn out to be the last */ |
|
|
|
*ThisStatement = My->CurrentVersion->OptionCommentChar; |
|
|
|
/* ThisStatment will turn out to be the last 08082020 Ken ? */ |
|
|
|
* ThisStatement = My->CurrentVersion->OptionCommentChar; |
|
|
|
} |
|
|
|
else if (IS_CHAR (BreakChar, My->CurrentVersion->OptionStatementChar)) |
|
|
|
{ |
|
|
@@ -1828,7 +1860,7 @@ bwb_ladd (char *buffer, LineType * p, int IsUser) |
|
|
|
fprintf (My->SYSOUT->cfp, "MISSING SPACE AFTER LINE NUMBER: %s\n", |
|
|
|
buffer); |
|
|
|
ResetConsoleColumn (); |
|
|
|
My->ERR = -1; /* bwb_ladd, MISSING SPACE AFTER LINE NUMBER */ |
|
|
|
My->ERR = -1; /* bwb_ladd, MISSING SPACE AFTER LINE NUMBER */ |
|
|
|
} |
|
|
|
/* newuffer does NOT contain the line number */ |
|
|
|
newbuffer += l->position; |
|
|
@@ -1880,7 +1912,7 @@ bwb_ladd (char *buffer, LineType * p, int IsUser) |
|
|
|
"ILLEGAL COMMAND AFTER LINE NUMBER: %d %s\n", l->number, |
|
|
|
l->buffer); |
|
|
|
ResetConsoleColumn (); |
|
|
|
My->ERR = -1; /* bwb_ladd, ILLEGAL COMMAND AFTER LINE NUMBER */ |
|
|
|
My->ERR = -1; /* bwb_ladd, ILLEGAL COMMAND AFTER LINE NUMBER */ |
|
|
|
} |
|
|
|
/* |
|
|
|
** |
|
|
@@ -1972,7 +2004,7 @@ bwb_xtxtline (char *buffer) |
|
|
|
/* execute the line as BASIC command line */ |
|
|
|
if (bwb_incexec ()) |
|
|
|
{ |
|
|
|
My->StackHead->line = My->UserMarker->next; /* and set current line in it */ |
|
|
|
My->StackHead->line = My->UserMarker->next; /* and set current line in it */ |
|
|
|
My->StackHead->ExecCode = EXEC_NORM; |
|
|
|
} |
|
|
|
} |
|
|
@@ -2122,7 +2154,8 @@ bwx_Error (int ERR, char *ErrorMessage) |
|
|
|
{ |
|
|
|
/* |
|
|
|
ERR is the error number |
|
|
|
ErrorMessage is used to override the default error message, and is usually NULL |
|
|
|
ErrorMessage is used to override the default error |
|
|
|
message, and is usually NULL |
|
|
|
*/ |
|
|
|
assert( My != NULL ); |
|
|
|
|
|
|
@@ -2135,11 +2168,11 @@ bwx_Error (int ERR, char *ErrorMessage) |
|
|
|
** |
|
|
|
*/ |
|
|
|
My->IsErrorPending = FALSE; /* bwx_Error, ERR == 0 */ |
|
|
|
My->ERR = 0; /* bwx_Error, ERR == 0 */ |
|
|
|
My->ERL = NULL; /* bwx_Error, ERR == 0 */ |
|
|
|
bwb_strcpy (My->ERROR4, ""); /* bwx_Error, ERR == 0 */ |
|
|
|
My->ERR = 0; /* bwx_Error, ERR == 0 */ |
|
|
|
My->ERL = NULL; /* bwx_Error, ERR == 0 */ |
|
|
|
bwb_strcpy (My->ERROR4, ""); /* bwx_Error, ERR == 0 */ |
|
|
|
return FALSE; |
|
|
|
case 6: /* WARN_OVERFLOW */ |
|
|
|
case 6: /* WARN_OVERFLOW */ |
|
|
|
case 11: /* WARN_DIVISION_BY_ZERO */ |
|
|
|
case 15: /* WARN_STRING_TOO_LONG */ |
|
|
|
/* |
|
|
@@ -2189,9 +2222,9 @@ bwx_Error (int ERR, char *ErrorMessage) |
|
|
|
** only keep the first pending error to occur |
|
|
|
** |
|
|
|
*/ |
|
|
|
My->IsErrorPending = TRUE; /* bwx_Error, ERR != 0 */ |
|
|
|
My->ERR = ERR; /* bwx_Error, ERR != 0 */ |
|
|
|
My->ERL = NULL; /* bwx_Error, ERR != 0 */ |
|
|
|
My->IsErrorPending = TRUE; /* bwx_Error, ERR != 0 */ |
|
|
|
My->ERR = ERR; /* bwx_Error, ERR != 0 */ |
|
|
|
My->ERL = NULL; /* bwx_Error, ERR != 0 */ |
|
|
|
bwb_strcpy (My->ERROR4, ""); /* bwx_Error, ERR != 0 */ |
|
|
|
if (My->StackHead) |
|
|
|
{ |
|
|
@@ -2346,9 +2379,9 @@ bwb_execline (void) |
|
|
|
{ |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** USER line in console |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** |
|
|
|
** fall thru to the DEFAULT ERROR HANDLER |
|
|
|
** |
|
|
@@ -2370,9 +2403,9 @@ bwb_execline (void) |
|
|
|
{ |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** ON ERROR RESUME NEXT |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** |
|
|
|
*/ |
|
|
|
assert (r != NULL); |
|
|
@@ -2387,9 +2420,9 @@ bwb_execline (void) |
|
|
|
{ |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** ON ERROR GOTO 0 |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** |
|
|
|
** fall thru to the DEFAULT ERROR HANDLER |
|
|
|
** |
|
|
@@ -2399,9 +2432,9 @@ bwb_execline (void) |
|
|
|
{ |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** RECURSION |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------------- |
|
|
|
** |
|
|
|
** For example: |
|
|
|
** 10 ON ERROR GOTO 20 |
|
|
@@ -2425,12 +2458,13 @@ bwb_execline (void) |
|
|
|
{ |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------- |
|
|
|
** OPTION ERROR GOSUB |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------- |
|
|
|
** |
|
|
|
** RETURN should act like RESUME NEXT... |
|
|
|
** Execution resumes at the statement immediately following the one which caused the error. |
|
|
|
** Execution resumes at the statement immediately following |
|
|
|
** the one which caused the error. |
|
|
|
** For structured commands, this is the bottom line of the structure. |
|
|
|
** |
|
|
|
*/ |
|
|
@@ -2470,9 +2504,9 @@ bwb_execline (void) |
|
|
|
{ |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------- |
|
|
|
** OPTION ERROR GOTO |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** --------------------------------------------------------------- |
|
|
|
** |
|
|
|
*/ |
|
|
|
x->position = 0; /* start of line */ |
|
|
@@ -2487,9 +2521,9 @@ bwb_execline (void) |
|
|
|
} |
|
|
|
/* |
|
|
|
** |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** ----------------------------------------------------------------------- |
|
|
|
** DEFAULT ERROR HANDLER (FATAL) |
|
|
|
** ------------------------------------------------------------------------- |
|
|
|
** ----------------------------------------------------------------------- |
|
|
|
** |
|
|
|
*/ |
|
|
|
/* |
|
|
@@ -2560,7 +2594,7 @@ bwb_execline (void) |
|
|
|
bwb_clrexec (); |
|
|
|
SetOnError (0); |
|
|
|
|
|
|
|
My->ERR = -1; /* in bwb_execline(), default error handler */ |
|
|
|
My->ERR = -1; /* in bwb_execline(), default error handler */ |
|
|
|
|
|
|
|
|
|
|
|
/* reset the break handler */ |
|
|
@@ -3640,3 +3674,4 @@ bwb_vector( LineType *l ) |
|
|
|
} |
|
|
|
|
|
|
|
/* EOF */ |
|
|
|
|