[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] {ylwrap-refactor} ylwrap: cleanup refactoring (no semantic change)
From: |
Stefano Lattarini |
Subject: |
[FYI] {ylwrap-refactor} ylwrap: cleanup refactoring (no semantic change) |
Date: |
Thu, 5 May 2011 19:03:15 +0200 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
* lib/ylwrap (handle_renaming): Restructure to remove a longish
if/else construct.
---
ChangeLog | 6 +++
lib/ylwrap | 101 ++++++++++++++++++++++++++++++-----------------------------
2 files changed, 57 insertions(+), 50 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e262cce..264c5fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-05-05 Stefano Lattarini <address@hidden>
+ ylwrap: cleanup refactoring (no semantic change)
+ * lib/ylwrap (handle_renaming): Restructure to remove a longish
+ if/else construct.
+
+2011-05-05 Stefano Lattarini <address@hidden>
+
ylwrap: warn when expected output files are missing
* lib/ylwrap (handle_renaming): Warn if an expected output file
from the wrapped program is missing, instead of just erroring out
diff --git a/lib/ylwrap b/lib/ylwrap
index 77e68a3..dfff700 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -87,56 +87,7 @@ handle_renaming ()
from=$1
ofrom=$from
dos_fix_yacc_filenames
- if test -f "$from"; then
- # If $2 is an absolute path name, then just use that,
- # otherwise prepend `../'.
- case $2 in
- [\\/]* | ?:[\\/]*) target=$2;;
- *) target=../$2;;
- esac
-
- # We do not want to overwrite a header file if it hasn't
- # changed. This avoid useless recompilations. However the
- # parser itself (the first file) should always be updated,
- # because it is the destination of the .y.c rule in the
- # Makefile. Divert the output of all other files to a temporary
- # file so we can compare them to existing versions.
- if test $wrapped = yacc && test $ofrom = y.tab.h; then
- realtarget=$target
- target=header.tmp
- fi
- # 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.
- # TODO: This include guards seems not to be generated anymore
- # by newer bison versions (at least starting from 1.875; they
- # were still generated in version 1.75, though). Also, BSD and
- # Solaris yacc seems not to generate such include guards either.
- # So, how much is this code still relevant today?
- FROM=`tr_cpp "$from"`
- TARGET=`tr_cpp "$2"`
-
- sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
- -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
-
- # Check whether header files must be updated.
- if test $wrapped = yacc && test $ofrom = y.tab.h; then
- if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
- echo "$2" is unchanged
- rm -f "$target"
- else
- echo updating "$2"
- mv -f "$target" "$realtarget"
- fi
- fi
- else # ! -f $from
+ if test ! -f $from; then
# When using yacc, if the `-d' option is not used, we don't want an
# error when the header file is "missing". Similarly, if `-v' is not
# used, we don't want an error when the `y.output' file is "missing".
@@ -147,6 +98,56 @@ handle_renaming ()
ret=1
;;
esac
+ return
+ fi
+
+ # If $2 is an absolute path name, then just use that,
+ # otherwise prepend `../'.
+ case $2 in
+ [\\/]* | ?:[\\/]*) target=$2;;
+ *) target=../$2;;
+ esac
+
+ # We do not want to overwrite a header file if it hasn't
+ # changed. This avoid useless recompilations. However the
+ # parser itself (the first file) should always be updated,
+ # because it is the destination of the .y.c rule in the
+ # Makefile. Divert the output of all other files to a temporary
+ # file so we can compare them to existing versions.
+ if test $wrapped = yacc && test $ofrom = y.tab.h; then
+ realtarget=$target
+ target=header.tmp
+ fi
+ # 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.
+ # TODO: This include guards seems not to be generated anymore
+ # by newer bison versions (at least starting from 1.875; they
+ # were still generated in version 1.75, though). Also, BSD and
+ # Solaris yacc seems not to generate such include guards either.
+ # So, how much is this code still relevant today?
+ FROM=`tr_cpp "$from"`
+ TARGET=`tr_cpp "$2"`
+
+ sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
+ -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
+
+ # Check whether header files must be updated.
+ if test $wrapped = yacc && test $ofrom = y.tab.h; then
+ if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
+ echo "$2" is unchanged
+ rm -f "$target"
+ else
+ echo updating "$2"
+ mv -f "$target" "$realtarget"
+ fi
fi
}
--
1.7.2.3
- [FYI] {ylwrap-refactor} Refactoring (eventual rewriting) of the `ylwrap' script., Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: various refactorings, few improvements, Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: fixlets in option parsing, Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: make less general and more "expert", Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: new subroutine `tr_cpp', Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: new subroutine `handle_renaming', Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: warn when expected output files are missing, Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: cleanup refactoring (no semantic change),
Stefano Lattarini <=
- [FYI] {ylwrap-refactor} ylwrap: another cleanup refactoring (no semantic change), Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: get rid of the loop on "FROM TARGET" couples, Stefano Lattarini, 2011/05/05
- FYI] {ylwrap-refactor} ylwrap: go into tempdir only when running wrapped program, Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: pull `dos_fix_yacc_filenames' out of `handle_renaming', Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: move "update if changed" logic out of `handle_renaming', Stefano Lattarini, 2011/05/05
- [FYI] {ylwrap-refactor} ylwrap: some renaming of variables and subroutines, Stefano Lattarini, 2011/05/06
- [FYI] {ylwrap-refactor} ylwrap: fix indentation, Stefano Lattarini, 2011/05/06
- [FYI] {ylwrap-refactor} ylwrap: rename 'handle_renaming' to 'tempfile_deploy', Stefano Lattarini, 2011/05/06
- [FYI] {ylwrap-refactor} merged branch 'yacc-work', Stefano Lattarini, 2011/05/06