[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/3] ylwrap: refactor
From: |
Akim Demaille |
Subject: |
[PATCH 1/3] ylwrap: refactor |
Date: |
Thu, 12 Jul 2012 15:51:57 +0200 |
* lib/ylwrap (guard): New function.
Move functions before actual code.
---
lib/ylwrap | 48 ++++++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/lib/ylwrap b/lib/ylwrap
index 6879d8d..fd29af8 100755
--- a/lib/ylwrap
+++ b/lib/ylwrap
@@ -1,7 +1,7 @@
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
-scriptversion=2011-08-25.18; # UTC
+scriptversion=2012-07-12.12; # UTC
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
#
@@ -29,6 +29,31 @@ scriptversion=2011-08-25.18; # UTC
# bugs to <address@hidden> or send patches to
# <address@hidden>.
+get_dirname ()
+{
+ case $1 in
+ */*|*\\*) printf '%s\n' "$1" | sed -e 's,\([\\/]\)[^\\/]*$,\1,';;
+ # Otherwise, we want the empty string (not ".").
+ esac
+}
+
+# guard FILE
+# ----------
+# The CPP macro used to guard inclusion of FILE.
+guard()
+{
+ echo "$from" \
+ | sed \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'
+}
+
+quote_for_sed ()
+{
+ # FIXME: really we should care about more than '.' and '\'.
+ sed -e 's,[\\.],\\&,g'
+}
+
case "$1" in
'')
echo "$0: No files given. Try '$0 --help' for more information." 1>&2
@@ -62,19 +87,6 @@ EOF
;;
esac
-get_dirname ()
-{
- case $1 in
- */*|*\\*) printf '%s\n' "$1" | sed -e 's,\([\\/]\)[^\\/]*$,\1,';;
- # Otherwise, we want the empty string (not ".").
- esac
-}
-
-quote_for_sed ()
-{
- # FIXME: really we should care about more than '.' and '\'.
- sed -e 's,[\\.],\\&,g'
-}
# The input.
input="$1"
@@ -178,12 +190,8 @@ if test $ret -eq 0; then
# 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'`
+ FROM=`guard "$from"`
+ TARGET=`guard "$2"`
sed -e "/^#/!b" -e "s,$input_rx,$input_sub_rx," -e "s,$from,$2," \
-e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
--
1.7.11.1
- Re: [PATCH 0/4] ylwrap: support C++ and others that generate several files, (continued)
- Re: [PATCH 0/4] ylwrap: support C++ and others that generate several files, Stefano Lattarini, 2012/07/14
- Re: [PATCH 0/4] ylwrap: support C++ and others that generate several files, Stefano Lattarini, 2012/07/14
- yacc-work: rebased on maint, one more fixlet (was: Re: [PATCH 0/4] ylwrap: support C++ and others that generate several files), Stefano Lattarini, 2012/07/14
- Re: yacc-work: rebased on maint, one more fixlet (was: Re: [PATCH 0/4] ylwrap: support C++ and others that generate several files), Akim Demaille, 2012/07/14
- Re: yacc-work: rebased on maint, one more fixlet, Stefano Lattarini, 2012/07/14
- Re: [PATCH 0/4] ylwrap: support C++ and others that generate several files, Akim Demaille, 2012/07/14
- Re: [PATCH 3/3] ylwrap: rename header inclusion in generated parsers, Stefano Lattarini, 2012/07/14
- Re: [PATCH 3/3] ylwrap: rename header inclusion in generated parsers, Stefano Lattarini, 2012/07/14
- Re: [PATCH 3/3] ylwrap: rename header inclusion in generated parsers, Akim Demaille, 2012/07/15
- Re: [PATCH 3/3] ylwrap: rename header inclusion in generated parsers, Stefano Lattarini, 2012/07/16
[PATCH 1/3] ylwrap: refactor,
Akim Demaille <=
Re: [PATCH 0/3] ylwrap: handle header inclusion properly, Stefano Lattarini, 2012/07/12