development/opencomal: Added (interpreter for Comal).

Signed-off-by: David Spencer <idlemoor@slackbuilds.org>
This commit is contained in:
B. Watson 2017-12-11 20:03:09 +00:00 committed by Willy Sudiarto Raharjo
parent 2f57a1d6a5
commit c21cc4e428
12 changed files with 618 additions and 0 deletions

View File

@ -0,0 +1,10 @@
opencomal (interpreter for Comal programming language)
OpenComal is a portable and free implementation of the Comal programming
language written by Jos Visser. Currently supported platforms are Unix,
MsDos and Win32. Comal is a crossover between Basic and Pascal, with
the best features of both and none of the drawbacks of either.
opencomal development stopped in January 2002. By default, this script
builds the last stable release of opencomal. If you'd rather build
the last beta, see README.beta.

View File

@ -0,0 +1,11 @@
By default, this script builds the last stable release of opencomal,
0.2.6, from December 2002. It's also possible to build the last beta,
0.2.7-pre1-work, from January 2003. To do this, download the source from:
http://www.josvisser.nl/opencomal/opencomal-0.2.7-pre1-work.tar.gz
The md5sum is 43b90700cec264e8da4bd728b3e70cb1.
Save the file in the same directory as opencomal.SlackBuild, then run
the script with BETA=yes set in the environment. The resulting package
will have a version number of 0.2.7pre1 (no hyphen or -work suffix).

View File

