automake-patches
[Top][All Lists]
Advanced

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

[RFC 07/20] depcomp: don't rely on character ranges working as in C loca


From: Stefano Lattarini
Subject: [RFC 07/20] depcomp: don't rely on character ranges working as in C locale
Date: Thu, 18 Oct 2012 22:40:41 +0200

* lib/depcomp (pgcc): Here.
Related reorganization, with the unconditional definition of ...
($upper, $lower, $digits, $alnum, $alpha): ... these shell variables.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 lib/depcomp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/lib/depcomp b/lib/depcomp
index e651d86..ed1997e 100755
--- a/lib/depcomp
+++ b/lib/depcomp
@@ -61,6 +61,13 @@ tab='        '
 # A newline character.
 nl='
 '
+# Character ranges might be problematic outside the C locale.
+# These definitions help.
+upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
+alpha=${upper}${lower}
+alnum=${alpha}${digits}
 
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   echo "depcomp: Variables source, object and depmode must be set" 1>&2
@@ -161,7 +168,6 @@ gcc)
   fi
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
 ## The second -e expression handles DOS-style file names with drive letters.
   sed -e 's/^[^:]*: / /' \
       -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
@@ -272,8 +278,8 @@ aix)
     # Each line is of the form 'foo.o: dependent.h'.
     # Do two passes, one to just change these to
     # '$object: dependent.h' and one to simply 'dependent.h:'.
-    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> 
"$depfile"
+    sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" >> 
"$depfile"
   else
     # The sourcefile does not contain any dependencies, so just
     # store a dummy comment line, to avoid errors with the Makefile
@@ -348,7 +354,7 @@ pgcc)
   test "x$dir" = "x$object" && dir=
   # Use the source, not the object, to determine the base name, since
   # that's sadly what pgcc will do too.
-  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
+  base=`echo "$source" | sed -e 's|^.*/||' -e "s/\.[-_$alnum]*$//"`
   tmpdepfile=$base.d
 
   # For projects that build the same source file twice into different object
@@ -436,7 +442,7 @@ hp2)
     test -f "$tmpdepfile" && break
   done
   if test -f "$tmpdepfile"; then
-    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
     # Add 'dependent.h:' lines.
     sed -ne '2,${
               s/^ *//
@@ -498,8 +504,8 @@ tru64)
      test -f "$tmpdepfile" && break
    done
    if test -f "$tmpdepfile"; then
-      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> 
"$depfile"
+      sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" > "$depfile"
+      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" >> 
"$depfile"
    else
       echo "#dummy" > "$depfile"
    fi
-- 
1.8.0.rc2.11.gd25c58c




reply via email to

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