Browse Source

v3.20d - KenUNIX

* Added a search for profile.bas in Windows
      C:\Bwbasic
 * And Linux
      /usr/share/bwbasic
tags/v3.20d
Jon Foster 2 years ago
parent
commit
22e31c704c
12 changed files with 194 additions and 77 deletions
  1. +30
    -9
      Makefile
  2. +12
    -0
      OME/Desktop/bwbasic.desktop
  3. +10
    -6
      README
  4. +3
    -3
      READMEFIRST
  5. +89
    -54
      bwbasic.c
  6. +12
    -0
      bwbasic.desktop
  7. +16
    -0
      bwbasic.h
  8. BIN
      bwbasic.png
  9. +11
    -0
      bwbasic.sh
  10. +5
    -4
      compile.bat
  11. +5
    -0
      profile.bas
  12. +1
    -1
      stdcomp.bat

+ 30
- 9
Makefile View File

@@ -1,6 +1,6 @@
#
# Makefile for bwbasic on Linux 4-30-2020
# Now version bwbasic-3.20b
# Makefile for bwbasic on Linux 8-9-2020
# Now version bwbasic-3.20d
#
# Tested on Ubuntu 18.04 Had to fix compatabily issues
# Ubuntu 20.04 Had to fix compatabily issues
@@ -18,27 +18,48 @@ CC=gcc
# to have a smaller runtime size
CFLAGS=-s -ansi
LIB=-lm
DEST=/usr/local/bin
DEST=/usr/bin
# HOME=$HOME

bwbasic:
$(CC) $(CFLAGS) -o bwbasic bw*.c $(LIB)
$(CC) $(CFLAGS) -o bwbasic bw*.c $(LIB) -DLINUX
$(CC) $(CFLAGS) -o renum renum.c $(LIB)
ls -l bwbasic renum

# bwbasic and renum runtime. editfl temp file created by renum
clean:
rm -f *.o bwbasic renum editfl
rm -f *.o bwbasic renum editfl core

install:
ls -l bwbasic renum
cp bwbasic renum $(DEST)/.
ls -l $(DEST)/bwbasic $(DEST)/renum
cp bwbasic renum bwbasic.sh $(DEST)/.
ls -l $(DEST)/bwbasic $(DEST)/renum $(DEST)/bwbasic.sh
mkdir -p /usr/share/bwbasic
mkdir -p /usr/share/doc/cbwbasic
mkdir -p /usr/share/doc/bwbasic/docs
mkdir -p $HOME/Desktop
cp BAS-EXAMPLES/* /usr/share/bwbasic/.
cp DOCS/* /usr/share/doc/bwbasic/docs/.
cp README READMEFIRST /usr/share/doc/bwbasic/.
cp COPYING /usr/share/doc/bwbasic/.
cp bwbasic.png /usr/share/pixmaps/.
cp bwbasic.desktop /usr/share/applications/bwbasic.desktop
# cp bwbasic.desktop $HOME/Desktop/.
# chmod 666 $HOME/Desktop/bwbasic/desktop

remove:
rm $(DEST)/bwbasic $(DEST)/renum
rm $(DEST)/bwbasic $(DEST)/renum $(DEST)/bwbasic.sh
rm -r -f /usr/share/bwbasic
rm -r -f /usr/share/doc/bwbasic
rm -f /usr/share/pixmaps/bwbasic.png
rm -f /usr/share/applications/bwbasic.desktop

uninstall:
rm $(DEST)/bwbasic $(DEST)/renum
rm $(DEST)/bwbasic $(DEST)/renum $(DEST)/bwbasic.sh
rm -r -f /usr/share/bwbasic
rm -r -f /usr/share/doc/bwbasic
rm -f /usr/share/pixmaps/bwbasic.png
rm -f /usr/share/applications/bwbasic.desktop

run:
$(DEST)/bwbasic


+ 12
- 0
OME/Desktop/bwbasic.desktop View File

@@ -0,0 +1,12 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Name=Bywater BASIC
GenericName=Bywater BASIC
Type=Application
Exec=/usr/bin/bwbasic.sh
Icon=/usr/share/pixmaps/bwbasic.png
StartupNotify=true
Terminal=true
Categories=Development


+ 10
- 6
README View File

@@ -42,8 +42,8 @@
Version 3.20 modifications by Howard Wulf, AF5NE
4 June 2017

Version 3.20b modifications by Ken Martin
Nov. 2019 Apr. 2020
Version 3.20c modifications by Ken Martin
Nov. 2019 Aug. 2020



@@ -66,10 +66,10 @@ DESCRIPTION:



OBTAINING THE SOURCE CODE:
OBTAINING THE CODE:

The source code for bwbasic-3.20b is available from
https://github.com/kenmartin-unix/Bwbasic-3.20b
The executable code for bwbasic-3.20c is available from
https://github.com/kenmartin-unix/Bwbasic

The source code for older versions bwBASIC is available from
http://bwbasic.sourceforge.net
@@ -94,9 +94,13 @@ A LIST OF BASIC COMMANDS AND FUNCTIONS IMPLEMENTED in bwBASIC:

CHANGE HISTORY

CHANGES FROM 3.20 to 3.20b
CHANGES FROM 3.20 to 3.20c

* General cleanup and bug fixes.
Added a search for profile.bas in Windows
C:\Bwbasic
And Linux
/usr/share/bwbasic

CHANGES FROM 3.10 to 3.20



+ 3
- 3
READMEFIRST View File

@@ -1,4 +1,4 @@
4-16-2020 Updated 4-30-2020 3.20b
4-16-2020 Updated 8-8-2020 3.20d

Bwbasic has been around since the early 1990's
in one form or another and actually quite powerfull.
@@ -10,7 +10,7 @@ If running this under Linux you will need 'gcc' compiler.
To see if it's installed type in gcc --version if OK
then simply do the following:

tar -xf bwbasic-3.20b.tar
tar -xf bwbasic-3.20d.tar

cd <here>

@@ -33,7 +33,7 @@ To remove compiled programs and recompile (5) make clean

That's it.

bwbasic and renum will be in /usr/local/bin
bwbasic and renum will be in /usr/bin

If you want bwbasic to work from a GUI cd GUI
(1) copy bwbasic.sh to a suitable location


+ 89
- 54
bwbasic.c View File

@@ -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 */