@ -0,0 +1,92 @@
#!/bin/sh
# Slackware build script for opencomal
# Written by B. Watson (yalhcru@gmail.com)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
PRGNAM=opencomal
VERSION=${VERSION:-0.2.6}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
if [ "${BETA:-no}" = "yes" ]; then
VERSION="0.2.7pre1"
TARVER="0.2.7-pre1-work"
else
TARVER="$VERSION"
fi
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$TARVER
tar xvf $CWD/$PRGNAM-$TARVER.tar.gz
cd $PRGNAM-$TARVER
rm -rf bin/* # do not use prebuilt binaries
chown -R root:root .
find . -type d -exec chmod 755 {} \+
find . -type f -exec chmod 644 {} \+
chmod 755 tools/*
# see patches/README to find out what all these patches are for.
for i in $CWD/patches/*.diff; do
echo "Applying $(basename $i)"
patch -p1 < $i
done
# no point building in debug symbols that we strip out afterwards.
sed -i 's,-ggdb,,' src/Makefile
# not 100% sure -j1 is needed, but this is a small program anyway.
make -j1 -C src PROFILE="$SLKCFLAGS"
# no 'make install' target.
mkdir -p $PKG/usr/bin
install -s -m0755 bin/* $PKG/usr/bin
# don't need to install build docs.
rm -f doc/BUILD
# no man pages. neither binary takes any flags, so I don't see much point
# in creating them.
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a doc/* samples $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View File

@ -0,0 +1,10 @@
PRGNAM="opencomal"
VERSION="0.2.6"
HOMEPAGE="http://www.josvisser.nl/opencomal/"
DOWNLOAD="http://www.josvisser.nl/opencomal/opencomal-0.2.6.tar.gz"
MD5SUM="5d87ef48af35320f84a61a591a1b58ed"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="B. Watson"
EMAIL="yalhcru@gmail.com"

View File

@ -0,0 +1,81 @@
diff -Naur opencomal-0.2.6/src/pdccmd.c opencomal-0.2.6.patched/src/pdccmd.c
--- opencomal-0.2.6/src/pdccmd.c 2002-09-22 13:36:49.000000000 -0400
+++ opencomal-0.2.6.patched/src/pdccmd.c 2017-12-10 16:51:45.087203071 -0500
@@ -22,6 +22,7 @@
#include "pdcsqash.h"
#include "pdcenv.h"
+#include <string.h>
PRIVATE void cmd_list_horse(struct string *filename, long from, long to)
{
diff -Naur opencomal-0.2.6/src/pdcenv.c opencomal-0.2.6.patched/src/pdcenv.c
--- opencomal-0.2.6/src/pdcenv.c 2002-09-17 12:20:06.000000000 -0400
+++ opencomal-0.2.6.patched/src/pdcenv.c 2017-12-10 16:52:01.592203099 -0500
@@ -16,6 +16,8 @@
#include "pdcseg.h"
#include "pdcid.h"
+#include <string.h>
+
PUBLIC struct comal_env *env_new(char *name)
{
struct comal_env *work = GETCORE(MISC_POOL, struct comal_env);
diff -Naur opencomal-0.2.6/src/pdcexp.c opencomal-0.2.6.patched/src/pdcexp.c
--- opencomal-0.2.6/src/pdcexp.c 2002-12-06 06:02:35.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcexp.c 2017-12-10 16:52:33.823203154 -0500
@@ -20,7 +20,7 @@
#include "pdcstr.h"
#include "pdcval.h"
-
+#include <string.h>
#include <math.h>
#ifdef HAS_ROUND
diff -Naur opencomal-0.2.6/src/pdcext.c opencomal-0.2.6.patched/src/pdcext.c
--- opencomal-0.2.6/src/pdcext.c 2002-12-05 02:17:02.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcext.c 2017-12-10 16:53:06.231203208 -0500
@@ -18,6 +18,8 @@
#include "pdcval.h"
#include "version.h"
+#include <string.h>
+
struct inpfile_stkent {
struct inpfile_stkent *next;
FILE *inpfile;
diff -Naur opencomal-0.2.6/src/pdclist.c opencomal-0.2.6.patched/src/pdclist.c
--- opencomal-0.2.6/src/pdclist.c 2002-11-30 09:39:49.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdclist.c 2017-12-10 16:52:20.328203131 -0500
@@ -15,6 +15,8 @@
#include "pdcparss.h"
#include "pdcmisc.h"
+#include <string.h>
+
PUBLIC int show_exec = 0;
PRIVATE void list_horse();
diff -Naur opencomal-0.2.6/src/pdcmisc.c opencomal-0.2.6.patched/src/pdcmisc.c
--- opencomal-0.2.6/src/pdcmisc.c 2002-12-06 05:58:13.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcmisc.c 2017-12-10 16:51:25.608203038 -0500
@@ -18,6 +18,7 @@
#include "pdcexec.h"
#include "pdclist.h"
+#include <string.h>
#include <math.h>
#include <fcntl.h>
diff -Naur opencomal-0.2.6/src/pdcsqash.c opencomal-0.2.6.patched/src/pdcsqash.c
--- opencomal-0.2.6/src/pdcsqash.c 2002-11-30 09:40:16.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcsqash.c 2017-12-10 16:52:52.257203185 -0500
@@ -17,6 +17,7 @@
#include "pdcexec.h"
#include <fcntl.h>
#include <sys/stat.h>
+#include <string.h>
PRIVATE void sqash_exp();
PRIVATE void sqash_horse();

View File

@ -0,0 +1,93 @@
diff -Naur opencomal-0.2.6/src/pdcexec.c opencomal-0.2.6.patched/src/pdcexec.c
--- opencomal-0.2.6/src/pdcexec.c 2002-11-30 09:58:16.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcexec.c 2017-12-10 17:29:51.489206949 -0500
@@ -25,6 +25,7 @@
#include "pdcexec.h"
#include "pdcdsys.h"
+#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
@@ -42,10 +43,13 @@
PUBLIC void run_error(int error, char *s, ...)
{
+ va_list ap;
char *buf;
char buf2[MAX_LINELEN];
- vsprintf(buf2, s, (char *) &s + sizeof(s));
+ va_start(ap, s);
+ vsprintf(buf2, s, ap);
+ va_end(ap);
curenv->error = curenv->lasterr = error;
mem_free(curenv->lasterrmsg);
diff -Naur opencomal-0.2.6/src/pdcmisc.c opencomal-0.2.6.patched/src/pdcmisc.c
--- opencomal-0.2.6/src/pdcmisc.c 2017-12-10 17:23:13.344206273 -0500
+++ opencomal-0.2.6.patched/src/pdcmisc.c 2017-12-10 17:24:52.465206441 -0500
@@ -18,6 +18,7 @@
#include "pdcexec.h"
#include "pdclist.h"
+#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <fcntl.h>
@@ -58,9 +59,12 @@
PUBLIC void my_printf(int stream, int newline, char *s, ...)
{
+ va_list ap;
char buf[MAX_LINELEN];
- vsprintf(buf, s, (char *) &s + sizeof(s));
+ va_start(ap, s);
+ vsprintf(buf, s, ap);
+ va_end(ap);
my_put(stream, buf, -1L);
if (newline)
@@ -70,9 +74,12 @@
PUBLIC void fatal(char *s, ...)
{
+ va_list ap;
char buf[140];
- vsprintf(buf, s, (char *) &s + sizeof(s));
+ va_start(ap, s);
+ vsprintf(buf, s, ap);
+ va_end(ap);
my_printf(MSG_ERROR, 1, "FATAL error: %s", buf);
longjmp(RESTART, ERR_FATAL);
diff -Naur opencomal-0.2.6/src/pdcparss.c opencomal-0.2.6.patched/src/pdcparss.c
--- opencomal-0.2.6/src/pdcparss.c 2002-11-30 03:22:16.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcparss.c 2017-12-10 17:29:21.935206898 -0500
@@ -16,6 +16,8 @@
#include "pdcstr.h"
#include "pdcparss.h"
+#include <stdarg.h>
+
PRIVATE int pars_error_happened = 0;
PRIVATE char pars_errtxt[MAX_LINELEN];
@@ -282,11 +284,14 @@
PUBLIC void pars_error(char *s, ...)
{
+ va_list ap;
if (pars_error_happened)
return;
pars_error_happened = lex_pos();
- vsprintf(pars_errtxt, s, (char *) &s + sizeof(s));
+ va_start(ap, s);
+ vsprintf(pars_errtxt, s, ap);
+ va_end(ap);
}

View File

@ -0,0 +1,18 @@
diff -Naur opencomal-0.2.6/src/pdccmd.c opencomal-0.2.6.patched/src/pdccmd.c
--- opencomal-0.2.6/src/pdccmd.c 2017-12-10 17:36:56.144207669 -0500
+++ opencomal-0.2.6.patched/src/pdccmd.c 2017-12-10 17:37:14.539207700 -0500
@@ -260,9 +260,11 @@
aline = crunch_line(buf);
- direct_cmd = !aline->ld;
- result = process_comal_line(aline);
- nr += step;
+ if(aline) {
+ direct_cmd = !aline->ld;
+ result = process_comal_line(aline);
+ nr += step;
+ }
}
return result;

View File

@ -0,0 +1,12 @@
diff -Naur opencomal-0.2.6/src/pdclinux.c opencomal-0.2.6.patched/src/pdclinux.c
--- opencomal-0.2.6/src/pdclinux.c 2002-11-30 03:40:20.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdclinux.c 2017-12-10 17:48:17.357208824 -0500
@@ -486,7 +486,7 @@
PUBLIC void sys_mkdir(char *dir)
{
- if (!mkdir(dir,0777)<0)
+ if (mkdir(dir,0777)<0)
run_error(DIR_ERR,strerror(errno));
}

View File

@ -0,0 +1,225 @@
diff -Naur opencomal-0.2.6/src/pdccmd.c opencomal-0.2.6.patched/src/pdccmd.c
--- opencomal-0.2.6/src/pdccmd.c 2017-12-10 17:36:56.144207669 -0500
+++ opencomal-0.2.6.patched/src/pdccmd.c 2017-12-10 17:52:49.942209286 -0500
@@ -36,7 +36,7 @@
if (!listfile)
run_error(OPEN_ERR, "File open error %s",
- sys_errlist[errno]);
+ strerror(errno));
setvbuf(listfile, NULL, _IOFBF, TEXT_BUFSIZE);
} else {
@@ -126,7 +126,7 @@
if (!yyenter)
run_error(OPEN_ERR, "File open error: %s",
- sys_errlist[errno]);
+ strerror(errno));
setvbuf(yyenter, NULL, _IOFBF, TEXT_BUFSIZE);
++entering;
@@ -138,7 +138,7 @@
if (!feof(yyenter))
run_error(CMD_ERR,
"Error when reading ENTER file: %s",
- sys_errlist[errno]);
+ strerror(errno));
} else {
aline = crunch_line(tline);
diff -Naur opencomal-0.2.6/src/pdcexec.c opencomal-0.2.6.patched/src/pdcexec.c
--- opencomal-0.2.6/src/pdcexec.c 2017-12-10 17:37:01.335207678 -0500
+++ opencomal-0.2.6.patched/src/pdcexec.c 2017-12-10 17:53:27.853209351 -0500
@@ -1218,7 +1218,7 @@
frec->hfno = open(name->s, flags | O_BINARY, S_IREAD | S_IWRITE);
if (frec->hfno == -1)
- run_error(OPEN_ERR, "OPEN error: %s", sys_errlist[errno]);
+ run_error(OPEN_ERR, "OPEN error: %s", strerror(errno));
frec->next = curenv->fileroot;
curenv->fileroot = frec;
@@ -1244,7 +1244,7 @@
if (close(walk->hfno) == -1)
run_error(CLOSE_ERR,
"Close error on file %ld: %s",
- walk->cfno, sys_errlist[errno]);
+ walk->cfno, strerror(errno));
walk = mem_free(walk);
}
@@ -1268,7 +1268,7 @@
if (close(walk->hfno) == -1)
run_error(CLOSE_ERR,
"CLOSE error on file %ld: %s",
- walk->cfno, sys_errlist[errno]);
+ walk->cfno, strerror(errno));
else {
if (last)
last->next = walk->next;
@@ -1314,7 +1314,7 @@
-1)
run_error(POS_ERR,
"Random file positioning error: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
return f;
@@ -1391,7 +1391,7 @@
if (r < 0)
run_error(READ_ERR, "INPUT/READ file error: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
@@ -1534,7 +1534,7 @@
if (w < 0)
run_error(WRITE_ERR, "File write error: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
@@ -1703,7 +1703,7 @@
if (fclose(*f))
run_error(SELECT_ERR,
"Error when closing current SELECT file: %s",
- sys_errlist[errno]);
+ strerror(errno));
calc_exp(exp, (void **) &result, &type);
@@ -1715,7 +1715,7 @@
if (!*f)
run_error(SELECT_ERR,
"Error when opening new SELECT file: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
mem_free(result);
diff -Naur opencomal-0.2.6/src/pdcexp.c opencomal-0.2.6.patched/src/pdcexp.c
--- opencomal-0.2.6/src/pdcexp.c 2017-12-10 17:36:56.144207669 -0500
+++ opencomal-0.2.6.patched/src/pdcexp.c 2017-12-10 17:54:02.343209409 -0500
@@ -220,7 +220,7 @@
if (result == -1)
run_error(EOF_ERR, "Error when checking for EOF: %s",
- sys_errlist[errno]);
+ strerror(errno));
return result;
}
diff -Naur opencomal-0.2.6/src/pdcext.c opencomal-0.2.6.patched/src/pdcext.c
--- opencomal-0.2.6/src/pdcext.c 2017-12-10 17:36:56.144207669 -0500
+++ opencomal-0.2.6.patched/src/pdcext.c 2017-12-10 17:54:53.239209496 -0500
@@ -248,7 +248,7 @@
pop_inpfile();
run_error(SYS_ERR,
"Error opening sysin: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
}
@@ -280,7 +280,7 @@
if (!sys_outfile && name->s[0])
run_error(SYS_ERR, "Error opening sysout: %s",
- sys_errlist[errno]);
+ strerror(errno));
return 0;
} else if (strcmp(cmd, "memdump") == 0) {
@@ -323,7 +323,7 @@
if (!eof)
run_error(SYS_ERR, "Error reading sysin: %s",
- sys_errlist[errno]);
+ strerror(errno));
return ext_get(stream, line, maxlen, prompt);
}
diff -Naur opencomal-0.2.6/src/pdcmisc.c opencomal-0.2.6.patched/src/pdcmisc.c
--- opencomal-0.2.6/src/pdcmisc.c 2017-12-10 17:37:01.335207678 -0500
+++ opencomal-0.2.6.patched/src/pdcmisc.c 2017-12-10 17:50:59.802209100 -0500
@@ -39,7 +39,7 @@
if (fputc('\n', sel_outfile) == EOF)
run_error(SELECT_ERR,
"Error when writing to SELECT OUTPUT file %s",
- sys_errlist[errno]);
+ strerror(errno));
} else
sys_nl(stream);
}
@@ -51,7 +51,7 @@
if (fputs(buf, sel_outfile) == EOF)
run_error(SELECT_ERR,
"Error when writing to SELECT OUTPUT file %s",
- sys_errlist[errno]);
+ strerror(errno));
} else
sys_put(stream, buf, len);
}
diff -Naur opencomal-0.2.6/src/pdcsqash.c opencomal-0.2.6.patched/src/pdcsqash.c
--- opencomal-0.2.6/src/pdcsqash.c 2017-12-10 17:36:56.145207669 -0500
+++ opencomal-0.2.6.patched/src/pdcsqash.c 2017-12-10 17:54:58.873209505 -0500
@@ -39,7 +39,7 @@
close(sqash_file);
run_error(SQASH_ERR,
"Error when writing to file: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
sqash_i = 0;
@@ -543,7 +543,7 @@
if (sqash_file < 0)
run_error(OPEN_ERR, "File open error: %s",
- sys_errlist[errno]);
+ strerror(errno));
sqash_buf = mem_alloc(MISC_POOL, SQASH_BUFSIZE);
sqash_i = 0;
@@ -568,7 +568,7 @@
if (close(sqash_file) < 0)
run_error(CLOSE_ERR, "Error closing file: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
@@ -583,7 +583,7 @@
if (sqash_hwm < 0) {
close(sqash_file);
run_error(SQASH_ERR, "Error when reading from file: %s",
- sys_errlist[errno]);
+ strerror(errno));
}
sqash_i = 0;
@@ -1276,7 +1276,7 @@
if (sqash_file < 0)
run_error(OPEN_ERR, "File open error: %s",
- sys_errlist[errno]);
+ strerror(errno));
sqash_buf = mem_alloc(MISC_POOL, SQASH_BUFSIZE);
sqash_i = MAXUNSIGNED;
@@ -1332,7 +1332,7 @@
if (close(sqash_file) < 0)
run_error(CLOSE_ERR, "Error closing file: %s",
- sys_errlist[errno]);
+ strerror(errno));
return root;
}

View File

@ -0,0 +1,24 @@
diff -Naur opencomal-0.2.6/src/pdcexec.h opencomal-0.2.6.patched/src/pdcexec.h
--- opencomal-0.2.6/src/pdcexec.h 2002-09-17 12:20:06.000000000 -0400
+++ opencomal-0.2.6.patched/src/pdcexec.h 2017-12-10 18:11:31.222211188 -0500
@@ -10,7 +10,7 @@
/* Line execution routines header file */
-extern void run_error(int error, char *s, ...);
+extern void run_error(int error, char *s, ...) __attribute__((noreturn));
extern void exec_call(struct expression *exp, int calltype, void **result,
enum VAL_TYPE *type);
extern int exec_trap(struct comal_line *line);
diff -Naur opencomal-0.2.6/src/pdcmisc.h opencomal-0.2.6.patched/src/pdcmisc.h
--- opencomal-0.2.6/src/pdcmisc.h 2002-12-06 05:31:50.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcmisc.h 2017-12-10 18:06:37.942210691 -0500
@@ -13,7 +13,7 @@
extern void my_nl(int stream);
extern void my_put(int stream, char *buf, long len);
extern void my_printf(int stream, int newline, char *s, ...);
-extern void fatal(char *s, ...);
+extern void fatal(char *s, ...) __attribute__((noreturn));
extern void *my_reverse(void *root);
extern void free_list(struct my_list *root);
extern int exp_list_of_nums(struct exp_list *root);

View File

@ -0,0 +1,23 @@
opencomal needed a lot of patching to get it building & running on modern
Slackware. All these patches are by the SlackBuild author.
01-missing_includes.diff
#include <string.h>
02-vsprintf.diff
bizarre non-standards-compliant handling of vsprintf() causes immediate
segfault on startup, when it tries to print the banner.
03-fix_auto_segfault.diff
missing NULL check, causes segfault in 'auto' mode when a syntax error
is entered, followed by ^C.
04-mkdir.diff
fix the mkdir command so it actually reports errors.
05-sys_errlist.diff
fix deprecation warning.
06-noreturn.diff
squelch a bunch of spurious 'might be used uninitialized' warnings.
there are still a couple left, caveat emptor...

View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
opencomal: opencomal (interpreter for Comal programming language)
opencomal:
opencomal: OpenComal is a portable and free implementation of the Comal
opencomal: programming language written by Jos Visser. Currently supported
opencomal: platforms are Unix, MsDos and Win32. Comal is a crossover between
opencomal: Basic and Pascal, with the best features of both and none of the
opencomal: drawbacks of either.
opencomal:
opencomal:
opencomal:
opencomal: