summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-11-01 09:23:49 +0200
committerSergey Poznyakoff <gray@gnu.org>2021-11-01 09:36:01 +0200
commit9792d313e43e735ac69d7be31c55ef9a033d83c6 (patch)
treed672ecfb9ddbb0740356ca26989dd8030362351b
parent305b124c78459fe1d89a6ed4ebf30a955d530a4c (diff)
downloadmailutils-9792d313e43e735ac69d7be31c55ef9a033d83c6.tar.gz
mailutils-9792d313e43e735ac69d7be31c55ef9a033d83c6.tar.bz2
Require GNU bison and flex
* am/bison.m4: Use AC_PATH_PROG. * am/flex.m4: Likewise. * configure.ac: Remove MU_YLWRAP. * include/mailutils/yyloc.h (YYLTYPE): Remove. This needs be defined in each grammar source individually. * mu-aux/Makefile.am: Remove gylwrap. * mu-aux/gylwrap: Remove. * libmailutils/cfg/Makefile.am: Rewrite rules for building grammars and lexers. * libmailutils/datetime/Makefile.am: Likewise. * libmu_sieve/Makefile.am: Likewise. * mail/Makefile.am: Likewise. * mh/Makefile.am: Likewise. * mimeview/Makefile.am: Likewise. * libmailutils/cfg/gylwrap.conf: Remove. * libmailutils/datetime/gylwrap.conf: Remove. * libmu_sieve/gylwrap.conf: Remove. * mh/gylwrap.conf: Remove. * mimeview/gylwrap.conf: Remove. * libmailutils/cfg/lexer.l: Use %option prefix * libmu_sieve/sieve-lex.l: Likewise. * mh/mh_alias_lex.l: Likewise. * mimeview/lexer.l: Likewise. * libmailutils/cfg/parser.y: Use api.prefix and %code requires. * libmailutils/datetime/parsedate.y: Likewise. * mh/mh_alias_gram.y: Likewise. * mh/mh_fmtgram.y: Likewise. * mh/pick-gram.y: Likewise. * libmu_sieve/sieve-gram.y: Likewise. * mimeview/grammar.y: Likewise. * testsuite/lib/mailutils.exp (mu_create_config): Fix source location.
-rw-r--r--am/bison.m49
-rw-r--r--am/flex.m412
-rw-r--r--bootstrap.conf11
-rw-r--r--configure.ac3
-rw-r--r--include/mailutils/yyloc.h1
-rw-r--r--libmailutils/cfg/Makefile.am16
-rw-r--r--libmailutils/cfg/gylwrap.conf4
-rw-r--r--libmailutils/cfg/lexer.l1
-rw-r--r--libmailutils/cfg/parser.y6
-rw-r--r--libmailutils/datetime/Makefile.am12
-rw-r--r--libmailutils/datetime/gylwrap.conf3
-rw-r--r--libmailutils/datetime/parsedate.y2
-rw-r--r--libmailutils/stream/file_stream.c1
-rw-r--r--libmu_sieve/Makefile.am16
-rw-r--r--libmu_sieve/gylwrap.conf4
-rw-r--r--libmu_sieve/sieve-gram.y8
-rw-r--r--libmu_sieve/sieve-lex.l13
-rw-r--r--mail/Makefile.am14
-rw-r--r--mh/Makefile.am27
-rw-r--r--mh/gylwrap.conf13
-rw-r--r--mh/mh_alias_gram.y13
-rw-r--r--mh/mh_alias_lex.l16
-rw-r--r--mh/mh_fmtgram.y4
-rw-r--r--mh/pick-gram.y7
-rw-r--r--mimeview/Makefile.am20
-rw-r--r--mimeview/grammar.y13
-rw-r--r--mimeview/gylwrap.conf3
-rw-r--r--mimeview/lexer.l11
-rw-r--r--mu-aux/Makefile.am1
-rwxr-xr-xmu-aux/gylwrap539
-rw-r--r--testsuite/lib/mailutils.exp3
31 files changed, 154 insertions, 652 deletions
diff --git a/am/bison.m4 b/am/bison.m4
index ea691f176..611ff1711 100644
--- a/am/bison.m4
+++ b/am/bison.m4
@@ -1,11 +1,6 @@
-# bison.m4 serial 2
+# bison.m4 serial 3
AC_DEFUN([MU_PROG_BISON],
[
- if test "x$ac_cv_prog_YACC" = x; then
- AC_PROG_YACC
- if ! $YACC --version 2>/dev/null | grep -q '^bison '; then
- YACC="\${SHELL} $am_aux_dir/missing bison"
- fi
- fi
+ AC_PATH_PROG([BISON],[bison],[\$(SHELL) \$(top_srcdir)/build-aux/missing bison])
])
diff --git a/am/flex.m4 b/am/flex.m4
index d29efdbe2..51a2b9fca 100644
--- a/am/flex.m4
+++ b/am/flex.m4
@@ -1,13 +1,5 @@
-# flex.m4 serial 2
+# flex.m4 serial 3
AC_DEFUN([MU_PROG_FLEX],
-[
- if test "x$LEX" = x; then
- AC_PROG_LEX
- if ! $LEX --version 2>/dev/null | grep -q '^flex '; then
- LEX="\${SHELL} $am_aux_dir/missing flex"
- AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
- AC_SUBST([LEXLIB], [''])
- fi
- fi
+[AC_PATH_PROG([FLEX],[flex],[\$(SHELL) \$(top_srcdir)/build-aux/missing flex])
])
diff --git a/bootstrap.conf b/bootstrap.conf
index c097169ba..aec769601 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -97,11 +97,12 @@ if [ -z "$help" ]; then
fi
# Grab the latest radius.m4
- test -f m4/radius.m4 ||
- wget -P m4 http://git.savannah.gnu.org/cgit/radius.git/plain/scripts/radius.m4
-
- # Create included listings for texinfo docs.
- #make -C doc/texinfo -f maint.mk
+ if [ ! -f m4/radius.m4 ]; then
+ if [ ! -d m4 ]; then
+ mkdir m4
+ fi
+ wget -P m4 http://git.savannah.gnu.org/cgit/radius.git/plain/scripts/radius.m4
+ fi
fi
bootstrap_epilogue() {
diff --git a/configure.ac b/configure.ac
index 33fa71452..452b611cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,9 +66,6 @@ AC_SUBST(MU_LIB_COMMON_INCLUDES,'-I${top_builddir} -I${top_srcdir}/include -I${
AC_SUBST(MU_APP_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_srcdir}/lib/gnu -I${top_builddir}/lib/gnu -I${top_builddir} -I${top_builddir}/include')
-# Use our replacement for the ylwrap tool
-AC_SUBST([MU_YLWRAP],'$(mu_aux_dir)/gylwrap --')
-
dnl Check for programs
AC_PROG_CC
AM_PROG_CC_C_O
diff --git a/include/mailutils/yyloc.h b/include/mailutils/yyloc.h
index a33b83323..58a2856d0 100644
--- a/include/mailutils/yyloc.h
+++ b/include/mailutils/yyloc.h
@@ -23,7 +23,6 @@ void mu_file_print_locus_point (FILE *,
void mu_file_print_locus_range (FILE *,
struct mu_locus_range const *loc);
-#define YYLTYPE struct mu_locus_range
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
{ \
diff --git a/libmailutils/cfg/Makefile.am b/libmailutils/cfg/Makefile.am
index a5fb85642..7f99ca6fd 100644
--- a/libmailutils/cfg/Makefile.am
+++ b/libmailutils/cfg/Makefile.am
@@ -20,8 +20,8 @@ noinst_LTLIBRARIES = libcfg.la
libcfg_la_SOURCES = \
driver.c\
format.c\
- lexer.l\
- parser.y
+ lexer.c\
+ parser.c
localedir = $(datadir)/locale
AM_CPPFLAGS = \
@@ -32,12 +32,18 @@ AM_CPPFLAGS = \
EXTRA_DIST = \
lexer.l\
parser.y\
- parser.h\
- gylwrap.conf
+ parser.h
BUILT_SOURCES = parser.c parser.h lexer.c
-YLWRAP = $(MU_YLWRAP)
+parser.c parser.h: parser.y
+lexer.c: lexer.l
+
AM_YFLAGS=-vdt
AM_LFLAGS=-dp
+.l.c:
+ $(FLEX) -o $@ $(AM_LFLAGS) $<
+.y.c:
+ $(BISON) -o $@ $(AM_YFLAGS) $<
+
diff --git a/libmailutils/cfg/gylwrap.conf b/libmailutils/cfg/gylwrap.conf
deleted file mode 100644
index 4a93e6f83..000000000
--- a/libmailutils/cfg/gylwrap.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-# Configuration settings for gylwrap.
-# See ../../mu-aux/gylwrap --help, for details.
-
-yyrepl = mu_cfg_yy
diff --git a/libmailutils/cfg/lexer.l b/libmailutils/cfg/lexer.l
index 600a4f0ae..c97b49b21 100644
--- a/libmailutils/cfg/lexer.l
+++ b/libmailutils/cfg/lexer.l
@@ -81,6 +81,7 @@ static struct mu_locus_point string_beg;
while (0);
%}
+%option prefix="mu_cfg_yy"
%option nounput
%option noinput
diff --git a/libmailutils/cfg/parser.y b/libmailutils/cfg/parser.y
index 29b7c11f0..4f38a0f1b 100644
--- a/libmailutils/cfg/parser.y
+++ b/libmailutils/cfg/parser.y
@@ -169,6 +169,12 @@ mu_cfg_create_node_list (mu_list_t *plist)
%}
+%define api.prefix {mu_cfg_yy}
+%code requires {
+#define MU_CFG_YYLTYPE struct mu_locus_range
+#define yylloc mu_cfg_yylloc
+#define yylval mu_cfg_yylval
+}
%locations
%expect 1
diff --git a/libmailutils/datetime/Makefile.am b/libmailutils/datetime/Makefile.am
index d670c885b..fe8f0afd7 100644
--- a/libmailutils/datetime/Makefile.am
+++ b/libmailutils/datetime/Makefile.am
@@ -21,7 +21,7 @@ libdatetime_la_SOURCES = \
dow.c\
doy.c\
jd.c\
- parsedate.y\
+ parsedate.c\
scantime.c\
streamftime.c\
strftime.c\
@@ -32,6 +32,12 @@ libdatetime_la_SOURCES = \
utcoff.c\
yd.c
+BUILT_SOURCES = parsedate.c
+EXTRA_DIST = parsedate.y
+
+parsedate.c: parsedate.y
+.y.c:
+ $(BISON) -o $@ $(AM_YFLAGS) $<
+
AM_CPPFLAGS = $(MU_LIB_COMMON_INCLUDES) -I/libmailutils
-YLWRAP = $(MU_YLWRAP)
-EXTRA_DIST = gylwrap.conf
+
diff --git a/libmailutils/datetime/gylwrap.conf b/libmailutils/datetime/gylwrap.conf
deleted file mode 100644
index 33b8c123f..000000000
--- a/libmailutils/datetime/gylwrap.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-# Configuration settings for gylwrap.
-# See ../../mu-aux/gylwrap --help, for details.
-yyrepl = pd_yy
diff --git a/libmailutils/datetime/parsedate.y b/libmailutils/datetime/parsedate.y
index d69c6d730..729e8ea30 100644
--- a/libmailutils/datetime/parsedate.y
+++ b/libmailutils/datetime/parsedate.y
@@ -213,6 +213,8 @@ static const char *yyinput;
%type <date> item time zone date day rel relspec relunit
%type <datespec> spec
+%define api.prefix {pd_yy}
+
%%
input : spec
diff --git a/libmailutils/stream/file_stream.c b/libmailutils/stream/file_stream.c
index 781fae98c..1e5b97ff1 100644
--- a/libmailutils/stream/file_stream.c
+++ b/libmailutils/stream/file_stream.c
@@ -23,6 +23,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <poll.h>
+#include <limits.h>
#if HAVE_TERMIOS_H
# include <termios.h>
diff --git a/libmu_sieve/Makefile.am b/libmu_sieve/Makefile.am
index add78165f..6d2d517a0 100644
--- a/libmu_sieve/Makefile.am
+++ b/libmu_sieve/Makefile.am
@@ -14,9 +14,7 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
-YLWRAP = $(MU_YLWRAP)
AM_YFLAGS = -dtv
-#AM_LFLAGS=-dvp
AM_CPPFLAGS =\
$(MU_LIB_COMMON_INCLUDES)\
-DMU_SIEVE_MODDIR=\"$(MU_SIEVE_MODDIR)\"
@@ -38,8 +36,8 @@ libmu_sieve_la_SOURCES = \
relational.c\
require.c\
runtime.c\
- sieve-gram.y\
- sieve-lex.l\
+ sieve-gram.c\
+ sieve-lex.c\
strexp.c\
string.c\
tests.c\
@@ -53,9 +51,15 @@ noinst_HEADERS = sieve-priv.h sieve-gram.h
BUILT_SOURCES = \
sieve-gram.c sieve-gram.h \
sieve-lex.c
+MAINTAINERCLEANFILES=$(BUILT_SOURCES)
+EXTRA_DIST = sieve-gram.y sieve-lex.l
+sieve-gram.c sieve-gram.h: sieve-gram.y
+sieve-lex.c: sieve-lex.l
-EXTRA_DIST=gylwrap.conf
+.l.c:
+ $(FLEX) -o $@ $(AM_LFLAGS) $<
+.y.c:
+ $(BISON) -o $@ $(AM_YFLAGS) $<
-MAINTAINERCLEANFILES=$(BUILT_SOURCES)
diff --git a/libmu_sieve/gylwrap.conf b/libmu_sieve/gylwrap.conf
deleted file mode 100644
index 3f574d74e..000000000
--- a/libmu_sieve/gylwrap.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-# Configuration settings for gylwrap.
-# See ../mu-aux/gylwrap --help, for details.
-
-yyrepl=mu_sieve_yy
diff --git a/libmu_sieve/sieve-gram.y b/libmu_sieve/sieve-gram.y
index dae4da70b..44a676dbb 100644
--- a/libmu_sieve/sieve-gram.y
+++ b/libmu_sieve/sieve-gram.y
@@ -37,7 +37,13 @@ static void node_list_add (struct mu_sieve_node_list *list,
%}
-%error-verbose
+%define api.prefix {mu_sieve_yy}
+%code requires {
+#define MU_SIEVE_YYLTYPE struct mu_locus_range
+#define yylloc mu_sieve_yylloc
+#define yylval mu_sieve_yylval
+}
+%define parse.error verbose
%locations
%union {
diff --git a/libmu_sieve/sieve-lex.l b/libmu_sieve/sieve-lex.l
index 4fb572896..0d13a6f4c 100644
--- a/libmu_sieve/sieve-lex.l
+++ b/libmu_sieve/sieve-lex.l
@@ -153,12 +153,12 @@ push_source (const char *name)
if (yylloc.beg.mu_file && st.st_ino == sieve_source_inode)
{
- yyerror (_("recursive inclusion"));
+ mu_sieve_yyerror (_("recursive inclusion"));
return 1;
}
if ((ctx = ctx_lookup (st.st_ino)))
{
- yyerror (_("recursive inclusion"));
+ mu_sieve_yyerror (_("recursive inclusion"));
if (ctx->prev)
{
mu_diag_at_locus_range (MU_LOG_ERROR, &ctx->incl_range,
@@ -232,6 +232,7 @@ pop_source ()
}
%}
+%option prefix="mu_sieve_yy"
%option nounput
%option noinput
@@ -344,7 +345,7 @@ get_file_name (char *p, char *endp, int *usepath)
break;
default:
- yyerror (_("preprocessor syntax"));
+ mu_sieve_yyerror (_("preprocessor syntax"));
return NULL;
}
@@ -353,7 +354,7 @@ get_file_name (char *p, char *endp, int *usepath)
if (*p != exp)
{
- yyerror (_("missing closing quote in preprocessor statement"));
+ mu_sieve_yyerror (_("missing closing quote in preprocessor statement"));
return NULL;
}
@@ -567,7 +568,7 @@ multiline_begin (void)
multiline_delimiter = strdup (".");
if (!multiline_delimiter)
{
- yyerror (_("not enough memory"));
+ mu_sieve_yyerror (_("not enough memory"));
exit (1);
}
}
@@ -587,7 +588,7 @@ ident (const char *text)
yylval.string = strdup (text);
if (!yylval.string)
{
- yyerror (_("not enough memory"));
+ mu_sieve_yyerror (_("not enough memory"));
exit (1);
}
}
diff --git a/mail/Makefile.am b/mail/Makefile.am
index cfbd93f79..a06979532 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -14,7 +14,6 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
-YLWRAP = $(MU_YLWRAP)
AM_YFLAGS=-vt
AM_CPPFLAGS = \
$(MU_APP_COMMON_INCLUDES) $(MU_AUTHINCS)\
@@ -33,8 +32,6 @@ mail_LDADD = \
$(MU_LIB_MAILUTILS)\
@READLINE_LIBS@ $(MU_COMMON_LIBRARIES)
-EXTRA_DIST = msgset.c
-
mail_SOURCES = \
alias.c\
alt.c\
@@ -63,7 +60,7 @@ mail_SOURCES = \
mailline.c\
mailvar.c\
mbox.c\
- msgset.y\
+ msgset.c\
next.c\
page.c\
pipe.c\
@@ -94,5 +91,14 @@ mail_SOURCES = \
write.c\
z.c
+BUILT_SOURCES = msgset.c
+EXTRA_DIST = msgset.y
+
+msgset.c: msgset.y
+
+.y.c:
+ $(BISON) -o $@ $(AM_YFLAGS) $<
+
+
SUBDIRS = . testsuite tests
diff --git a/mh/Makefile.am b/mh/Makefile.am
index e8325adca..5602552c9 100644
--- a/mh/Makefile.am
+++ b/mh/Makefile.am
@@ -67,14 +67,14 @@ noinst_LIBRARIES = libmh.a
libmh_a_SOURCES= \
compcommon.c\
mboxprop.c\
- mh_alias_gram.y\
- mh_alias_lex.l\
+ mh_alias_gram.c\
+ mh_alias_lex.c\
mh_getopt.c\
mh_global.c\
mh_format.c\
mh_init.c\
mh_list.c\
- mh_fmtgram.y\
+ mh_fmtgram.c\
mh_msgset.c\
mh_sequence.c\
mh_stream.c\
@@ -95,8 +95,6 @@ BUILT_SOURCES=\
MAINTAINERCLEANFILES=$(BUILT_SOURCES)
-EXTRA_DIST = gylwrap.conf
-
mhlibdir = $(pkgdatadir)/mh
AM_CPPFLAGS =\
@@ -115,10 +113,9 @@ mh_LIBS = \
$(MU_COMMON_LIBRARIES)
LDADD = $(mh_LIBS)
scan_LDADD = $(mh_LIBS) @CURSES_LIBS@
-pick_SOURCES = pick.c pick.h pick-gram.y pick-gram.h
+pick_SOURCES = pick.c pick.h pick-gram.c pick-gram.h
-YLWRAP = $(MU_YLWRAP)
-AM_YFLAGS=-vt
+AM_YFLAGS=-dt
inc_LDADD = \
./libmh.a\
@@ -143,3 +140,17 @@ install-exec-hook:
$(LN_S) show next; \
$(LN_S) show prev; \
cd $$here
+
+EXTRA_DIST = pick-gram.y mh_alias_gram.y mh_fmtgram.y mh_alias_lex.l
+
+pick-gram.c pick-gram.h: pick-gram.y
+mh_alias_gram.c mh_alias_gram.h: mh_alias_gram.y
+mh_alias_lex.c: mh_alias_lex.l
+
+mh_fmtgram.c: mh_fmtgram.y
+ $(BISON) -o $@ -t $<
+
+.l.c:
+ $(FLEX) -o $@ $(AM_LFLAGS) $<
+.y.c:
+ $(BISON) -o $@ $(AM_YFLAGS) $<
diff --git a/mh/gylwrap.conf b/mh/gylwrap.conf
deleted file mode 100644
index 995496232..000000000
--- a/mh/gylwrap.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# Configuration settings for gylwrap.
-# See ../mu-aux/gylwrap --help, for details.
-
-[pick-gram.y]
- yyrepl = pick_yy
- flags = -d
-[mh_fmtgram.y]
- yyrepl = fmt_yy
-[mh_alias_gram.y]
- yyrepl = ali_yy
- flags = -d
-[mh_alias_lex.l]
- yyrepl = ali_yy
diff --git a/mh/mh_alias_gram.y b/mh/mh_alias_gram.y
index a83120d44..653c66823 100644
--- a/mh/mh_alias_gram.y
+++ b/mh/mh_alias_gram.y
@@ -119,6 +119,12 @@ int yylex (void);
%type <string> address
%type <alias> alias
+%define api.prefix {ali_yy}
+%code requires {
+#define ALI_YYLTYPE struct mu_locus_range
+#define yylloc ali_yylloc
+#define yylval ali_yylval
+}
%locations
%%
@@ -207,6 +213,13 @@ string_list : STRING
%%
+int
+yyerror (char *s)
+{
+ mu_error ("%s", s);
+ return 0;
+}
+
static mu_list_t
ali_list_dup (mu_list_t src)
{
diff --git a/mh/mh_alias_lex.l b/mh/mh_alias_lex.l
index 9184c7aa9..6e149aa4d 100644
--- a/mh/mh_alias_lex.l
+++ b/mh/mh_alias_lex.l
@@ -32,13 +32,6 @@
static mu_linetrack_t trk;
static ino_t ali_source_inode;
-int
-yyerror (char *s)
-{
- mu_error ("%s", s);
- return 0;
-}
-
#define xinput() (yyin ? getc(yyin) : EOF)
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) do { \
@@ -223,6 +216,7 @@ pop_source (void)
extern int yyparse (void);
%}
+%option prefix="ali_yy"
%option nounput
%option noinput
@@ -272,15 +266,15 @@ mh_alias_read (char const *name, int fail)
{
int rc;
int old_mode, mode;
- extern int yydebug;
+ extern int ali_yydebug;
char *p = getenv ("ALI_YYDEBUG");
if (p && *p > '0' && *p < '9')
- yydebug = 1;
+ ali_yydebug = 1;
if (push_source (name, fail))
return 1;
- if (yydebug)
+ if (ali_yydebug)
fprintf (stderr, "Starting parse of %s\n", name);
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
@@ -288,7 +282,7 @@ mh_alias_read (char const *name, int fail)
mode = old_mode | MU_LOGMODE_LOCUS;
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
- rc = yyparse ();
+ rc = ali_yyparse ();
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_MODE, &old_mode);
return rc;
diff --git a/mh/mh_fmtgram.y b/mh/mh_fmtgram.y
index 5ffa93d4d..f1f380c46 100644
--- a/mh/mh_fmtgram.y
+++ b/mh/mh_fmtgram.y
@@ -149,8 +149,8 @@ static struct node *typecast (struct node *node, enum mh_type type);
%type <builtin> function
%type <fmtspec> fmtspec
-%error-verbose
-
+%define api.prefix {fmt_yy}
+%define parse.error verbose
%%
input : list
diff --git a/mh/pick-gram.y b/mh/pick-gram.y
index 07a91dc1e..c2cfb837c 100644
--- a/mh/pick-gram.y
+++ b/mh/pick-gram.y
@@ -38,6 +38,13 @@ static int nesting_level;
static int reg_flags = REG_EXTENDED|REG_ICASE;
%}
+%define api.prefix {pick_yy}
+%code requires {
+#define PICK_YYLTYPE struct mu_locus_range
+#define yylloc pick_yylloc
+#define yylval pick_yylval
+}
+
%token <string> T_COMP T_DATEFIELD T_STRING T_CFLAGS
%token T_LBRACE T_RBRACE T_BEFORE T_AFTER
%left T_OR
diff --git a/mimeview/Makefile.am b/mimeview/Makefile.am
index 3f12908b3..f1d80babd 100644
--- a/mimeview/Makefile.am
+++ b/mimeview/Makefile.am
@@ -24,15 +24,27 @@ AM_CPPFLAGS = \
bin_PROGRAMS = mimeview
mimeview_SOURCES = \
mimeview.c \
- grammar.y \
- lexer.l \
+ grammar.c \
+ lexer.c \
mimeview.h\
grammar.h
-YLWRAP = $(MU_YLWRAP)
AM_YFLAGS=-vtd
AM_LFLAGS=-d
-EXTRA_DIST = gylwrap.conf
+
+grammar.c grammar.h: grammar.y
+lexer.c: lexer.l
+
+BUILT_SOURCES = \
+ grammar.c grammar.h \
+ lexer.c
+
+EXTRA_DIST = grammar.y lexer.l
+
+.l.c:
+ $(FLEX) -o $@ $(AM_LFLAGS) $<
+.y.c:
+ $(BISON) -o $@ $(AM_YFLAGS) $<
mimeview_LDADD = \
$(MU_APP_LIBRARIES)\
diff --git a/mimeview/grammar.y b/mimeview/grammar.y
index 4ff399bdb..e92a459bc 100644
--- a/mimeview/grammar.y
+++ b/mimeview/grammar.y
@@ -124,6 +124,12 @@ static mu_list_t rule_list;
static size_t errors;
%}
+%define api.prefix {mimetypes_yy}
+%code requires {
+#define MIMETYPES_YYLTYPE struct mu_locus_range
+#define yylloc mimetypes_yylloc
+#define yylval mimetypes_yylval
+}
%locations
%expect 15
@@ -297,6 +303,13 @@ arg : STRING
%%
int
+yyerror (char *s)
+{
+ mu_error ("%s", s);
+ return 0;
+}
+
+int
mimetypes_parse (const char *name)
{
int rc;
diff --git a/mimeview/gylwrap.conf b/mimeview/gylwrap.conf
deleted file mode 100644
index cd41ab231..000000000
--- a/mimeview/gylwrap.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-# Configuration settings for gylwrap.
-# See ../mu-aux/gylwrap --help, for details.
-yyrepl = mimetypes_yy
diff --git a/mimeview/lexer.l b/mimeview/lexer.l
index f62be0097..64e681d74 100644
--- a/mimeview/lexer.l
+++ b/mimeview/lexer.l
@@ -87,6 +87,8 @@ finish_string (void)
%}
+%option prefix="mimetypes_yy"
+
%x RULE ARGS ASTRING
X [0-9a-fA-F]
IDENT [a-zA-Z_\.][a-zA-Z0-9_\.-]*
@@ -274,14 +276,7 @@ mimetypes_close ()
}
int
-yyerror (char *s)
-{
- mu_error ("%s", s);
- return 0;
-}
-
-int
-yywrap ()
+yywrap (void)
{
return 1;
}
diff --git a/mu-aux/Makefile.am b/mu-aux/Makefile.am
index 45a34e8d2..e5be1a407 100644
--- a/mu-aux/Makefile.am
+++ b/mu-aux/Makefile.am
@@ -16,7 +16,6 @@
EXTRA_DIST = \
debcat.awk\
- gylwrap\
mailutils.spec\
mailutils.spec.in\
texify.sed\
diff --git a/mu-aux/gylwrap b/mu-aux/gylwrap
deleted file mode 100755
index 1bcb22c8b..000000000
--- a/mu-aux/gylwrap
+++ /dev/null
@@ -1,539 +0,0 @@
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
- & eval 'exec perl -wS "$0" $argv:q'
- if 0;
-
-# This file is part of GNU Mailutils.
-# Copyright (C) 2017-2021 Free Software Foundation, Inc.
-#
-# GNU Mailutils is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 3, or (at
-# your option) any later version.
-#
-# GNU Mailutils is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
-
-use strict;
-use warnings;
-use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order auto_version);
-use File::Basename;
-use File::Temp qw(tempdir tempfile);
-use Pod::Man;
-use Pod::Usage;
-use Cwd 'abs_path';
-
-=head1 NAME
-
-gylwrap - wrapper for yacc, lex and similar programs
-
-=head1 SYNOPSIS
-
-B<gylwrap>
-[B<-?>]
-[B<--reset>]
-[B<--yyrepl=>I<PREFIX>]
-[B<--yysym=>I<STRING>]
-[B<--help>]
-[B<--version>]
-I<INPUT>
-[I<OUTPUT> I<DESIRED>]...
-B<--> I<PROGRAM> [I<ARGS>]
-
-B<gylwrap>
-B<--dump>
-[B<--reset>]
-[B<--yyrepl=>I<PREFIX>]
-[I<OUTFILE>]
-
-=head1 DESCRIPTION
-
-Wraps B<lex> and B<yacc> invocations to rename their output files.
-It also ensures that multiple I<COMMAND> instances can be invoked
-in a single directory in parallel and allows for renaming global
-symbols to avoid clashes when multiple parsers and/or lexers are
-linked in a single executable.
-
-To achieve this, B<gylwrap> creates a temporary directory, changes
-to it, and runs I<PROGRAM>, with I<ARGS> and I<INPUT> as its arguments.
-Upon successful exit from I<PROGRAM>, B<gylwrap> processes the
-I<OUTPUT>-I<DESIRED> pairs. Each I<OUTPUT> file is then renamed
-to the file I<DESIRED>, taking care to fix up any eventual B<#line>
-directives.
-
-If B<--yyrepl=I<PREFIX>> is given, the global symbols that can cause
-name clashes are renamed by replacing the initial B<yy> with I<PREFIX>.
-For a list of symbols that are subject for replacement, inspect the
-B<@sym> variable at the start of the script. Additional names can be
-added to this list using the B<--yysym> option.
-
-Prior to running the I<PROGRAM>, B<gylwrap> program checks whether the
-file named B<gylwrap.conf> exists in directory of the I<INPUT> file.
-If found, it is parsed as follows. Empty lines and comments (introduced
-by the hash sign) are ignored. Rest of lines are either option
-assignements, or section headings.
-
-Option assignements have the form B<I<OPTION> = I<VALUE>>, and generally,
-have the same meaning as the corresponding command line option without
-the leading two dashes:
-
-=over 4
-
-=item B<yyrepl => I<PREFIX>
-
-Replace the B<yy> prefix with I<PREFIX> in the identifiers.
-
-=item B<yysym => I<NAME>
-
-Add I<NAME> to the list of symbols suitable for prefix replacement.
-This keyword can appear multiple times.
-
-=item B<flags => I<STRING>
-
-Add I<STRING> to the invocation of I<COMMAND>. This is useful, if you
-have several parsers in the same directory, and some of them require
-the B<-d> option, while others don't.
-
-=back
-
-Section headers have the form B<[I<FILE>]>. The settings under a
-section header have effect only if I<FILE> is the same as the I<INPUT>
-command line argument.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<--dump>
-
-Dumps the entire program (after applying any eventual B<--yysym> options)
-to I<OUTFILE>. If I<OUTFILE> is not given, rewrite the program file with
-the output. Use this option to hardcode more replaceable symbols into
-this program. See the BOOTSTRAP section for an example.
-
-=item B<--reset>
-
-Clears the yysym array.
-
-=item B<--yyrepl=>I<PREFIX>
-
-Replace the B<yy> prefix in global symbols with I<PREFIX>.
-
-=item B<--yysym=>I<SYMBOL>
-
-Add I<SYMBOL> to the list of symbols subject for replacement.
-
-=item B<-?>, B<--help>
-
-Displays help text and exit
-
-=item B<--version>
-
-Displays program version and exits.
-
-=back
-
-=head1 NOTE
-
-This script is an improved version of the B<ylwrap> script, included
-in the GNU Automake distribution.
-
-=head1 BOOTSTRAP
-
-This version of gylwrap was bootstrapped as follows:
-
- gylwrap --dump --reset --yysym=yymaxdepth --yysym=yyparse\
- --yysym=yylex --yysym=yyerror --yysym=yylval\
- --yysym=yychar --yysym=yydebug --yysym=yypact\
- --yysym=yyr1 --yysym=yyr2 --yysym=yydef --yysym=yychk\
- --yysym=yypgo --yysym=yyact --yysym=yyexca\
- --yysym=yyerrflag --yysym=yynerrs --yysym=yyps\
- --yysym=yypv --yysym=yys --yysym=yy_yys\
- --yysym=yystate --yysym=yytmp --yysym=yyv\
- --yysym=yy_yyv --yysym=yyval --yysym=yylloc\
- --yysym=yyreds --yysym=yytoks --yysym=yylhs\
- --yysym=yylen --yysym=yydefred --yysym=yydgoto\
- --yysym=yysindex --yysym=yyrindex --yysym=yygindex\
- --yysym=yytable --yysym=yycheck --yysym=yyname\
- --yysym=yyrule --yysym=yy_create_buffer\
- --yysym=yy_delete_buffer --yysym=yy_flex_debug\
- --yysym=yy_init_buffer --yysym=yy_flush_buffer\
- --yysym=yy_load_buffer_state\
- --yysym=yy_switch_to_buffer --yysym=yyin\
- --yysym=yyleng --yysym=yylex --yysym=yylineno\
- --yysym=yyout --yysym=yyrestart --yysym=yytext\
- --yysym=yywrap --yysym=yyalloc --yysym=yyrealloc\
- --yysym=yyfree --yysym=yy_scan_buffer\
- --yysym=yy_scan_bytes --yysym=yy_scan_string\
- --yysym=yyget_debug --yysym=yyget_in\
- --yysym=yyget_leng --yysym=yyget_lineno\
- --yysym=yyget_out --yysym=yyget_text\
- --yysym=yylex_destroy --yysym=yypop_buffer_state\
- --yysym=yypush_buffer_state --yysym=yyset_debug\
- --yysym=yyset_in --yysym=yyset_lineno\
- --yysym=yyset_out
-
-=cut
-
-# List of symbols suitable for prefix replacements. See the
-# options --yyrepl and --yysym, and similar statements in the configuration
-# file.
-my @yysym = qw(
- yymaxdepth
- yyparse
- yylex
- yyerror
- yylval
- yychar
- yydebug
- yypact
- yyr1
- yyr2
- yydef
- yychk
- yypgo
- yyact
- yyexca
- yyerrflag
- yynerrs
- yyps
- yypv
- yys
- yy_yys
- yystate
- yytmp
- yyv
- yy_yyv
- yyval
- yylloc
- yyreds
- yytoks
- yylhs
- yylen
- yydefred
- yydgoto
- yysindex
- yyrindex
- yygindex
- yytable
- yycheck
- yyname
- yyrule
- yy_create_buffer
- yy_delete_buffer
- yy_flex_debug
- yy_init_buffer
- yy_flush_buffer
- yy_load_buffer_state
- yy_switch_to_buffer
- yyin
- yyleng
- yylex
- yylineno
- yyout
- yyrestart
- yytext
- yywrap
- yyalloc
- yyrealloc
- yyfree
- yy_scan_buffer
- yy_scan_bytes
- yy_scan_string
- yyget_debug
- yyget_in
- yyget_leng
- yyget_lineno
- yyget_out
- yyget_text
- yylex_destroy
- yypop_buffer_state
- yypush_buffer_state
- yyset_debug
- yyset_in
- yyset_lineno
- yyset_out
-);
-
-my @addsym;
-
-our $VERSION = '1.01';
-
-# If prefix replacement is requested, the list above is assembled into
-# a single regular expression, stored here.
-my $yyrx = q{(?:_(?:(?:crea|dele)te_buffer|fl(?:ex_debug|ush_buffer)|init_buffer|load_buffer_state|s(?:can_(?:b(?:uffer|ytes)|string)|witch_to_buffer)|yy[sv])|a(?:ct|lloc)|ch(?:ar|(?:ec)?k)|d(?:e(?:bug|f(?:red)?)|goto)|e(?:rr(?:flag|or)|xca)|free|g(?:et_(?:debug|in|l(?:eng|ineno)|(?:ou|tex)t)|index)|(?:le|i)n|l(?:e(?:ng|x(?:_destroy)?)|hs|ineno|loc|val)|maxdepth|n(?:ame|errs)|(?:ou|pac)t|p(?:arse|go|op_buffer_state|ush_buffer_state|[sv])|r(?:e(?:alloc|ds|start)|index|ule|[12])|s(?:et_(?:debug|in|lineno|out)|index|tate)?|t(?:able|ext|mp|oks)|v(?:al)?|wrap)};
-
-# String to replace the "yy" prefix with.
-my $yyrepl;
-
-# Input directory with special characters escaped, for "#line" directive
-# fixup.
-my $input_rx;
-
-# Configuration settings from the "gylwrap.conf" file. Indexed by
-# input file name. Default entry is ''.
-my %config;
-
-# Name of the first output file. This is used to avoid bailing out if
-# one of the output files (except the principal one) does not exist.
-my $parser;
-
-# Name this program was invoked as.
-my $progname = basename($0);
-
-# List of files created during the run, for cleanup purposes.
-my @created;
-
-sub filter {
- my ($from, $to) = @_;
- my $target = basename($to);
- my $ifd;
- unless (open($ifd, '<', $from)) {
- return if $from ne $parser;
- die "can't open input file $from: $!";
- }
- open(my $ofd, '>', $to)
- or die "can't open output file $to: $!";
- push @created, $to;
- while (<$ifd>) {
- if (/^#/) {
- s{$input_rx/}{};
- s{"$from"}{"$target"};
- }
- if ($yyrepl) {
- s{\byy($yyrx)\b}{${yyrepl}$1}g;
- }
- print $ofd $_
- }
- close $ifd;
- close $ofd;
-}
-
-sub readconf {
- my $file = shift;
- open(my $fd, '<', $file)
- or die "can't open $file: $!";
- my $key = '';
- while (<$fd>) {
- chomp;
- s/^\s+//;
- if (/^#/ || /^$/) {
- next;
- } elsif (/^\[(.+)\]/) {
- $key = $1;
- } elsif (m/(.+?)\s*=\s*(.+)$/) {
- if ($1 eq 'yysym' || $1 eq 'flags') {
- push @{$config{$key}{$1}}, (split /\s+/, $2);
- } else {
- $config{$key}{$1} = $2;
- }
- } else {
- print STDERR "$file:$.: unrecognized line\n";
- }
- }
- close($fd);
-}
-
-sub mkrx {
- my $ret = eval {
- require List::Regexp;
- List::Regexp::regexp_opt({ type => 'pcre' }, map { s/^yy//; $_ } @yysym);
- };
- if ($@) {
- if ($@ =~ /^Can't locate.*Regexp\.pm/) {
- die "Perl module List::Regexp is not installed. Please install it and try again";
- } else {
- die $@;
- }
- }
- return $ret;
-}
-
-sub backup {
- my $file = shift;
- my $level = shift || 0;
- my $bak = "$file~";
-
- if (-e $bak) {
- if ($level == 3) {
- unlink $bak
- or die "can't unlink outdated backup file $bak: $!";
- } else {
- backup($bak, $level + 1);
- }
- }
- rename $file, $bak
- or die "can't rename $file to $bak";
-}
-
-sub dumpme {
- my $outname = shift || $0;
- die "too many arguments for --dump option" if @_;
- open(my $in, '<', $0)
- or die "can't open $0 for reading: $!";
- my ($out, $tempname) = tempfile(basename($outname) . ".XXXXXX",
- DIR => dirname($outname));
- push @yysym, @addsym;
- my $skip;
- while (<$in>) {
- chomp;
- if ($skip) {
- next unless /^=/;
- $skip = 0;
- }
-
- if (/^(my\s+\$yyrx)\s*(?=.*)?;\s*?/) {
- my $rx = mkrx;
- print $out "$1 = q{$rx};\n";
- } elsif (s/^(my \@yysym\s+=).*/$1/) {
- my $start = $.;
- print $out "$_ qw(\n"
- . join("\n", map { " $_" } @yysym) . "\n";
- while (<$in>) {
- if (/^\);/) {
- $start = undef;
- last;
- }
- }
-
- die "can't find closing parenthesis in definition at $0:$start"
- if defined $start;
- redo;
- } elsif (/^=head1\s+BOOTSTRAP/) {
- print $out "$_\n\n";
- print $out "This version of gylwrap was bootstrapped as follows:\n\n";
- my $s = " gylwrap --dump --reset ";
- print $out $s;
- my $len = length($s);
- foreach my $sym (@yysym) {
- my $opt = "--yysym=$sym";
- my $l = length($opt);
- if ($len + $l + 1 > 64) {
- print $out "\\\n ";
- $len = 10;
- } else {
- $opt = " $opt";
- }
- print $out $opt;
- $len += length($opt);
- }
- print $out "\n\n";
- $skip = 1;
- } else {
- print $out "$_\n";
- }
- }
- close($in);
- close($out);
-
- if (-e $outname) {
- backup($outname);
- }
-
- rename $tempname, $outname
- or die "can't rename $tempname to $outname: $!";
- chmod 0755, $outname;
-
- exit(0);
-}
-
-my $input;
-my @output;
-my $dump;
-
-GetOptions("yyrepl=s" => \$yyrepl,
- "yysym=s@" => \@addsym,
- "reset" => sub { $yyrx = undef; @yysym = () },
- "dump" => \$dump,
- "help|?" => sub {
- pod2usage(-exitstatus => 0, -verbose => 2);
- }
- ) or exit(1);
-
-die "some --yysym arguments don't start with yy"
- if @addsym && grep(!/^yy/, @addsym);
-
-dumpme(@ARGV) if $dump;
-
-$input = shift @ARGV;
-while (my $arg = shift @ARGV) {
- last if ($arg eq '--');
- push @output, $arg;
-}
-
-pod2usage(-exitstatus => 1, -verbose => 0, -output => \*STDERR)
- unless (@output && (@output % 2) == 0);
-
-# Make sure input file name is absolute
-$input = abs_path($input);
-
-my $input_dir = dirname($input);
-$input_rx = qr($input_dir);
-
-my $confile = "$input_dir/gylwrap.conf";
-readconf($confile) if -r $confile;
-
-my $input_base = basename($input);
-unless ($yyrepl) {
- $yyrepl = $config{$input_base}{yyrepl} || $config{''}{yyrepl};
-}
-if ($yyrepl) {
- push @addsym, @{$config{$input_base}{yysym}}
- if exists $config{$input_base}{yysym};
- push @addsym, @{$config{''}{yysym}}
- if exists $config{''}{yysym};
- if (@addsym) {
- push @yysym, @addsym;
- $yyrx = undef;
- }
-}
-$yyrx = mkrx unless defined($yyrx);
-
-if (my $flags = $config{$input_base}{flags} || $config{''}{flags}) {
- push @ARGV, @$flags;
-}
-push @ARGV, $input;
-
-$parser = $output[0];
-
-# Create working directory
-my $wd = tempdir("ylXXXXXX", DIR => '.', CLEANUP => 1)
- or die "cannot create temporary directory";
-chdir $wd
- or die "cannot change to the temporary directory";
-END {
- if ($?) {
- unlink @created;
- }
- chdir "..";
-}
-
-system(@ARGV);
-if ($? == -1) {
- print STDERR "$ARGV[0]: $!\n";
- exit(127);
-} elsif ($? & 127) {
- print STDERR "$ARGV[0] died with signal ".($? & 127)."\n";
- exit(127);
-} else {
- my $code = $? >> 8;
- exit($code) if $code;
-}
-
-while (my $from = shift @output) {
- my $to = shift @output;
- $to = '../' . $to unless $to =~ m{^/};
- filter($from, $to);
-}
-
-exit 0;
-
-# Local Variables:
-# mode: perl
-# End:
-
-
diff --git a/testsuite/lib/mailutils.exp b/testsuite/lib/mailutils.exp
index 236fa0f1f..30f15a6d6 100644
--- a/testsuite/lib/mailutils.exp
+++ b/testsuite/lib/mailutils.exp
@@ -93,7 +93,8 @@ proc mu_makespool args {
proc mu_create_config {name} {
global objdir
- mu_copy_file $objdir/$name.rcin $objdir/$name.rc
+ global srcdir
+ mu_copy_file $srcdir/$name.rcin $objdir/$name.rc
}
proc mu_init {args} {

Return to:

Send suggestions and report system problems to the System administrator.