1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-28 11:57:28 +00:00
freebsd/usr.bin/awk/b.c.diff
Ruslan Ermilov f9fe4d605f Add temporary patches to make one-true-awk respect locale's collating order
in [a-z] bracket expressions, until a more complete fix (like handing BREs)
is ready.

Prodded by:	ache
OK'ed by:	tjr
2005-05-17 14:54:33 +00:00

54 lines
1.3 KiB
Diff

$FreeBSD$
Index: b.c
===================================================================
RCS file: /home/ncvs/src/contrib/one-true-awk/b.c,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 b.c
--- b.c 16 May 2005 19:11:31 -0000 1.1.1.8
+++ b.c 16 May 2005 19:12:40 -0000
@@ -282,9 +282,21 @@ int quoted(char **pp) /* pick up next th
return c;
}
+static int collate_range_cmp(int a, int b)
+{
+ static char s[2][2];
+
+ if ((uschar)a == (uschar)b)
+ return 0;
+ s[0][0] = a;
+ s[1][0] = b;
+ return (strcoll(s[0], s[1]));
+}
+
char *cclenter(const char *argp) /* add a character class */
{
int i, c, c2;
+ int j;
uschar *p = (uschar *) argp;
uschar *op, *bp;
static uschar *buf = 0;
@@ -303,15 +315,18 @@ char *cclenter(const char *argp) /* add
c2 = *p++;
if (c2 == '\\')
c2 = quoted((char **) &p);
- if (c > c2) { /* empty; ignore */
+ if (collate_range_cmp(c, c2) > 0) {
bp--;
i--;
continue;
}
- while (c < c2) {
+ for (j = 0; j < NCHARS; j++) {
+ if ((collate_range_cmp(c, j) > 0) ||
+ collate_range_cmp(j, c2) > 0)
+ continue;
if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
FATAL("out of space for character class [%.10s...] 2", p);
- *bp++ = ++c;
+ *bp++ = j;
i++;
}
continue;