[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] {ylwrap-refactor} ylwrap: pull `dos_fix_yacc_filenames' out of `ha
From: |
Stefano Lattarini |
Subject: |
[FYI] {ylwrap-refactor} ylwrap: pull `dos_fix_yacc_filenames' out of `handle_renaming' |
Date: |
Thu, 5 May 2011 19:36:37 +0200 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
* lib/ylwrap (dos_fix_yacc_filenames): Refactor so that it can run
from main code instead that only from `handle_renaming'. It now
sets ...
($y_tab_c, $y_tab_h, $y_output): ... this new global variables.
(handle_renaming): Remove call to `dos_fix_yacc_filenames'. Remove
uses of `$ofrom', which is unneeded now. Other related updates.
(Main Code): Add call to `dos_fix_yacc_filenames' just after the
wrapped script has run. Other updates.
---
ChangeLog | 12 ++++++++++++
lib/ylwrap | 37 +++++++++++++++----------------------
2 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d378296..c2656f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2011-05-05 Stefano Lattarini <address@hidden>
+ ylwrap: pull `dos_fix_yacc_filenames' out of `handle_renaming'
+ * lib/ylwrap (dos_fix_yacc_filenames): Refactor so that it can run
+ from main code instead that only from `handle_renaming'. It now
+ sets ...
+ ($y_tab_c, $y_tab_h, $y_output): ... this new global variables.
+ (handle_renaming): Remove call to `dos_fix_yacc_filenames'. Remove
+ uses of `$ofrom', which is unneeded now. Other related updates.
+ (Main Code): Add call to `dos_fix_yacc_filenames' just after the
+ wrapped script has run. Other updates.
+
+2011-05-05 Stefano Lattarini <address@hidden>
+
ylwrap: go into tempdir only when running wrapped program
* lib/ylwrap: Now chdir into the temporary directory `$dirname'
only to run the wrapped program. This will be useful mostly for
diff --git a/lib/ylwrap b/lib/ylwrap
index 4e6dd0f..058cfe0 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -62,38 +62,30 @@ tr_cpp ()
# Since DOS filename conventions don't allow two dots, the DOS version
# of Bison writes out y_tab.c instead of y.tab.c and y_tab.h instead
# of y.tab.h. Test to see if this is the case.
-# This function might set the global variable `$y_tab_nodot' (meant for
-# internal use only), and modify the global variable `$from'.
dos_fix_yacc_filenames ()
{
test $wrapped = yacc || return 0
- if test -z "$y_tab_nodot"; then
- if test -f $dirname/y_tab.c || test -f $dirname/y_tab.h; then
- y_tab_nodot=yes
- else
- y_tab_nodot=no
- fi
- fi
- if test $y_tab_nodot = yes; then
- # Handle y_tab.c and y_tab.h output by DOS
- test $from = y.tab.c && from=y_tab.c
- test $from = y.tab.h && from=y_tab.h
+ if test -f y_tab.c || test -f y_tab.h; then
+ y_tab_c=y_tab.c
+ y_tab_h=y_tab.h
+ else
+ y_tab_c=y.tab.c
+ y_tab_h=y.tab.h
fi
+ y_output=y.output
}
# Usage: handle_renaming FROM TARGET
handle_renaming ()
{
from=$1
- ofrom=$from
target=$2
- dos_fix_yacc_filenames
if test ! -f $dirname/$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".
- case $wrapped:$ofrom in
- yacc:y.tab.h|yacc:y.output) ;;
+ case $wrapped:$from in
+ yacc:$y_tab_h|yacc:$y_output) ;;
*)
echo "ylwrap: expected file \`$from' not found" >&2
ret=1
@@ -108,7 +100,7 @@ handle_renaming ()
# 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
+ if test $wrapped = yacc && test $from = $y_tab_h; then
realtarget=$target
target=header.tmp
fi
@@ -134,7 +126,7 @@ handle_renaming ()
-e "s,$FROM,$TARGET," $dirname/"$from" >"$target" || ret=$?
# Check whether header files must be updated.
- if test $wrapped = yacc && test $ofrom = y.tab.h; then
+ if test $wrapped = yacc && test $from = $y_tab_h; then
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
echo "$realtarget is unchanged"
rm -f "$target"
@@ -245,6 +237,7 @@ case $# in
*) "$prog" "$@" "$input" ;;
esac
ret=$?
+dos_fix_yacc_filenames
cd "$ocwd" || exit 1
test $ret -eq 0 || eval "$do_exit"
@@ -259,9 +252,9 @@ case $wrapped in
c_ext=`echo $y_ext | tr 'y' 'c'`
h_ext=`echo $y_ext | tr 'y' 'h'`
output_stem=`echo "$output" | sed "s/\\\\.$c_ext$//"`
- handle_renaming y.tab.c $output_stem.$c_ext
- handle_renaming y.tab.h $output_stem.$h_ext
- handle_renaming y.output $output_stem.output
+ handle_renaming $y_tab_c $output_stem.$c_ext
+ handle_renaming $y_tab_h $output_stem.$h_ext
+ handle_renaming $y_output $output_stem.output
;;
lex)
handle_renaming $lex_output_root.c $output
--
1.7.2.3
- [FYI] {ylwrap-refactor} ylwrap: various refactorings, few improvements, (continued)
- [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, 2011/05/05
- [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 <=
- [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