This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not.
[metaconfig.git] / U / modified / Tr.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: Tr.U,v 3.0.1.2 1994/10/29 18:00:54 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic Licence,
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 3.0.
10?RCS:
11?RCS: $Log: Tr.U,v $
12?RCS: Revision 3.0.1.2 1994/10/29 18:00:54 ram
13?RCS: patch43: forgot to quote $@ to protect against "evil" characters
14?RCS:
15?RCS: Revision 3.0.1.1 1994/10/29 15:58:35 ram
16?RCS: patch36: created
17?RCS:
18?X:
19?X: This unit produces a bit of shell code that must be dotted in in order
20?X: to do a character translation. It catches translations to uppercase or
21?X: to lowercase, and then invokes the real tr to perform the job.
22?X:
23?X: This unit is necessary on HP machines (HP strikes again!) with non-ascii
24?X: ROMAN8-charset, where normal letters are not arranged in a row, so a-z
25?X: covers not the whole alphabet but lots of special chars. This was reported
26?X: by Andreas Sahlbach <a.sahlbach@tu-bs.de>.
27?X:
28?X: Units performing a tr '[A-Z]' '[a-z]' or the other way round should include
29?X: us in their dependency and use ./tr instead.
30?X:
31?MAKE:Tr: startsh tr eunicefix
32?MAKE: -pick add $@ %<
33?F:./tr
34?T:up low
35: see whether [:lower:] and [:upper:] are supported character classes
36echo " "
37case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
38ABYZ)
39 echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
40 up='[:upper:]'
41 low='[:lower:]'
42 ;;
3ffa43af
MB
43*) # There is a discontinuity in EBCDIC between 'R' and 'S'
44 # (0xd9 and 0xe2), therefore that is a nice testing point.
45 if test "X$up" = X -o "X$low" = X; then
46 case "`echo RS | $tr '[R-S]' '[r-s]' 2>/dev/null`" in
47 rs) up='[A-Z]'
48 low='[a-z]'
959f3c4c
JH
49 ;;
50 esac
3ffa43af 51 fi
959f3c4c 52 if test "X$up" = X -o "X$low" = X; then
3ffa43af
MB
53 case "`echo RS | $tr R-S r-s 2>/dev/null`" in
54 rs) up='A-Z'
959f3c4c
JH
55 low='a-z'
56 ;;
57 esac
3ffa43af 58 fi
959f3c4c 59 if test "X$up" = X -o "X$low" = X; then
3ffa43af
MB
60 case "`echo RS | od -x 2>/dev/null`" in
61 *D9E2*|*d9e2*)
959f3c4c
JH
62 echo "Hey, this might be EBCDIC." >&4
63 if test "X$up" = X -o "X$low" = X; then
3ffa43af
MB
64 case "`echo RS | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
65 rs) up='[A-IJ-RS-Z]'
66 low='[a-ij-rs-z]'
959f3c4c
JH
67 ;;
68 esac
69 fi
70 if test "X$up" = X -o "X$low" = X; then
3ffa43af
MB
71 case "`echo RS | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
72 rs) up='A-IJ-RS-Z'
73 low='a-ij-rs-z'
959f3c4c
JH
74 ;;
75 esac
76 fi
77 ;;
78 esac
79 fi
80esac
3ffa43af
MB
81case "`echo RS | $tr \"$up\" \"$low\" 2>/dev/null`" in
82rs)
959f3c4c
JH
83 echo "Using $up and $low to convert case." >&4
84 ;;
85*)
86 echo "I don't know how to translate letters from upper to lower case." >&4
87 echo "Your tr is not acting any way I know of." >&4
88 exit 1
89 ;;
90esac
91: set up the translation script tr, must be called with ./tr of course
92cat >tr <<EOSC
93$startsh
94case "\$1\$2" in
95'[A-Z][a-z]') exec $tr '$up' '$low';;
96'[a-z][A-Z]') exec $tr '$low' '$up';;
97esac
98exec $tr "\$@"
99EOSC
100chmod +x tr
101$eunicefix tr
102