automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] ylwrap: refactoring: don't rely on the file order


From: Akim Demaille
Subject: [PATCH 2/4] ylwrap: refactoring: don't rely on the file order
Date: Sat, 14 Jul 2012 10:32:07 +0200

Forthcoming changes will make us iterate over the files in a different
order.

lib/ylwrap (first): Remove, replaced by...
(parser): this.
---
 lib/ylwrap | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/ylwrap b/lib/ylwrap
index 725b388..4ad820d 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -117,6 +117,9 @@ if test -f y_tab.c || test -f y_tab.h; then
   y_tab_nodot=true
 fi
 
+# The parser itself, the first file, is the destination of the .y.c
+# rule in the Makefile.
+parser=$1
 # The list of file to rename: FROM TO...
 pairlist=
 # A sed program to s/FROM/TO/g for all the FROM/TO so that, for
@@ -173,7 +176,6 @@ ret=$?
 if test $ret -eq 0; then
   set X $pairlist
   shift
-  first=yes
 
   input_rx=`get_dirname "$input" | quote_for_sed`
 
@@ -207,8 +209,8 @@ if test $ret -eq 0; then
       sed -e "/^#/!b" -e "s|$input_rx|$input_sub_rx|" -e "$rename_sed" \
           -e "s|$FROM|$TARGET|" "$from" >"$target" || ret=$?
 
-      # Check whether header files must be updated.
-      if test $first = no; then
+      # Check whether files must be updated.
+      if test "$from" != "$parser"; then
         if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
           echo "$to is unchanged"
           rm -f "$target"
@@ -218,17 +220,15 @@ if test $ret -eq 0; then
         fi
       fi
     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
-      # is not specified, we don't want an error when the header
-      # file is "missing".
-      if test $first = yes; then
+      # A missing file is only an error for the parser.  This is a
+      # blatant hack to let us support using "yacc -d".  If -d is not
+      # specified, don't fail when the header file is "missing".
+      if test "$from" = "$parser"; then
         ret=1
       fi
     fi
     shift
     shift
-    first=no
   done
 else
   ret=$?
-- 
1.7.11.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]