Replace byacc with oyacc

byacc has an awk script to generate .c files

oyacc seems to work fine instead
This commit is contained in:
fosslinux 2025-02-05 15:21:14 +11:00
parent dfb3ae04e2
commit 622dd36d1f
14 changed files with 180 additions and 320 deletions

View file

@ -45,9 +45,9 @@ c30d11b798f3a6198f339ec98a88f8971c6ec13d5dcb10cb7af780752e97509f e2fsprogs-1.45
139af6684f275e362e5c247bb830e85c888aa6c263622c1f3e967b2f71ff38f4 ed-1.4_0.tar.bz2 139af6684f275e362e5c247bb830e85c888aa6c263622c1f3e967b2f71ff38f4 ed-1.4_0.tar.bz2
ce69ed8b48cf5440d33c756aadefc48711bdf058ead79121176e13fd9e306c50 file-5.44_0.tar.bz2 ce69ed8b48cf5440d33c756aadefc48711bdf058ead79121176e13fd9e306c50 file-5.44_0.tar.bz2
eec07e0d710ed3dd8d0ba6a1ec6ca9f1fa3a611bbb225195435679175317bf90 findutils-4.2.33_0.tar.bz2 eec07e0d710ed3dd8d0ba6a1ec6ca9f1fa3a611bbb225195435679175317bf90 findutils-4.2.33_0.tar.bz2
6f2194592682f4a448ccb0aa897e707a8a00eeb69d4b1f5f0236eb6d0fef6242 flex-2.5.11_0.tar.bz2 0fb7580f81433aaf9f560e796799c0875c33a8ddf1da27ea523f6f895a1797e6 flex-2.5.11_0.tar.bz2
9cb13b1e60c2c860e2f6fb11efffa74646290ef8461fbc43ed6e5ccfc3bd673f flex-2.5.33_0.tar.bz2 9cb13b1e60c2c860e2f6fb11efffa74646290ef8461fbc43ed6e5ccfc3bd673f flex-2.5.33_0.tar.bz2
7bd44ec26cad78e5bb146e5ab709d489b6589da6049e319a4f438603f10eda4b flex-2.6.4_0.tar.bz2 9e898068d570b5cfa016f0e14819d7f7a6577bae9177ef1e9bb62866d5b0f0b9 flex-2.6.4_0.tar.bz2
c925739472260498342ba6dc3263da937abf5237e7e9102622bf5657ec98094a gawk-3.0.4_0.tar.bz2 c925739472260498342ba6dc3263da937abf5237e7e9102622bf5657ec98094a gawk-3.0.4_0.tar.bz2
97e255a5852cb5fbd16e632249787f80e6bfd75cc5b31f8dfc8c81660a0801e1 gawk-5.3.0_0.tar.bz2 97e255a5852cb5fbd16e632249787f80e6bfd75cc5b31f8dfc8c81660a0801e1 gawk-5.3.0_0.tar.bz2
ab8b5b92de4780b085d8bc7e98ee72ad5ba9c07b26690c579c559b5cc21817eb gc-8.0.4_0.tar.bz2 ab8b5b92de4780b085d8bc7e98ee72ad5ba9c07b26690c579c559b5cc21817eb gc-8.0.4_0.tar.bz2
@ -64,7 +64,7 @@ bfeb5cad6720cd6ff629095f562fc7b60e2b352d248c4f8bdc9de3db1ed09b17 grep-3.7_0.tar
3f08414ffc65cebc8a635b0339f95c7ea0259d33cb53676293c3b28b0453f8c1 grub-2.06_0.tar.bz2 3f08414ffc65cebc8a635b0339f95c7ea0259d33cb53676293c3b28b0453f8c1 grub-2.06_0.tar.bz2
fc97b59e6b3a99ef457890a00ddee4a9ad44316e41cb746cf6cac1d193e480b7 guile-3.0.9_0.tar.bz2 fc97b59e6b3a99ef457890a00ddee4a9ad44316e41cb746cf6cac1d193e480b7 guile-3.0.9_0.tar.bz2
4b784b57ed27e22750cf79492bb65bf68bd8211d942eeb74490981effa41196b gzip-1.13_0.tar.bz2 4b784b57ed27e22750cf79492bb65bf68bd8211d942eeb74490981effa41196b gzip-1.13_0.tar.bz2
d0cb00116d742d4216af4a7ed47f20408640229909a497c184aed3d4fcd4f30a heirloom-devtools-070527_0.tar.bz2 30910d1d4af913272a46d76e824155bf3d023347a940db03837250000c17bab5 heirloom-devtools-070527_0.tar.bz2
8d2015b87337abbf287f7a39ee4cf53514120b5d3e90a93fe7d533dcc43f14fa help2man-1.36.4_0.tar.bz2 8d2015b87337abbf287f7a39ee4cf53514120b5d3e90a93fe7d533dcc43f14fa help2man-1.36.4_0.tar.bz2
f59be8342ecf28d94e07c862de2d04dc46a7f9415e5256360d0e2ea6d1e3b252 kbd-1.15_0.tar.bz2 f59be8342ecf28d94e07c862de2d04dc46a7f9415e5256360d0e2ea6d1e3b252 kbd-1.15_0.tar.bz2
eaac2e938932926864c3866eb60b05c710137f20bb08b6fbdcba752d729f5b68 kexec-linux-1.0.0_0.tar.bz2 eaac2e938932926864c3866eb60b05c710137f20bb08b6fbdcba752d729f5b68 kexec-linux-1.0.0_0.tar.bz2

