From c99b9d90a8f21e0df90be4732c7414e13327a792 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 1 Nov 2001 17:39:39 +0000 Subject: [PATCH] * lib/am/lex.am, lib/am/yacc.am: Use the output file name in `#line' and multiple inclusion guards. * lib/ylwrap: Remove debugging code. (input_dir, input_rx): Move where used. Use the output file name in `#line'. --- ChangeLog | 8 ++++++++ NEWS | 2 ++ lib/am/lex.am | 9 +++++++-- lib/am/yacc.am | 20 +++++++++++++++----- lib/ylwrap | 39 +++++++++++++++++++++++++-------------- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b4adab..d4b2a87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-11-01 Akim Demaille + + * lib/am/lex.am, lib/am/yacc.am: Use the output file name in + `#line' and multiple inclusion guards. + * lib/ylwrap: Remove debugging code. + (input_dir, input_rx): Move where used. + Use the output file name in `#line'. + 2001-10-31 Alexandre Duret-Lutz * automake.in (transform): Update documentation. diff --git a/NEWS b/NEWS index 864ed3b..ab550c3 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ New in 1.5a: * AM_FUNC_ERROR_AT_LINE, AM_FUNC_STRTOD, AM_FUNC_OBSTACK, AM_PTRDIFF_T are no longer shipped, since Autoconf 2.52 provides them (both as AM_ and AC_). +* `#line' of Lex and Yacc files are properly set. +* Fixed CDPATH portability problems, in particular for MacOS X. New in 1.5: * Support for `configure.ac'. diff --git a/lib/am/lex.am b/lib/am/lex.am index e835668..8d0f996 100644 --- a/lib/am/lex.am +++ b/lib/am/lex.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright 2001 Free Software Foundation, Inc. +## Copyright 2001 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. +## FIXME: These two are to be removed once we trace Autoconf, since +## they are AC_SUBST'ed. LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LEXLIB = @LEXLIB@ @@ -24,5 +26,8 @@ LEXLIB = @LEXLIB@ if %?MORE-THAN-ONE% $(SHELL) $(YLWRAP) %SOURCE% $(LEX_OUTPUT_ROOT).c %OBJ% -- %COMPILE% else !%?MORE-THAN-ONE% - %COMPILE% %SOURCE% && mv $(LEX_OUTPUT_ROOT).c %OBJ% + %COMPILE% %SOURCE% +## Edit out `#line' or `#' directives. + sed '/^#/ s/$(LEX_OUTPUT_ROOT)\.c/%OBJ%/' $(LEX_OUTPUT_ROOT).c >%OBJ% + rm $(LEX_OUTPUT_ROOT).c endif !%?MORE-THAN-ONE% diff --git a/lib/am/yacc.am b/lib/am/yacc.am index 6fc6c16..2032f0c 100644 --- a/lib/am/yacc.am +++ b/lib/am/yacc.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright 1998, 1999, 2001 Free Software Foundation, Inc. +## Copyright 1998, 1999, 2001 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,12 +21,22 @@ if %?MORE-THAN-ONE% $(SHELL) $(YLWRAP) %SOURCE% y.tab.c %OBJ% y.tab.h %BASE%.h -- %COMPILE% else !%?MORE-THAN-ONE% - %COMPILE% %SOURCE% && mv y.tab.c %OBJ% + %COMPILE% %SOURCE% +## Edit out `#line' or `#' directives. + sed '/^#/ s/y\.tab\.c/%OBJ%/' y.tab.c >%OBJ% + rm y.tab.c +## Edit out Bison multiple inclusion guards. It may be BISON_Y_TAB_H, +## or Y_TAB_H depending upon the version, that's why the regexp is +## so loose. if test -f y.tab.h; then \ - if cmp -s y.tab.h %BASE%.h; then \ - rm -f y.tab.h; \ + to=`echo "%BASE%_H" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \ + sed "/^#/ s/Y_TAB_H/$$to/g" y.tab.h >%BASE%.ht; \ + if cmp -s %BASE%.ht %BASE%.h; then \ + rm %BASE%.ht ;\ else \ - mv y.tab.h %BASE%.h; \ + mv %BASE%.ht %BASE%.h; \ fi; \ fi endif !%?MORE-THAN-ONE% diff --git a/lib/ylwrap b/lib/ylwrap index 5ea68e4..e8abf82 100755 --- a/lib/ylwrap +++ b/lib/ylwrap @@ -1,6 +1,6 @@ #! /bin/sh # ylwrap - wrapper for lex/yacc invocations. -# Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +# Copyright 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -44,14 +44,6 @@ case "$input" in ;; esac -# The directory holding the input. -input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` -# Quote $INPUT_DIR so we can use it in a regexp. -# FIXME: really we should care about more than `.' and `\'. -input_rx=`echo "$input_dir" | sed -e 's,\\\\,\\\\\\\\,g' -e 's,\\.,\\\\.,g'` - -echo "got $input_rx" - pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then @@ -94,6 +86,12 @@ if test $status -eq 0; then y_tab_nodot="yes" fi + # The directory holding the input. + input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` + # Quote $INPUT_DIR so we can use it in a regexp. + # FIXME: really we should care about more than `.' and `\'. + input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` + while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS @@ -114,11 +112,24 @@ if test $status -eq 0; then *) target="../$2";; esac - # Edit out `#line' or `#' directives. We don't want the - # resulting debug information to point at an absolute srcdir; - # it is better for it to just mention the .y file with no - # path. - sed -e "/^#/ s,$input_rx,," "$from" > "$target" || status=$? + # Edit out `#line' or `#' directives. + # + # We don't want the resulting debug information to point at + # an absolute srcdir; it is better for it to just mention the + # .y file with no path. + # + # We want to use the real output file name, not yy.lex.c for + # instance. + # + # We want the include guards to be adjusted too. + FROM=`echo "$from" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + TARGET=`echo "$2" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + sed "/^#/{s,$input_rx,,;s,$from,$2,;s,$FORM,$TO,;}" "$from" >"$target" || + status=$? else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d -- 2.7.4