+ 12
- 0
bwbasic.desktop View File

@@ -0,0 +1,12 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Name=Bywater BASIC
GenericName=Bywater BASIC
Type=Application
Exec=/usr/bin/bwbasic.sh
Icon=/usr/share/pixmaps/bwbasic.png
StartupNotify=true
Terminal=true
Categories=Development


+ 16
- 0
bwbasic.h View File

@@ -36,6 +36,8 @@
/* */
/* Version 3.20 by Howard Wulf, AF5NE */
/* */
/* Version 3.20d by KenUnix */
/* */
/*---------------------------------------------------------------*/


@@ -448,10 +450,24 @@
** Filename for PROFILE, only used when PROFILE == TRUE
** This file contains the various OPTION commands
**
** If MSDOS C:\Bwbasic\profile.bas
** Else if LINUX see
**
** 1 to open [profile.bas]
** 2 to open [/home/$USER/profile.bas]
** 3 to open [/etc/profile.bas]
**
** Else profile.bas
**
*/
#ifdef MSDOS
#define PROFILENAME "C:\\Bwbasic\\profile.bas"
#else
#define PROFILENAME "profile.bas"
#endif
#endif /* PROFILENAME */


#if FALSE
/*
**


BIN
bwbasic.png View File

Before After
Width: 48  |  Height: 48  |  Size: 3.8 KiB

+ 11
- 0
bwbasic.sh View File

@@ -0,0 +1,11 @@
#!/bin/sh
# 12/14/2019 Ken
# 07/28/2020 enhanced by ChipMaster
[ -z "$BWBASIC" ] && BWBASIC="$HOME/bwbasic"
[ ! -d "$BWBASIC" ] && mkdir "$BWBASIC"
cd "$BWBASIC"
trap 'echo " "; echo "PROGRAM INTERRUPTED"; echo "Press Enter "; read j; exit 1' INT
bwbasic "$@"
# -n = no newline -e interpret special octel numbers \007 = Bell
/bin/echo -n -e "Bwbasic terminated. Press Enter \007"
read j

+ 5
- 4
compile.bat View File

@@ -1,7 +1,7 @@
@echo off
echo 12/13/2019 Ken. bwbasic. Works under Windows 10 using gcc 7.4.0
echo and gcc 8.1.0 64 bit
echo Wait
echo 8-5-2020 Ken. bwbasic. Works under Windows 10 using gcc 7.4.0
echo and gcc 8.1.0 64 bit
echo Wait
echo.

if exist *.o del *.o
@@ -25,7 +25,7 @@ call stdcomp bwx_tty.c
call stdcomp bwd_cmd.c
call stdcomp bwd_fun.c

gcc -s -ansi -o bwbasic.exe bwb_cmd.o bwb_cnd.o bwb_dio.o bwb_exp.o bwb_fnc.o bwb_inp.o bwb_int.o bwb_prn.o bwb_stc.o bwb_str.o bwb_tbl.o bwb_var.o bwbasic.o bwd_cmd.o bwd_fun.o bwx_tty.o
gcc -s -ansi -DMSDOS -o bwbasic.exe bwb_cmd.o bwb_cnd.o bwb_dio.o bwb_exp.o bwb_fnc.o bwb_inp.o bwb_int.o bwb_prn.o bwb_stc.o bwb_str.o bwb_tbl.o bwb_var.o bwbasic.o bwd_cmd.o bwd_fun.o bwx_tty.o

gcc -s -ansi -DMSDOS -o renum.exe renum.c

@@ -49,3 +49,4 @@ echo.
echo --Done--
echo.
@echo on


+ 5
- 0
profile.bas View File

@@ -0,0 +1,5 @@
OPTION TERMINAL ANSI
OPTION EDIT "nano"
OPTION DISABLE COMMAND "renum"
OPTION RENUM ""


+ 1
- 1
stdcomp.bat View File

@@ -1 +1 @@
gcc -w -c -ansi -I . %1 %2 %3 %4 %5 %6 %7 %8 %9
gcc -w -c -ansi -DMSDOS -I . %1 %2 %3 %4 %5 %6 %7 %8 %9

Loading…
Cancel
Save