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

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