automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [PATCH 04/17] [ng] am: implement $(am__tolower) and $(am__


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH 04/17] [ng] am: implement $(am__tolower) and $(am__toupper)
Date: Tue, 22 May 2012 22:48:42 +0200

These new make functions will be useful in future changes.

* lib/am/header-vars.am (am__toupper, am__tolower): New make functions.
* t/internals.tap: Test them.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 lib/am/header-vars.am |   16 ++++++++++++++++
 t/internals.tap       |   44 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 79dde9c..98a8042 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -83,6 +83,22 @@ am__uniq = $(strip \
            $(am__empty), \
            $(lastword $(1)))))
 
+## These definitions have been generated by the following Bash 4 script:
+##
+##    #!/bin/bash
+##    toupper='$1' tolower='$1'
+##    for c in {a..z}; do
+##        C=${c^^}
+##        toupper="\$(subst $c,$C,$toupper)"
+##        tolower="\$(subst $C,$c,$tolower)"
+##    done
+##    echo "am__tolower = $tolower"
+##    echo "am__toupper = $toupper"
+
+am__tolower = $(subst Z,z,$(subst Y,y,$(subst X,x,$(subst W,w,$(subst 
V,v,$(subst U,u,$(subst T,t,$(subst S,s,$(subst R,r,$(subst Q,q,$(subst 
P,p,$(subst O,o,$(subst N,n,$(subst M,m,$(subst L,l,$(subst K,k,$(subst 
J,j,$(subst I,i,$(subst H,h,$(subst G,g,$(subst F,f,$(subst E,e,$(subst 
D,d,$(subst C,c,$(subst B,b,$(subst A,a,$1))))))))))))))))))))))))))
+
+am__toupper = $(subst z,Z,$(subst y,Y,$(subst x,X,$(subst w,W,$(subst 
v,V,$(subst u,U,$(subst t,T,$(subst s,S,$(subst r,R,$(subst q,Q,$(subst 
p,P,$(subst o,O,$(subst n,N,$(subst m,M,$(subst l,L,$(subst k,K,$(subst 
j,J,$(subst i,I,$(subst h,H,$(subst g,G,$(subst f,F,$(subst e,E,$(subst 
d,D,$(subst c,C,$(subst b,B,$(subst a,A,$1))))))))))))))))))))))))))
+
 ## Simple memoization for recursive make variables.  It is useful for
 ## situations where immediate variables can't be used (due, say, to
 ## ordering issues with the assignments of the referenced variables),
diff --git a/t/internals.tap b/t/internals.tap
index f6ea954..44b8912 100755
--- a/t/internals.tap
+++ b/t/internals.tap
@@ -19,7 +19,7 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-plan_ 4
+plan_ 6
 
 cp "$am_amdir"/header-vars.am . \
   || fatal_ "fetching makefile fragment headers-vars.am"
@@ -34,6 +34,9 @@ rm -f header-vars.am
 cat > Makefile << 'END'
 include ./defn.mk
 
+lo = abcdefghijklmnopqrstuvwxyz
+up = ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
 default:
        @echo Please select an explicit test; exit 1
 .PHONY: default
@@ -104,11 +107,50 @@ test-strip-suffixes:
              = 'foo.b bar'
        test '$(call am__strip_suffixes, .b.a .a, foo.b.a bar.a)' \
              = 'foo bar'
+
+.PHONY: test-tolower
+test-tolower:
+
+.PHONY: test-toupper
+test-toupper:
+       test '$(call am__toupper,a)'  = A
+       test '$(call am__toupper,A)'  = A
+       test '$(call am__toupper,aba)' = ABA
+       test '$(call am__toupper,a b)' = 'A B'
+       test '$(call am__toupper, a B)' = ' A B'
+       test '$(call am__toupper,Ab  )' = 'AB  '
+       test '$(call am__toupper,A       B c )' = 'A     B C '
+       test '$(call am__toupper,0)'  = 0
+       test '$(call am__toupper,0d)' = 0D
+       test '$(call am__toupper,@:&/?-)' = '@:&/?-'
+       test '$(call am__toupper,address@hidden)' = address@hidden
+       test '$(call am__toupper,zxzxzxZXZxzxzxzxzx)' = ZXZXZXZXZXZXZXZXZX
+       test '$(call am__toupper,$(lo))' = '$(up)'
+       test '$(call am__toupper,$(up))' = '$(up)'
+
+.PHONY: test-tolower
+test-tolower:
+       test '$(call am__tolower,A)'  = a
+       test '$(call am__tolower,a)'  = a
+       test '$(call am__tolower,ABA)' = aba
+       test '$(call am__tolower,A B)' = 'a b'
+       test '$(call am__tolower, A b)' = ' a b'
+       test '$(call am__tolower,aB  )' = 'ab  '
+       test '$(call am__tolower,a       b C )' = 'a     b c '
+       test '$(call am__tolower,0)'  = 0
+       test '$(call am__tolower,0D)' = 0d
+       test '$(call am__tolower,@:&/?-)' = '@:&/?-'
+       test '$(call am__tolower,address@hidden)' = address@hidden
+       test '$(call am__tolower,ZXZXZXzxzXZXZXZXZX)' = zxzxzxzxzxzxzxzxzx
+       test '$(call am__tolower,$(up))' = '$(lo)'
+       test '$(call am__tolower,$(lo))' = '$(lo)'
 END
 
 command_ok_  am__strip_firstword        $MAKE test-strip-firstword
 command_ok_  am__strip_lastword         $MAKE test-strip-lastword
 command_ok_  am__uniq                   $MAKE test-uniq
 command_ok_  am__test_strip_suffixes    $MAKE test-strip-suffixes
+command_ok_  am__tolower                $MAKE test-tolower
+command_ok_  am__toupper                $MAKE test-toupper
 
 :
-- 
1.7.9.5




reply via email to

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