[Top][All Lists]
[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
- [RFC 00/20] Refactoring and modernizations in the depcomp script, Stefano Lattarini, 2012/10/18
- [RFC 01/20] depcomp: be more idiomatic in checking for zero exit statuses, Stefano Lattarini, 2012/10/18
- [RFC 02/20] depcomp: remove useless quoting in variable definitions, Stefano Lattarini, 2012/10/18
- [RFC 03/20] depcomp: use "rmdir", not "rm -rf", to remove the empty lock directory, Stefano Lattarini, 2012/10/18
- [RFC 04/20] depcomp: correctly propagate exit status in exit trap, Stefano Lattarini, 2012/10/18
- [RFC 05/20] depcomp: safer quoting in variable expansion, Stefano Lattarini, 2012/10/18
- [RFC 06/20] depcomp: cosmetic fixlets to a comment, Stefano Lattarini, 2012/10/18
- [RFC 07/20] depcomp: don't rely on character ranges working as in C locale,
Stefano Lattarini <=
- [RFC 08/20] depcomp: reduce code duplication, Stefano Lattarini, 2012/10/18
- [RFC 09/20] depcomp: avoid an extra fork when possible, Stefano Lattarini, 2012/10/18
- [RFC 10/20] depcomp: less duplication between AIX and Tru64 modes, Stefano Lattarini, 2012/10/18
- [RFC 11/20] depcomp: make some code more self-documenting, Stefano Lattarini, 2012/10/18
- [RFC 12/20] depcomp: shell code style changes, Stefano Lattarini, 2012/10/18
- [RFC 15/20] depcomp: remove an unused variable, Stefano Lattarini, 2012/10/18
- [RFC 14/20] depcomp: rewrite a sed invocation for less quoting, Stefano Lattarini, 2012/10/18
- [RFC 13/20] depcomp: whitespace fixes, Stefano Lattarini, 2012/10/18
- [RFC 17/20] depcomp: improve comments about tcc support, Stefano Lattarini, 2012/10/18
- [RFC 18/20] tests: fix spurious failures with tcc, Stefano Lattarini, 2012/10/18