summaryrefslogtreecommitdiff
path: root/shells/tcsh/patches/patch-ac
blob: f4bf963aab2efd1ffca1b8721646e9384878e766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$NetBSD: patch-ac,v 1.3 1998/08/07 11:13:56 agc Exp $

--- glob.c.orig	Fri Nov 12 19:40:56 1993
+++ glob.c	Tue Aug  4 10:15:40 1998
@@ -139,6 +139,27 @@
 #define	M_SET		META('[')
 #define	ismeta(c)	(((c)&M_META) != 0)
 
+int collate_range_cmp (c1, c2)
+	int c1, c2;
+{
+#if defined(NLS) && defined(LC_COLLATE)
+	static char s1[2], s2[2];
+	int ret;
+#endif
+
+	c1 &= 0xFF;
+	c2 &= 0xFF;
+#if defined(NLS) && defined(LC_COLLATE)
+	if (c1 == c2)
+		return (0);
+	s1[0] = c1;
+	s2[0] = c2;
+	if ((ret = strcoll(s1, s2)) != 0)
+		return (ret);
+#endif
+	return (c1 - c2);
+}
+
 /*
  * Need to dodge two kernel bugs:
  * opendir("") != opendir(".")
@@ -646,7 +667,9 @@
 		++pat;
 	    while (((c = *pat++) & M_MASK) != M_END) {
 		if ((*pat & M_MASK) == M_RNG) {
-		    if (c <= k && k <= pat[1])
+		    if (   collate_range_cmp(CHAR(c), CHAR(k)) <= 0
+			&& collate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0
+		       )
 			ok = 1;
 		    pat += 2;
 		}