Download raw body.
[update] Brandy 1.20.1 -> 1.23.2
I noticed that Brandy (BBC BASIC interpreter) hasn't been updated since
2014 and the SDL version is broken on my machine as well (amd64).
https://sourceforge.net/projects/brandy/files/brandy/brandy-1.20/
It also has a lot of bugs that are left unfixed because it's no longer
maintained:
https://sourceforge.net/p/brandy/bugs/
Thankfully there's an updated fork of the project that's continually
being worked on called MatrixBrandy:
http://brandy.matrixnetwork.co.uk/
It fixes a lot of the bugs found in the original project and from what
I can tell is still compatible. You'll notice that MatrixBrandy says
BBC BASIC VI while Brandy says BBC BASIC V, but apparently Brandy has
always been BBC BASIC VI this whole time so it shouldn't break people's
programs. From the changelogs:
> Change identifier to BASIC VI (which is BASIC V with 64-bit FP maths,
which is what Brandy has always done)
http://brandy.matrixnetwork.co.uk/ChangeLog
Since I'm studying BBC BASIC right now and using this program, I'd like
to be the maintainer for the port.
Aside from bumping the version, I also made patches to switch out
strcat/strcpy/strcmp/sprintf where I can as recommended by
https://www.openbsd.org/faq/ports/guide.html
You can test the port by running the examples provided. Here are some
favorites:
$ brandy-sdl /usr/local/share/examples/brandy/BubbleUniverse
$ brandy-sdl /usr/local/share/examples/brandy/Snow
$ brandy /usr/local/share/examples/brandy/hex
OK?
--
he/him
jagtalon.net
weirder.earth/@jag
Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/brandy/Makefile,v
diff -u -p -u -r1.6 Makefile
--- Makefile 26 Sep 2023 12:02:00 -0000 1.6
+++ Makefile 2 Aug 2024 03:42:01 -0000
@@ -1,42 +1,50 @@
-COMMENT = interpreter for BBC Basic (Basic V)
+COMMENT = interpreter for BBC Basic (Basic VI)
-DISTNAME = brandy-1.20.1
-REVISION = 1
+V = 1.23.2
+DISTNAME = MatrixBrandy-${V}
+PKGNAME = brandy-${V}
+EXTRACT_SUFX = .tar.xz
CATEGORIES = lang
-HOMEPAGE = http://jaguar.orpheusweb.co.uk/branpage.html
+HOMEPAGE = http://brandy.matrixnetwork.co.uk/
+MAINTAINER = Jag Talon <jag@aangat.lahat.computer>
# GPLv2+
PERMIT_PACKAGE = Yes
-WANTLIB += SDL c m
+WANTLIB += SDL c m pthread X11
-SITES = ${SITE_SOURCEFORGE:=brandy/}
+SITES = http://brandy.matrixnetwork.co.uk/releases/
LIB_DEPENDS += devel/sdl
+USE_GMAKE = Yes
-CFLAGS += -I${LOCALBASE}/include/SDL
-LDFLAGS += -L${LOCALBASE}/lib
-
-MAKE_FLAGS = CC="${CC}" CFLAGS="${CFLAGS}" LD="${CC}" LDFLAGS="${LDFLAGS}"
-
+MAKE_FLAGS = CC="${CC}" LD="${CC}"
MAKE_FILE = makefile
NO_TEST = Yes
post-build:
cd ${WRKSRC}; \
- ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} -f makefile.text
+ ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} -f makefile.text clean
+
+ cd ${WRKSRC}; \
+ ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} -f makefile.text all
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/tbrandy ${PREFIX}/bin/brandy
${INSTALL_PROGRAM} ${WRKSRC}/brandy ${PREFIX}/bin/brandy-sdl
+
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/brandy
- ${INSTALL_DATA} ${WRKSRC}/docs/basic ${PREFIX}/share/doc/brandy
- ${INSTALL_DATA} ${WRKSRC}/docs/messages ${PREFIX}/share/doc/brandy
- ${INSTALL_DATA} ${WRKSRC}/docs/use ${PREFIX}/share/doc/brandy
+ ${INSTALL_DATA} ${WRKSRC}/docs/* ${PREFIX}/share/doc/brandy
+
${INSTALL_DATA_DIR} ${PREFIX}/share/examples/brandy
- ${INSTALL_DATA} ${WRKSRC}/examples/* ${PREFIX}/share/examples/brandy
+ ${INSTALL_DATA} ${WRKSRC}/examples/[!Mode7]* ${PREFIX}/share/examples/brandy
+
+ ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/brandy/Mode7
+ ${INSTALL_DATA} ${WRKSRC}/examples/Mode7/* ${PREFIX}/share/examples/brandy/Mode7
+
+
.include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/lang/brandy/distinfo,v
diff -u -p -u -r1.1.1.1 distinfo
--- distinfo 19 Mar 2017 21:49:31 -0000 1.1.1.1
+++ distinfo 2 Aug 2024 03:42:01 -0000
@@ -1,2 +1,2 @@
-SHA256 (brandy-1.20.1.tar.gz) = YiPgbFQf7qxKWrrXM/3g0Uxuveta0DbAPQ+r5C/vA+w=
-SIZE (brandy-1.20.1.tar.gz) = 422587
+SHA256 (MatrixBrandy-1.23.2.tar.xz) = CI8WhMIBtzn6MObxvjlDNGNitQjbMpUWoZWN9tAXyQA=
+SIZE (MatrixBrandy-1.23.2.tar.xz) = 461888
Index: patches/patch-makefile
===================================================================
RCS file: /cvs/ports/lang/brandy/patches/patch-makefile,v
diff -u -p -u -r1.2 patch-makefile
--- patches/patch-makefile 11 Mar 2022 19:28:51 -0000 1.2
+++ patches/patch-makefile 2 Aug 2024 03:42:01 -0000
@@ -1,11 +1,24 @@
---- makefile.orig Sat Mar 18 21:34:08 2017
-+++ makefile Sat Mar 18 21:35:05 2017
-@@ -3,7 +3,7 @@
- CC = gcc
- LD = gcc
+- remove git.mk since we're not in a git repo
+- remove -ldl and -lrt since they're not needed
+
+Index: makefile
+--- makefile.orig
++++ makefile
+@@ -5,15 +5,13 @@ LD = gcc
+ STRIP = strip
+ ADDFLAGS = ${BRANDY_BUILD_FLAGS}
--CFLAGS += -g -DDEBUG -I/usr/include/SDL -DUSE_SDL
-+CFLAGS += -DUSE_SDL
- CFLAGS2 = -O2 -I/usr/include/SDL -DUSE_SDL
+-include build/git.mk
+-
+ #CFLAGS = -g -DDEBUG $(shell sdl-config --cflags) -I/usr/local/include/SDL -DUSE_SDL -DDEFAULT_IGNORE -Wall $(GITFLAGS) $(ADDFLAGS)
+ #CFLAGS = -g $(shell sdl-config --cflags) -I/usr/local/include/SDL -DUSE_SDL -DDEFAULT_IGNORE -Wall $(GITFLAGS) $(ADDFLAGS)
+-CFLAGS = -O3 -fPIE $(shell sdl-config --cflags) -DUSE_SDL -DDEFAULT_IGNORE -Wall $(GITFLAGS) $(ADDFLAGS)
++CFLAGS = -O3 -fPIE $(shell sdl-config --cflags) -DUSE_SDL -DDEFAULT_IGNORE -Wall -DBRANDY_RELEASE $(ADDFLAGS)
LDFLAGS +=
+
+-LIBS = -lm $(shell sdl-config --libs) -ldl -pthread -lrt -lX11
++LIBS = -lm $(shell sdl-config --libs) -pthread -lX11
+
+ SRCDIR = src
+
Index: patches/patch-makefile_text
===================================================================
RCS file: /cvs/ports/lang/brandy/patches/patch-makefile_text,v
diff -u -p -u -r1.2 patch-makefile_text
--- patches/patch-makefile_text 11 Mar 2022 19:28:51 -0000 1.2
+++ patches/patch-makefile_text 2 Aug 2024 03:42:01 -0000
@@ -1,11 +1,24 @@
---- makefile.text.orig Thu Jun 27 14:56:55 2013
-+++ makefile.text Tue Mar 14 22:53:59 2017
-@@ -3,7 +3,7 @@
- CC = gcc
- LD = gcc
+- remove git.mk since we're not in a git repo
+- remove -ldl and -lrt since they're not needed
+
+Index: makefile.text
+--- makefile.text.orig
++++ makefile.text
+@@ -5,15 +5,13 @@ LD = gcc
+ STRIP = strip
+ ADDFLAGS = ${BRANDY_BUILD_FLAGS}
--CFLAGS += -g -DDEBUG -DNO_SDL
-+CFLAGS += -DNO_SDL
- CFLAGS2 = -O2 -DNO_SDL
+-include build/git.mk
+-
+ #CFLAGS = -g -DDEBUG -I/usr/include/SDL -DNO_SDL -DDEFAULT_IGNORE -Wall $(GITFLAGS) $(ADDFLAGS)
+ #CFLAGS = -g -I/usr/include/SDL -DNO_SDL -DDEFAULT_IGNORE -Wall $(GITFLAGS) $(ADDFLAGS)
+-CFLAGS = -O3 -fPIE -I/usr/include/SDL -DNO_SDL -DDEFAULT_IGNORE -Wall $(GITFLAGS) $(ADDFLAGS)
++CFLAGS = -O3 -fPIE -I/usr/include/SDL -DNO_SDL -DDEFAULT_IGNORE -Wall -DBRANDY_RELEASE $(ADDFLAGS)
LDFLAGS =
+
+-LIBS = -lm -ldl -lpthread -lrt
++LIBS = -lm -lpthread
+
+ SRCDIR = src
+
Index: patches/patch-src_commands_c
===================================================================
RCS file: patches/patch-src_commands_c
diff -N patches/patch-src_commands_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_commands_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,14 @@
+- replace sprintf with snprintf
+
+Index: src/commands.c
+--- src/commands.c.orig
++++ src/commands.c
+@@ -1092,7 +1092,7 @@ static void exec_auto(void) {
+ while (lineno <= MAXLINENO) { /* ESCAPE will interrupt */
+ boolean ok;
+ emulate_printf("%5d ",lineno);
+- sprintf(basicvars.stringwork, "%5d", lineno);
++ snprintf(basicvars.stringwork, MAXSTRING, "%5d", lineno);
+ ok = amend_line(basicvars.stringwork+5, MAXSTATELEN);
+ if (!ok) {
+ DEBUGFUNCMSGOUT;
Index: patches/patch-src_editor_c
===================================================================
RCS file: patches/patch-src_editor_c
diff -N patches/patch-src_editor_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_editor_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,23 @@
+- replace some strcpy with strlcpy
+
+Index: src/editor.c
+--- src/editor.c.orig
++++ src/editor.c
+@@ -392,7 +392,7 @@ void renumber_program(byte *progstart, int32 start, in
+ */
+ static FILE *open_file(char *name) {
+ FILE *handle;
+- strcpy(basicvars.filename, name);
++ strlcpy(basicvars.filename, name, FNAMESIZE);
+ handle = fopen(name, "rb");
+ #ifndef TARGET_RISCOS
+ if (handle!=NIL) return handle;
+@@ -405,7 +405,7 @@ static FILE *open_file(char *name) {
+ /* File not found but there is a list of directories to search */
+ } else {
+ char *dest, *srce = basicvars.loadpath;
+- strcpy(basicvars.filename, name); /* Reset */
++ strlcpy(basicvars.filename, name, FNAMESIZE); /* Reset */
+ do {
+ dest = basicvars.filename;
+ if (*srce!=',') { /* Not got a null directory name */
Index: patches/patch-src_errors_c
===================================================================
RCS file: patches/patch-src_errors_c
diff -N patches/patch-src_errors_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_errors_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,32 @@
+- replace vsprintf with vsnprintf
+- replace strcpy with strlcpy
+
+Index: src/errors.c
+--- src/errors.c.orig
++++ src/errors.c
+@@ -96,6 +96,7 @@ static HANDLE sigintthread = NULL; /* Thread numbe
+ #endif
+
+ static char errortext[200]; /* Copy of text of last error for REPORT */
++static int errortext_size = 200;
+
+ /*
+ ** 'handle_signal' deals with any signals raised during program execution.
+@@ -860,7 +861,7 @@ void error(int32 errnumber, ...) {
+ if (2 == get_refreshmode()) star_refresh(1); /* Re-enable Refresh if stopped using *Refresh OnError */
+ #endif
+ va_start(parms, errnumber);
+- vsprintf(errortext, errortable[errnumber].msgtext, parms);
++ vsnprintf(errortext, errortext_size, errortable[errnumber].msgtext, parms);
+ va_end(parms);
+ if (errortable[errnumber].equiverror != -1) basicvars.error_number = errortable[errnumber].equiverror;
+ if (basicvars.current==NIL) /* Not running a program */
+@@ -910,7 +911,7 @@ void show_error(int32 number, char *text) {
+ DEBUGFUNCMSGIN;
+ basicvars.error_number = number;
+ severity = number==0 ? FATAL : NONFATAL;
+- strcpy(errortext, text);
++ strlcpy(errortext, text, errortext_size);
+ badline = find_linestart(basicvars.current);
+ if (badline==NIL) /* 'ERROR' was not used in program - Assume it was in the command line */
+ basicvars.error_line = 0;
Index: patches/patch-src_iostate_c
===================================================================
RCS file: patches/patch-src_iostate_c
diff -N patches/patch-src_iostate_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_iostate_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,53 @@
+- replace sprintf with snprintf
+
+Index: src/iostate.c
+--- src/iostate.c.orig
++++ src/iostate.c
+@@ -1793,36 +1793,36 @@ static void print_screen(void) {
+ if (rightjust) { /* Value is printed right justified */
+ if (hex) {
+ if (matrixflags.hex64)
+- size = sprintf(basicvars.stringwork, "%*llX", fieldwidth, pop_anynum64());
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%*llX", fieldwidth, pop_anynum64());
+ else
+- size = sprintf(basicvars.stringwork, "%*X", fieldwidth, pop_anynum32());
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%*X", fieldwidth, pop_anynum32());
+ } else {
+ if (resultype == STACK_FLOAT || formattype == FORMAT_E || formattype == FORMAT_F) {
+- size = sprintf(basicvars.stringwork, rightfmt, fieldwidth, numdigits, pop_anynumfp());
++ size = snprintf(basicvars.stringwork, MAXSTRING, rightfmt, fieldwidth, numdigits, pop_anynumfp());
+ } else { /* One of the integer types */
+ int64 fromstack=pop_anynum64();
+- size = sprintf(basicvars.stringwork, "%lld", fromstack);
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%lld", fromstack);
+ if (size > numdigits)
+- size = sprintf(basicvars.stringwork, rightfmt, fieldwidth, numdigits, TOFLOAT(fromstack));
++ size = snprintf(basicvars.stringwork, MAXSTRING, rightfmt, fieldwidth, numdigits, TOFLOAT(fromstack));
+ else
+- size = sprintf(basicvars.stringwork, "%*lld", fieldwidth, fromstack);
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%*lld", fieldwidth, fromstack);
+ }
+ }
+ }
+ else { /* Left justify the value */
+ if (hex)
+ if (matrixflags.hex64)
+- size = sprintf(basicvars.stringwork, "%llX", pop_anynum64());
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%llX", pop_anynum64());
+ else
+- size = sprintf(basicvars.stringwork, "%X", pop_anynum32());
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%X", pop_anynum32());
+ else {
+ if (resultype == STACK_FLOAT || formattype == FORMAT_E || formattype == FORMAT_F)
+- size = sprintf(basicvars.stringwork, leftfmt, numdigits, pop_anynumfp());
++ size = snprintf(basicvars.stringwork, MAXSTRING, leftfmt, numdigits, pop_anynumfp());
+ else {
+ int64 fromstack=pop_anynum64();
+- size = sprintf(basicvars.stringwork, "%lld", fromstack);
++ size = snprintf(basicvars.stringwork, MAXSTRING, "%lld", fromstack);
+ if (size > numdigits)
+- size = sprintf(basicvars.stringwork, rightfmt, fieldwidth, numdigits, TOFLOAT(fromstack));
++ size = snprintf(basicvars.stringwork, MAXSTRING, rightfmt, fieldwidth, numdigits, TOFLOAT(fromstack));
+ }
+ }
+ }
Index: patches/patch-src_keyboard_c
===================================================================
RCS file: patches/patch-src_keyboard_c
diff -N patches/patch-src_keyboard_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_keyboard_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,11 @@
+Index: src/keyboard.c
+--- src/keyboard.c.orig
++++ src/keyboard.c
+@@ -108,6 +108,7 @@
+ **
+ */
+
++#include <sys/select.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <unistd.h>
Index: patches/patch-src_simpletext_c
===================================================================
RCS file: patches/patch-src_simpletext_c
diff -N patches/patch-src_simpletext_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_simpletext_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,14 @@
+- replace vsprintf with vsnprintf
+
+Index: src/simpletext.c
+--- src/simpletext.c.orig
++++ src/simpletext.c
+@@ -216,7 +216,7 @@ void emulate_printf(char *format, ...) {
+ char text [MAXSTRING];
+ int n;
+ va_start(parms, format);
+- length = vsprintf(text, format, parms);
++ length = vsnprintf(text, MAXSTRING, format, parms);
+ va_end(parms);
+ echo_off();
+ for (n = 0; n < length; n++) emulate_vdu(text[n]);
Index: patches/patch-src_statement_c
===================================================================
RCS file: patches/patch-src_statement_c
diff -N patches/patch-src_statement_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_statement_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,35 @@
+- replace sprintf with snprintf
+
+Index: src/statement.c
+--- src/statement.c.orig
++++ src/statement.c
+@@ -115,7 +115,7 @@ void trace_line(int32 lineno) {
+ int32 len;
+
+ DEBUGFUNCMSGIN;
+- len = sprintf(basicvars.stringwork, "[%d]", lineno);
++ len = snprintf(basicvars.stringwork, MAXSTRING, "[%d]", lineno);
+ if (basicvars.tracehandle == 0) { /* Trace output goes to screen */
+ if (basicvars.traces.console)
+ fprintf(stderr, "%s", basicvars.stringwork);
+@@ -139,9 +139,9 @@ void trace_proc(char *np, boolean entering) {
+ DEBUGFUNCMSGIN;
+ np++;
+ if (entering) /* Entering procedure or function */
+- len = sprintf(basicvars.stringwork, "==>%s%s ", what, np);
++ len = snprintf(basicvars.stringwork, MAXSTRING, "==>%s%s ", what, np);
+ else { /* Leaving procedure or function */
+- len = sprintf(basicvars.stringwork, "%s%s--> ", what, np);
++ len = snprintf(basicvars.stringwork, MAXSTRING, "%s%s--> ", what, np);
+ }
+ if (basicvars.tracehandle == 0) { /* Trace output goes to screen */
+ if (basicvars.traces.console)
+@@ -170,7 +170,7 @@ void trace_branch(byte *from, byte *to) {
+ fromline = find_linestart(from);
+ toline = find_linestart(to);
+ if (fromline == NIL || toline == NIL) return; /* Do not trace anything if at command line */
+- len = sprintf(basicvars.stringwork, "[%d->%d]", GET_LINENO(fromline), GET_LINENO(toline));
++ len = snprintf(basicvars.stringwork, MAXSTRING, "[%d->%d]", GET_LINENO(fromline), GET_LINENO(toline));
+ if (basicvars.tracehandle == 0) { /* Trace output goes to screen */
+ if (basicvars.traces.console)
+ fprintf(stderr, "%s", basicvars.stringwork);
Index: patches/patch-src_textonly_c
===================================================================
RCS file: patches/patch-src_textonly_c
diff -N patches/patch-src_textonly_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_textonly_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,14 @@
+- replace vsprintf with vsnprintf
+
+Index: src/textonly.c
+--- src/textonly.c.orig
++++ src/textonly.c
+@@ -1355,7 +1355,7 @@ void emulate_printf(char *format, ...) {
+ va_list parms;
+ char text [MAXSTRING];
+ va_start(parms, format);
+- length = vsprintf(text, format, parms);
++ length = vsnprintf(text, MAXSTRING, format, parms);
+ va_end(parms);
+ echo_off();
+ for (n = 0; n < length; n++) emulate_vdu(text[n]);
Index: patches/patch-src_tokens_c
===================================================================
RCS file: patches/patch-src_tokens_c
diff -N patches/patch-src_tokens_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_tokens_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,60 @@
+- replace some sprintf to snprintf
+- replace strcpy to strlcpy
+
+Index: src/tokens.c
+--- src/tokens.c.orig
++++ src/tokens.c
+@@ -981,7 +981,7 @@ static void copy_other(void) {
+ error(WARN_PARNEST);
+ }
+ break;
+- case 172: /* This is '¬' which is a hi-bit char and causes a compiler warning if used directly */
++ case 172: /* This is '�' which is a hi-bit char and causes a compiler warning if used directly */
+ tclass = TYPE_FUNCTION;
+ token = BASTOKEN_NOT;
+ break;
+@@ -1772,7 +1772,7 @@ static int expand_token(char *cp, char *namelist[], by
+ error(ERR_BROKEN, __LINE__, "tokens"); /* Sanity check for bad token value */
+ return 0;
+ }
+- strcpy(cp, name);
++ strlcpy(cp, name, MAXSTRING);
+ count = strlen(name);
+ if (basicvars.list_flags.lower) { /* Lower case version of name required */
+ int n;
+@@ -1818,7 +1818,7 @@ void expand(byte *line, char *text) {
+
+ DEBUGFUNCMSGIN;
+ if (!basicvars.list_flags.noline) { /* Include line number */
+- sprintf(text, "%5d", GET_LINENO(line));
++ snprintf(text, MAXSTRING, "%5d", GET_LINENO(line));
+ text+=5;
+ if (basicvars.list_flags.space) { /* Need a blank before the expanded line */
+ *text = ' ';
+@@ -1888,7 +1888,7 @@ void expand(byte *line, char *text) {
+ /* Deal with special cases first */
+ if (token == BASTOKEN_XLINENUM) { /* Line number */
+ elp++;
+- count = sprintf(text, "%d", GET_LINENO(elp));
++ count = snprintf(text, MAXSTRING, "%d", GET_LINENO(elp));
+ text+=count;
+ elp+=LINESIZE;
+ }
+@@ -2475,7 +2475,7 @@ int32 reformat(byte *tp, byte *tokenbuf, int32 ftype)
+ tp+=ACORN_LINESIZE;
+ } else if (token == ACORN_REM || token == ACORN_DATA) { /* REM or DATA - Copy rest of line */
+ p = onebyte_token[token-ACORNONE_LOWEST];
+- strcpy(cp, p);
++ strlcpy(cp, p, MAXSTRING);
+ cp+=strlen(p);
+ tp++;
+ while (*tp != ACORN_ENDLINE) {
+@@ -2566,7 +2566,7 @@ int32 reformat(byte *tp, byte *tokenbuf, int32 ftype)
+ *cp = ' ';
+ cp++;
+ }
+- strcpy(cp, p);
++ strlcpy(cp, p, MAXSTRING);
+ cp+=strlen(p);
+ /*
+ * If keyword is followed by a letter or a digit, add a blank.
Index: patches/patch-src_variables_c
===================================================================
RCS file: patches/patch-src_variables_c
diff -N patches/patch-src_variables_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_variables_c 2 Aug 2024 03:42:01 -0000
@@ -0,0 +1,199 @@
+- replace strcpy with strlcpy
+- replace strcat with strlcat
+- replace sprintf with snprintf
+
+Index: src/variables.c
+--- src/variables.c.orig
++++ src/variables.c
+@@ -177,6 +177,7 @@ void exec_clear_himem(void) {
+ static void list_varlist(char which, library *lp) {
+ variable *vp;
+ char temp[320];
++ int temp_size = 320;
+ int templen=319; /* Leave room for the terminating \0 byte */
+ int done = 0, columns = 0, next, len = 0, n, width;
+
+@@ -196,43 +197,43 @@ static void list_varlist(char which, library *lp) {
+ case VAR_INTWORD:
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s = %d", vp, vp->varname, vp->varentry.varinteger);
++ len = snprintf(temp, temp_size, "%p %s = %d", vp, vp->varname, vp->varentry.varinteger);
+ else
+ #endif
+- len = sprintf(temp, "%s = %d", vp->varname, vp->varentry.varinteger);
++ len = snprintf(temp, temp_size, "%s = %d", vp->varname, vp->varentry.varinteger);
+ break;
+ case VAR_UINT8:
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s = %d", vp, vp->varname, vp->varentry.varu8int);
++ len = snprintf(temp, temp_size, "%p %s = %d", vp, vp->varname, vp->varentry.varu8int);
+ else
+ #endif
+- len = sprintf(temp, "%s = %d", vp->varname, vp->varentry.varu8int);
++ len = snprintf(temp, temp_size, "%s = %d", vp->varname, vp->varentry.varu8int);
+ break;
+ case VAR_INTLONG:
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s = %lld", vp, vp->varname, vp->varentry.var64int);
++ len = snprintf(temp, temp_size, "%p %s = %lld", vp, vp->varname, vp->varentry.var64int);
+ else
+ #endif
+- len = sprintf(temp, "%s = %lld", vp->varname, vp->varentry.var64int);
++ len = snprintf(temp, temp_size, "%s = %lld", vp->varname, vp->varentry.var64int);
+ break;
+ case VAR_FLOAT:
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s = %g", vp, vp->varname, vp->varentry.varfloat);
++ len = snprintf(temp, temp_size, "%p %s = %g", vp, vp->varname, vp->varentry.varfloat);
+ else
+ #endif
+- len = sprintf(temp, "%s = %g", vp->varname, vp->varentry.varfloat);
++ len = snprintf(temp, temp_size, "%s = %g", vp->varname, vp->varentry.varfloat);
+ break;
+ case VAR_STRINGDOL: {
+ int count;
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s = \"", vp, vp->varname);
++ len = snprintf(temp, temp_size, "%p %s = \"", vp, vp->varname);
+ else
+ #endif
+- len = sprintf(temp, "%s = \"", vp->varname);
++ len = snprintf(temp, temp_size, "%s = \"", vp->varname);
+
+ if (vp->varentry.varstring.stringlen<=MAXSUBSTR)
+ count = vp->varentry.varstring.stringlen;
+@@ -251,13 +252,14 @@ static void list_varlist(char which, library *lp) {
+ case VAR_INTARRAY: case VAR_UINT8ARRAY: case VAR_INT64ARRAY: case VAR_FLOATARRAY: case VAR_STRARRAY: {
+ int i;
+ char temp2[20];
++ int temp2_size = 20;
+ basicarray *ap;
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s", vp, vp->varname);
++ len = snprintf(temp, temp_size, "%p %s", vp, vp->varname);
+ else
+ #endif
+- len = sprintf(temp, "%s", vp->varname);
++ len = snprintf(temp, temp_size, "%s", vp->varname);
+ if (vp->varentry.vararray==NIL) { /* Array bounds are undefined */
+ temp[len] = ')';
+ temp[len+1] = asc_NUL;
+@@ -266,11 +268,11 @@ static void list_varlist(char which, library *lp) {
+ ap = vp->varentry.vararray;
+ for (i=0; i<ap->dimcount; i++) {
+ if (i+1==ap->dimcount) /* Doing last dimension */
+- sprintf(temp2, "%d)", ap->dimsize[i]-1);
++ snprintf(temp2, temp2_size, "%d)", ap->dimsize[i]-1);
+ else {
+- sprintf(temp2, "%d,", ap->dimsize[i]-1);
++ snprintf(temp2, temp2_size, "%d,", ap->dimsize[i]-1);
+ }
+- strcat(temp, temp2);
++ strlcat(temp, temp2, temp_size);
+ }
+ }
+ len = strnlen(temp,templen);
+@@ -286,39 +288,39 @@ static void list_varlist(char which, library *lp) {
+ }
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p %s%s", vp, p, vp->varname+1);
++ len = snprintf(temp, temp_size, "%p %s%s", vp, p, vp->varname+1);
+ else
+ #endif
+- len = sprintf(temp, "%s%s", p, vp->varname+1);
++ len = snprintf(temp, temp_size, "%s%s", p, vp->varname+1);
+ fp = vp->varentry.varfnproc->parmlist;
+ if (fp!=NIL) {
+- strcat(temp, "(");
++ strlcat(temp, "(", temp_size);
+ do {
+- if ((fp->parameter.typeinfo & VAR_RETURN)!=0) strcat(temp, "RETURN ");
++ if ((fp->parameter.typeinfo & VAR_RETURN)!=0) strlcat(temp, "RETURN ", temp_size);
+ switch(fp->parameter.typeinfo & PARMTYPEMASK) {
+ case VAR_INTWORD: case VAR_INTLONG: case VAR_INTBYTEPTR: case VAR_INTWORDPTR: case VAR_UINT8:
+- strcat(temp, "integer");
++ strlcat(temp, "integer", temp_size);
+ break;
+ case VAR_FLOAT: case VAR_FLOATPTR:
+- strcat(temp, "real");
++ strlcat(temp, "real", temp_size);
+ break;
+ case VAR_STRINGDOL: case VAR_DOLSTRPTR:
+- strcat(temp, "string");
++ strlcat(temp, "string", temp_size);
+ break;
+- case VAR_INTARRAY: strcat(temp, "integer()"); break;
+- case VAR_INT64ARRAY: strcat(temp, "int64()"); break;
+- case VAR_UINT8ARRAY: strcat(temp, "uint8()"); break;
+- case VAR_FLOATARRAY: strcat(temp, "real()"); break;
+- case VAR_STRARRAY: strcat(temp, "string()"); break;
++ case VAR_INTARRAY: strlcat(temp, "integer()", temp_size); break;
++ case VAR_INT64ARRAY: strlcat(temp, "int64()", temp_size); break;
++ case VAR_UINT8ARRAY: strlcat(temp, "uint8()", temp_size); break;
++ case VAR_FLOATARRAY: strlcat(temp, "real()", temp_size); break;
++ case VAR_STRARRAY: strlcat(temp, "string()", temp_size); break;
+ default:
+ error(ERR_BROKEN, __LINE__, "variables");
+ return;
+ }
+ fp = fp->nextparm;
+ if (fp==NIL)
+- strcat(temp, ")");
++ strlcat(temp, ")", temp_size);
+ else {
+- strcat(temp, ",");
++ strlcat(temp, ",", temp_size);
+ }
+ } while (fp!=NIL);
+ }
+@@ -334,10 +336,10 @@ static void list_varlist(char which, library *lp) {
+ }
+ #ifdef DEBUG
+ if (basicvars.debug_flags.variables)
+- len = sprintf(temp, "%p [line %d] %s%s", vp, GET_LINENO(find_linestart(vp->varentry.varmarker)), p, vp->varname+1);
++ len = snprintf(temp, temp_size, "%p [line %d] %s%s", vp, GET_LINENO(find_linestart(vp->varentry.varmarker)), p, vp->varname+1);
+ else
+ #endif
+- len = sprintf(temp, "[line %d] %s%s", GET_LINENO(find_linestart(vp->varentry.varmarker)), p, vp->varname+1);
++ len = snprintf(temp, temp_size, "[line %d] %s%s", GET_LINENO(find_linestart(vp->varentry.varmarker)), p, vp->varname+1);
+ break;
+ }
+ default: /* Bad type of variable flag */
+@@ -397,10 +399,11 @@ void list_variables(char which) {
+ width = (basicvars.printwidth==0 ? PRINTWIDTH : basicvars.printwidth);
+ if (which==' ') { /* List everything */
+ char n, temp[40];
++ int temp_size = 40;
+ int columns = 0, atpercent, len, next;
+ emulate_printf("Static integer variables:\r\n");
+ for (n='A'; n<='Z'; n++) {
+- len = sprintf(temp, "%c%% = %d", n, basicvars.staticvars[n-'A'+1].varentry.varinteger);
++ len = snprintf(temp, temp_size, "%c%% = %d", n, basicvars.staticvars[n-'A'+1].varentry.varinteger);
+ next = (columns+FIELDWIDTH-1)/FIELDWIDTH*FIELDWIDTH;
+ if (next>=width) { /* Not enough room on this line */
+ emulate_printf("\r\n%s", temp);
+@@ -417,7 +420,7 @@ void list_variables(char which) {
+ }
+ /* Let's now do @%, output in hex as it makes more sense. */
+ atpercent = basicvars.staticvars[ATPERCENT].varentry.varinteger;
+- len = sprintf(temp, "@%% = &%X", atpercent);
++ len = snprintf(temp, temp_size, "@%% = &%X", atpercent);
+ next = (columns+FIELDWIDTH-1)/FIELDWIDTH*FIELDWIDTH;
+ while (columns<next) {
+ emulate_vdu(' ');
+@@ -1033,7 +1036,7 @@ static variable *search_library(library *lp, char *nam
+ if (fpp==NIL) return NIL; /* Entry not found in library */
+ vp = allocmem(sizeof(variable), 1); /* Entry found. Create symbol table entry for it */
+ vp->varname = allocmem(namelen+1, 1); /* +1 for NUL at end of name */
+- strcpy(vp->varname, name);
++ strlcpy(vp->varname, name, namelen+1);
+ vp->varhash = hashvalue;
+ vp->varentry.varmarker = fpp->fpmarker; /* Needed in 'scan_parmlist' */
+ vp->varflink = basicvars.varlists[hashvalue & VARMASK];
Index: pkg/DESCR
===================================================================
RCS file: /cvs/ports/lang/brandy/pkg/DESCR,v
diff -u -p -u -r1.1.1.1 DESCR
--- pkg/DESCR 19 Mar 2017 21:49:31 -0000 1.1.1.1
+++ pkg/DESCR 2 Aug 2024 03:42:01 -0000
@@ -1,5 +1,5 @@
-Brandy implements Basic V, the dialect of Basic that Acorn Computers
+Brandy implements Basic VI, the dialect of Basic that Acorn Computers
supplied with their ranges of desktop computers that use the ARM
-processor such as the Archimedes and RiscPC. Basic V is an extended
+processor such as the Archimedes and RiscPC. Basic VI is an extended
version of BBC Basic. This was the Basic used on the BBC Micro that
Acorn made during the early 1980s.
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/lang/brandy/pkg/PLIST,v
diff -u -p -u -r1.3 PLIST
--- pkg/PLIST 11 Mar 2022 19:28:52 -0000 1.3
+++ pkg/PLIST 2 Aug 2024 03:42:01 -0000
@@ -1,24 +1,67 @@
@bin bin/brandy
@bin bin/brandy-sdl
share/doc/brandy/
-share/doc/brandy/basic
-share/doc/brandy/messages
-share/doc/brandy/use
+share/doc/brandy/COPYING
+share/doc/brandy/ChangeLog
+share/doc/brandy/Config.txt
+share/doc/brandy/Mode7.txt
+share/doc/brandy/README
+share/doc/brandy/ScreenModes.txt
+share/doc/brandy/banana-bugs.txt
+share/doc/brandy/basic.txt
+share/doc/brandy/compiling.txt
+share/doc/brandy/extensions.txt
+share/doc/brandy/graphics.txt
+share/doc/brandy/history.txt
+share/doc/brandy/identification.txt
+share/doc/brandy/internals.txt
+share/doc/brandy/jgh-notes.txt
+share/doc/brandy/keyboard-codes
+share/doc/brandy/keymap.txt
+share/doc/brandy/messages.txt
+share/doc/brandy/networking.txt
+share/doc/brandy/osbyte.txt
+share/doc/brandy/raspi-gpio.txt
+share/doc/brandy/standalone-app.txt
+share/doc/brandy/sys-calls.txt
+share/doc/brandy/use.txt
share/examples/brandy/
+share/examples/brandy/BubbleUniverse
+share/examples/brandy/Mode7/
+share/examples/brandy/Mode7/M7terminal
+share/examples/brandy/Mode7/README
+share/examples/brandy/Mode7/SAA505xDemo
+share/examples/brandy/Mode7/m7point
+share/examples/brandy/Mode7/mode7demo
+share/examples/brandy/Mode7/telstar
+share/examples/brandy/Mode7/ttxtedit
share/examples/brandy/README
+share/examples/brandy/SAA505Xlib
+share/examples/brandy/Snow
+share/examples/brandy/bin2c
share/examples/brandy/cmdline
share/examples/brandy/combsort
share/examples/brandy/cricket
-share/examples/brandy/dow
+share/examples/brandy/gpiolib
share/examples/brandy/graphdemo
share/examples/brandy/hanoi
share/examples/brandy/hex
share/examples/brandy/lands
+share/examples/brandy/mouse-doodle
share/examples/brandy/pastriang
+share/examples/brandy/platformcheck
+share/examples/brandy/shroud
+share/examples/brandy/sierpinski
share/examples/brandy/sieve
+share/examples/brandy/sine
+share/examples/brandy/sphere
+share/examples/brandy/spiral
+share/examples/brandy/spiral-pattern
+share/examples/brandy/splash
share/examples/brandy/tekdemo1
share/examples/brandy/tekdemo2
share/examples/brandy/teklib
+share/examples/brandy/tekspiral
share/examples/brandy/trees1
share/examples/brandy/trees2
share/examples/brandy/tvtime
[update] Brandy 1.20.1 -> 1.23.2