View file

@ -1 +1 @@
366f84242bee042ea0919d06f536d48541175ce6fdcfaa238282867c8b85a300 /usr/bin/bash d6f725a9998443629e9d8496df3ed4a938a9bdc80cd1aab2b31b011b99f0dae4 /usr/bin/bash

View file

@ -1 +0,0 @@
34a6457920fd314e198b289d8c4b76f8e6a48178f0a29c6d8ded0f5b9dbf877d /usr/bin/yacc

View file

@ -1,98 +0,0 @@
# SPDX-FileCopyrightText: 2002-2022 Thomas E. Dickey
# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
#
# SPDX-License-Identifier: CC0-1.0
#
# From original byacc README:
# Berkeley Yacc is in the public domain. The data structures and algorithms
# used in Berkeley Yacc are all either taken from documents available to the
# general public or are inventions of the author. Anyone may freely distribute
# source or binary forms of Berkeley Yacc whether unchanged or modified.
# Distributers may charge whatever fees they can obtain for Berkeley Yacc.
# Programs generated by Berkeley Yacc may be distributed freely.
#
# (typo "Distributers" in original)
DEST = .
HDRS = defs.h
CFLAGS ?= -O -DNDEBUG
LDFLAGS ?=
LIBS ?=
LINKER ?= $(CC)
MAKEFILE = Makefile
OBJS = closure.o \
error.o graph.o \
lalr.o \
lr0.o \
main.o \
mkpar.o mstring.o \
output.o \
reader.o \
symtab.o \
verbose.o \
warshall.o yaccpar.o
PRINT = pr -f -l88
PROGRAM = yacc
SRCS = closure.c \
error.c graph.c \
lalr.c \
lr0.c \
main.c \
mkpar.c mstring.c \
output.c \
reader.c \
symtab.c \
verbose.c \
warshall.c yaccpar.c
all: $(PROGRAM)
$(PROGRAM): $(OBJS) $(LIBS)
@$(LINKER) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
clean:; @rm -f $(OBJS)
clobber:; @rm -f $(OBJS) $(PROGRAM)
depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
index:; @ctags -wx $(HDRS) $(SRCS)
install: $(PROGRAM)
@echo Installing $(PROGRAM) in $(DEST)
@install -s $(PROGRAM) $(DEST)
listing:; @$(PRINT) Makefile $(HDRS) $(SRCS) | lpr
lint:; @lint $(SRCS)
program: $(PROGRAM)
tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
###
closure.o: defs.h
error.o: defs.h
lalr.o: defs.h
lr0.o: defs.h
main.o: defs.h
mkpar.o: defs.h
output.o: defs.h
reader.o: defs.h
symtab.o: defs.h
verbose.o: defs.h
warshall.o: defs.h
btyaccpar.o: defs.h
yaccpar.o: defs.h
graph.o: defs.h
mstring.o: defs.h

