summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2012-12-19 14:51:58 +0100
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-12-21 19:32:31 +0100
commit27eb4254ec9acdd435bbd76a54201955a1b0fa78 (patch)
tree70ac4046705e8514c66cbc19ef2fe6848570279e
parentb9951d654abb76c5419f1e2b453f1ca06fdb331b (diff)
downloadautomake-27eb4254ec9acdd435bbd76a54201955a1b0fa78.tar.gz
ylwrap: various fixes
Rename properly header guards in generated header files, instead of leaving Y_TAB_H. Convert header guards in implementation files. Because ylwrap failed to rename properly #include in the implementation files, current versions of Bison (e.g., 2.7) duplicate the generated header file in the implementation file. The header guard then protects the implementation file from duplicate definitions from the header file. Generate header guards with a single '_' for series of non alphabetic characters, instead of several. This is what Bison does. Makes the test t/yacc-d-basic.sh pass again. * lib/ylwrap (guard): Properly honor $1 to rename properly the header guards. Keep a single _ instead of several. (rename_sed): Rename as... (sed_fix_filenames): this. Suggested by Stefano Lattarini. (sed_fix_header_guards): New. Use it.
-rw-r--r--NEWS18
-rwxr-xr-xlib/ylwrap33
2 files changed, 39 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index 5bf437976..b946c2aa5 100644
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,18 @@ New in 1.13:
should take precedence over the same-named automake-provided macro
(defined in '/usr/local/share/aclocal-1.14/vala.m4').
+* Bugs fixed:
+
+ - ylwrap renames properly header guards in generated header files
+ (*.h), instead of leaving Y_TAB_H.
+
+ - ylwrap now also converts header guards in implementation files
+ (*.c). Because ylwrap failed to rename properly #include in the
+ implementation files, current versions of Bison (e.g., 2.7)
+ duplicate the generated header file in the implementation file.
+ The header guard then protects the implementation file from
+ duplicate definitions from the header file.
+
* Version requirements:
- Autoconf 2.65 or greater is now required.
@@ -206,6 +218,12 @@ New in 1.13:
- Support for tcc (the Tiny C Compiler) has been improved, and is now
handled through a dedicated 'tcc' mode.
+* The ylwrap script:
+
+ - ylwrap generates header guards with a single '_' for series of non
+ alphabetic characters, instead of several. This is what Bison >=
+ 2.5.1 does.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bugs fixed in 1.12.6:
diff --git a/lib/ylwrap b/lib/ylwrap
index 7befa46de..b5c673d5f 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -1,7 +1,7 @@
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
-scriptversion=2012-07-14.08; # UTC
+scriptversion=2012-12-21.17; # UTC
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
#
@@ -42,10 +42,11 @@ get_dirname ()
# The CPP macro used to guard inclusion of FILE.
guard()
{
- printf '%s\n' "$from" \
- | sed \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
- -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'
+ printf '%s\n' "$1" \
+ | sed \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \
+ -e 's/__*/_/g'
}
# quote_for_sed [STRING]
@@ -121,10 +122,16 @@ fi
# The parser itself, the first file, is the destination of the .y.c
# rule in the Makefile.
parser=$1
+
# A sed program to s/FROM/TO/g for all the FROM/TO so that, for
# instance, we rename #include "y.tab.h" into #include "parse.h"
# during the conversion from y.tab.c to parse.c.
-rename_sed=
+sed_fix_filenames=
+
+# Also rename header guards, as Bison 2.7 for instance uses its header
+# guard in its implementation file.
+sed_fix_header_guards=
+
while test "$#" -ne 0; do
if test "$1" = "--"; then
shift
@@ -141,7 +148,8 @@ while test "$#" -ne 0; do
shift
to=$1
shift
- rename_sed="${rename_sed}s|"`quote_for_sed "$from"`"|$to|g;"
+ sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
+ sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
done
# The program to run.
@@ -174,7 +182,7 @@ ret=$?
if test $ret -eq 0; then
for from in *
do
- to=`printf '%s\n' "$from" | sed "$rename_sed"`
+ to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
if test -f "$from"; then
# If $2 is an absolute path name, then just use that,
# otherwise prepend '../'.
@@ -197,10 +205,11 @@ if test $ret -eq 0; then
# debug information point at an absolute srcdir. Use the real
# output file name, not yy.lex.c for instance. Adjust the
# include guards too.
- FROM=`guard "$from"`
- TARGET=`guard "$to"`
- sed -e "/^#/!b" -e "s|$input_rx|$input_sub_rx|" -e "$rename_sed" \
- -e "s|$FROM|$TARGET|" "$from" >"$target" || ret=$?
+ sed -e "/^#/!b" \
+ -e "s|$input_rx|$input_sub_rx|" \
+ -e "$sed_fix_filenames" \
+ -e "$sed_fix_header_guards" \
+ "$from" >"$target" || ret=$?
# Check whether files must be updated.
if test "$from" != "$parser"; then