automake
[Top][All Lists]
Advanced

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

PATCH: patsubst support


From: Alex Hornby
Subject: PATCH: patsubst support
Date: Wed, 25 Oct 2000 14:46:50 +0100 (BST)

Akim,

Here is a patch to add patsubst support to value_to_list. I've
included a new test case "patsubst.test" as well. 

After applying the patch you will need to make patsubst.test
executable, as I haven't yet found a way to make diffs include
permissions :)

Cheers,
Alex.

diff -r -P -u automake/ChangeLog.entry automake-patsubst/ChangeLog.entry
--- automake/ChangeLog.entry    Thu Jan  1 01:00:00 1970
+++ automake-patsubst/ChangeLog.entry   Wed Oct 25 14:16:08 2000
@@ -0,0 +1,5 @@
+2000-10-25  Alex Hornby <address@hidden>
+
+       * automake.in (value_to_list): added support for patsubst
+       style variable substitution.
+
diff -r -P -u automake/automake.in automake-patsubst/automake.in
--- automake/automake.in        Wed Oct 25 11:25:01 2000
+++ automake-patsubst/automake.in       Wed Oct 25 14:20:07 2000
@@ -5902,16 +5902,34 @@
            {
                $varname = $1;
                $to = $3;
-               ($from = $2) =~ s/(\W)/\\$1/g;
+               ($from = $2) =~ s/(\W)/$1/g;
            }
 
            # Find the value.
            @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
 
            # Now rewrite the value if appropriate.
-           if ($from)
+           if ($from =~ '^([^%]*)%([^%]*)')
            {
-               grep (s/$from$/$to/, @temp_list);
+               # patsubst style substitution
+               local ($prefrom, $suffrom, $preto, $sufto);
+               $prefrom = $1;
+               $suffrom = $2;
+
+               if ( $to =~  '^([^%]*)%([^%]*)')
+               {
+                   $preto = $1;
+                   $sufto = $2;
+               }
+               grep { 
+                   s/^$prefrom/$preto/;
+                   s/$suffrom$/$sufto/;
+               } @temp_list;
+           }
+           elsif ($from)
+           {
+               # standard substitution reference style
+               grep (s/$from$/$to/, @temp_list);
            }
 
            push (@result, @temp_list);
diff -r -P -u automake/tests/ChangeLog.entry 
automake-patsubst/tests/ChangeLog.entry
--- automake/tests/ChangeLog.entry      Thu Jan  1 01:00:00 1970
+++ automake-patsubst/tests/ChangeLog.entry     Wed Oct 25 14:15:54 2000
@@ -0,0 +1,5 @@
+2000-10-25  Alex Hornby <address@hidden>
+
+       * patsubst.test: added test for new patsubst expansion
+
+       * Makefile.am: reference patsubst.test
diff -r -P -u automake/tests/Makefile.am automake-patsubst/tests/Makefile.am
--- automake/tests/Makefile.am  Wed Oct 25 11:25:02 2000
+++ automake-patsubst/tests/Makefile.am Wed Oct 25 14:13:05 2000
@@ -181,6 +181,7 @@
 output5.test \
 package.test \
 parse.test \
+patsubst.test \
 pluseq.test \
 pluseq2.test \
 pluseq3.test \
diff -r -P -u automake/tests/patsubst.test automake-patsubst/tests/patsubst.test
--- automake/tests/patsubst.test        Thu Jan  1 01:00:00 1970
+++ automake-patsubst/tests/patsubst.test       Wed Oct 25 14:13:01 2000
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+# Test `patsubst expansion' functionality.
+
+. $srcdir/defs || exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+BASENAMES = zar doz
+zardoz_SOURCES = ${BASENAMES:%=%.c}
+END
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+END
+
+: > zar.c
+: > doz.c
+
+$AUTOMAKE || exit 1
+fgrep 'zar.o doz.o' Makefile.in



reply via email to

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