View file

@ -1,45 +0,0 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
set -ex
# Check tarball checksums
checksum-transcriber sources
sha256sum -c sources.SHA256SUM
mkdir build src
cd build
# Extract
cp ${DISTFILES}/${pkg}.tgz ../src/${pkg}.tar.gz
gunzip -f ../src/${pkg}.tar.gz
tar xf ../src/${pkg}.tar
rm -r ../src/
cd ${pkg}
# Prepare and patch
cp ../../files/Makefile .
patch -Np1 -i ../../patches/meslibc.patch
# Build yacc
make CC=tcc AR=tcc\ -ar CFLAGS=-DMAXPATHLEN=100\ -DEILSEQ=84\ -DMB_LEN_MAX=100 LDFLAGS=-lgetopt\ -static RANLIB=true
# Install yacc
install yacc ${BINDIR}/yacc
cd ../..
# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
sha256sum -o ${pkg}.checksums \
/usr/bin/yacc
install ${pkg}.checksums ${SRCDIR}
else
sha256sum -c ${pkg}.checksums
fi

View file

@ -1,170 +0,0 @@
SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
SPDX-License-Identifier: GPL-3.0-or-later
Remove usages of tmpfile(), rewind(), fgetpos(), fsetpos() and bsearch(),
which are unsupported by meslibc, and add missing declaration for strdup.
License note: Berkeley Yacc is in the public domain, but it's linked with
meslibc, which is GPL-3.0-or-later, so we apply that license here too.
diff -ru ../byacc-20240109.bak/main.c ./main.c
--- byacc-20240109/main.c 2024-04-14 16:06:09.646465507 +0200
+++ byacc-20240109/main.c 2024-04-14 20:41:56.227083399 +0200
@@ -788,7 +788,7 @@
(void)umask(save_umask);
}
#else
- result = tmpfile();
+ result = fopen(label, "w+");
#endif
if (result == 0)
diff -ru ../byacc-20240109.bak/output.c ./output.c
--- byacc-20240109/output.c 2024-04-14 16:06:09.646465507 +0200
+++ byacc-20240109/output.c 2024-04-14 16:06:24.636465897 +0200
@@ -1289,7 +1289,7 @@
{
if (union_file != 0)
{
- rewind(union_file);
+ fseek(union_file, 0, SEEK_SET);
while ((c = getc(union_file)) != EOF)
putc_code(fp, c);
}
@@ -1314,7 +1314,7 @@
if (text_file == NULL)
open_error("text_file");
- rewind(text_file);
+ fseek(text_file, 0, SEEK_SET);
in = text_file;
if ((c = getc(in)) == EOF)
return;
@@ -1684,7 +1684,7 @@
int state;
char line_state[20];
- rewind(action_file);
+ fseek(action_file, 0, SEEK_SET);
if ((c = getc(action_file)) == EOF)
return;
diff -ru ../byacc-20240109.bak/reader.c ./reader.c
--- byacc-20240109/reader.c 2024-04-14 16:06:09.646465507 +0200
+++ byacc-20240109/reader.c 2024-04-14 20:40:58.387082748 +0200
@@ -70,7 +70,7 @@
char *line_data; /* saved input-line */
size_t line_used; /* position within saved input-line */
size_t line_size; /* length of saved input-line */
- fpos_t line_fpos; /* pointer before reading past saved input-line */
+ long line_fpos; /* pointer before reading past saved input-line */
}
SAVE_LINE;
@@ -315,7 +315,7 @@
line = save_area.line_data;
cptr = save_area.line_used + line;
linesize = save_area.line_size;
- if (fsetpos(input_file, &save_area.line_fpos) != 0)
+ if (fseek(input_file, save_area.line_fpos, SEEK_SET) != 0)
on_error();
memset(&save_area, 0, sizeof(save_area));
}
@@ -338,7 +338,7 @@
save_area.line_size = linesize;
NO_SPACE(save_area.line_data);
memcpy(save_area.line_data, line, linesize);
- if (fgetpos(f, &save_area.line_fpos) != 0)
+ if ((save_area.line_fpos = ftell(f)) == -1)
on_error();
must_save = -must_save;
}
@@ -572,6 +572,36 @@
return strcmp(p->name, q->name);
}
+/*
+ * Compare keyword to cached token, treating '_' and '-' the same. Some
+ * grammars rely upon this misfeature.
+ */
+static int
+matchec(const char *name)
+{
+ const char *p = cache;
+ const char *q = name;
+ int code = 0; /* assume mismatch */
+
+ while (*p != '\0' && *q != '\0')
+ {
+ char a = *p++;
+ char b = *q++;
+ if (a == '_')
+ a = '-';
+ if (b == '_')
+ b = '-';
+ if (a != b)
+ break;
+ if (*p == '\0' && *q == '\0')
+ {
+ code = 1;
+ break;
+ }
+ }
+ return code;
+}
+
static int
keyword(void)
{
@@ -612,10 +642,36 @@
}
cachec(NUL);
- if ((key = bsearch(cache, keywords,
- sizeof(keywords) / sizeof(*key),
- sizeof(*key), compare_keys)))
- return key->token;
+ if (matchec("token") || matchec("term"))
+ return (TOKEN);
+ if (matchec("type"))
+ return (TYPE);
+ if (matchec("left"))
+ return (LEFT);
+ if (matchec("right"))
+ return (RIGHT);
+ if (matchec("nonassoc") || matchec("binary"))
+ return (NONASSOC);
+ if (matchec("start"))
+ return (START);
+ if (matchec("union"))
+ return (UNION);
+ if (matchec("ident"))
+ return (IDENT);
+ if (matchec("expect"))
+ return (EXPECT);
+ if (matchec("expect-rr"))
+ return (EXPECT_RR);
+ if (matchec("pure-parser"))
+ return (PURE_PARSER);
+ if (matchec("parse-param"))
+ return (PARSE_PARAM);
+ if (matchec("lex-param"))
+ return (LEX_PARAM);
+ if (matchec("token-table"))
+ return (TOKEN_TABLE);
+ if (matchec("yacc"))
+ return (POSIX_YACC);
}
else
{
@@ -1178,6 +1234,9 @@
return result;
}
+char *
+strdup (char const *s);
+
static void
save_param(int k, char *buffer, int name, int type2)
{

View file

@ -1 +0,0 @@
https://invisible-island.net/archives/byacc/byacc-20240109.tgz f2897779017189f1a94757705ef6f6e15dc9208ef079eea7f28abec577e08446

View file

@ -50,7 +50,7 @@ build: tar-1.12
build: sed-4.0.9 build: sed-4.0.9
build: bzip2-1.0.8 build: bzip2-1.0.8
build: coreutils-5.0 build: coreutils-5.0
build: byacc-20240109 build: oyacc-6.6
build: bash-2.05b build: bash-2.05b
improve: setup_repo improve: setup_repo
improve: update_env improve: update_env

View file

@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2019 Brian Callahan <bcallah@openbsd.org>
# SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: CC0-1.0
CC = tcc
CFLAGS = -D__dead= -D__unused=
LDFLAGS = -static
LIBS = -lgetopt
PREFIX = /usr
BINDIR = /usr/bin
MANDIR = /usr/share/man
PROG = yacc
OBJS = closure.o error.o lalr.o lr0.o main.o mkpar.o output.o reader.o \
skeleton.o symtab.o verbose.o warshall.o portable.o
all: ${PROG}
${PROG}: ${OBJS}
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS}
install: all
install -d ${DESTDIR}${BINDIR}
install -d ${DESTDIR}${MANDIR}
install -m 555 ${PROG} ${DESTDIR}${BINDIR}
install -m 555 yyfix.sh ${DESTDIR}${BINDIR}/yyfix
test:
@echo "No tests"
clean:
rm -f ${PROG} ${OBJS}
distclean: clean
rm -f Makefile config.h

