[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] {ylwrap-refactor} ylwrap: new subroutine `tr_cpp'
From: |
Stefano Lattarini |
Subject: |
[FYI] {ylwrap-refactor} ylwrap: new subroutine `tr_cpp' |
Date: |
Thu, 5 May 2011 18:03:06 +0200 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
* lib/ylwrap (tr_cpp): New subroutine, turning the given string
into a suitable C preprocessor symbol.
Use it to reduce code duplication.
Add comments about when postprocessing of C preprocessor symbols
in yacc-generated header files is relevant.
---
ChangeLog | 9 +++++++++
lib/ylwrap | 23 ++++++++++++++++-------
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e2c2c81..d5fa8f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-05-05 Stefano Lattarini <address@hidden>
+ ylwrap: new subroutine `tr_cpp'
+ * lib/ylwrap (tr_cpp): New subroutine, turning the given string
+ into a suitable C preprocessor symbol.
+ Use it to reduce code duplication.
+ Add comments about when postprocessing of C preprocessor symbols
+ in yacc-generated header files is relevant.
+
+2011-05-05 Stefano Lattarini <address@hidden>
+
ylwrap: fixlets in option parsing
* lib/ylwrap: Do not recognize anymore the unused `--basedir'
option. Be stricter in matching the `--help' and `--version'
diff --git a/lib/ylwrap b/lib/ylwrap
index 8ff3308..52b6900 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -1,7 +1,7 @@
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
-scriptversion=2011-05-05.10; # UTC
+scriptversion=2011-05-05.12; # UTC
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
# 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
@@ -51,6 +51,14 @@ dirname_ ()
|| printf '%s\n' "$1" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'
}
+# Turn the given string into a suitable C preprocessor symbol.
+tr_cpp ()
+{
+ printf '%s\n' "$1" \
+ | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'
+}
+
# 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.
@@ -235,12 +243,13 @@ if test $ret -eq 0; then
# 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'`
+ # 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=$?
--
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 <=
- [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, 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