View file

@ -0,0 +1,2 @@
34daad98b980e2dd6ff7c4949598445aeb47a732c1751db5bc51a92aa89f4044 /usr/bin/yacc
9d3a06dbcf75c3098dba17fab4e013bf91c78be163387b1f23862c2171b1b2c0 /usr/bin/yyfix

View file

@ -0,0 +1,46 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
set -ex
# Check tarball checksums
checksum-transcriber sources
sha256sum -c sources.SHA256SUM
mkdir build src
cd build
# Extract
cp ${DISTFILES}/${pkg}.tar.gz ../src/${pkg}.tar.gz
gunzip -f ../src/${pkg}.tar.gz
tar xf ../src/${pkg}.tar
rm -r ../src/
cd ${pkg}
# Prepare
cp ../../mk/main.mk Makefile
touch config.h
patch -Np1 -i ../../patches/meslibc.patch
patch -Np1 -i ../../patches/tcc.patch
# Build
make
# Install
make install
cd ../..
# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
sha256sum -o ${pkg}.checksums \
/usr/bin/yacc \
/usr/bin/yyfix
install ${pkg}.checksums ${SRCDIR}
else
sha256sum -c ${pkg}.checksums
fi

View file

@ -0,0 +1,75 @@
SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: BSD-3-Clause
* paths.h does not exist, hardcode /tmp
* mkstemp does not exist, replace with mktemp
* getopt.h needs explicit inclusion
* sig_atomic_t is undefineed
--- oyacc-6.6/main.c 2025-02-05 14:14:48.552829130 +1100
+++ oyacc-6.6/main.c 2025-02-05 14:20:05.025828293 +1100
@@ -35,7 +35,7 @@
#include <sys/types.h>
#include <fcntl.h>
-#include <paths.h>
+#include <getopt.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
@@ -104,7 +104,7 @@
void create_file_names(void);
void open_files(void);
-volatile sig_atomic_t sigdie;
+volatile int sigdie;
void
done(int k)
@@ -234,7 +234,7 @@
size_t len;
char *tmpdir;
- tmpdir = _PATH_TMP;
+ tmpdir = "/tmp";
len = strlen(tmpdir);
if (tmpdir[len - 1] == '/')
@@ -300,7 +300,7 @@
void
open_files(void)
{
- int fd;
+ char *fname;
create_file_names();
@@ -309,12 +309,12 @@
if (input_file == 0)
open_error(input_file_name);
}
- fd = mkstemp(action_file_name);
- if (fd == -1 || (action_file = fdopen(fd, "w")) == NULL)
+ fname = mktemp(action_file_name);
+ if (!fname || (action_file = fopen(fname, "w")) == NULL)
open_error(action_file_name);
- fd = mkstemp(text_file_name);
- if (fd == -1 || (text_file = fdopen(fd, "w")) == NULL)
+ fname = mktemp(text_file_name);
+ if (!fname || (text_file = fopen(fname, "w")) == NULL)
open_error(text_file_name);
if (vflag) {
@@ -326,8 +326,8 @@
defines_file = fopen(defines_file_name, "w");
if (defines_file == NULL)
open_write_error(defines_file_name);
- fd = mkstemp(union_file_name);
- if (fd == -1 || (union_file = fdopen(fd, "w")) == NULL)
+ fname = mktemp(union_file_name);
+ if (!fname || (union_file = fopen(fname, "w")) == NULL)
open_error(union_file_name);
}
output_file = fopen(output_file_name, "w");

View file

@ -0,0 +1,15 @@
SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: BSD-3-Clause
In tcc, a variable declared as extern that is assigned to does not work
correctly.
--- oyacc-6.6/defs.h 2025-02-05 14:23:40.883827721 +1100
+++ oyacc-6.6/defs.h 2025-02-05 14:23:43.879827713 +1100
@@ -365,4 +365,4 @@
/* system variables */
-extern char *__progname;
+char *__progname;

1
steps/oyacc-6.6/sources Normal file
View file

@ -0,0 +1 @@
https://github.com/ibara/yacc/releases/download/oyacc-6.6/oyacc-6.6.tar.gz eb0866e740b79bd3a23e0ca47885eb3148aab18d77a4bedba96e979d8b4ebfe1