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
This commit is contained in:
parent
95f55a632e
commit
f9fe4d605f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146322
@ -29,4 +29,10 @@ CLEANFILES+= nawk.1
|
||||
nawk.1: awk.1
|
||||
cat ${.ALLSRC} > ${.TARGET}
|
||||
|
||||
.for f in b.c main.c run.c
|
||||
${f}: ${AWKSRC}/${f} ${.CURDIR}/${f}.diff
|
||||
patch -s -b .orig -o ${.TARGET} < ${.CURDIR}/${f}.diff ${AWKSRC}/${f}
|
||||
CLEANFILES+= ${f}
|
||||
.endfor
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
53
usr.bin/awk/b.c.diff
Normal file
53
usr.bin/awk/b.c.diff
Normal file
@ -0,0 +1,53 @@
|
||||
$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;
|
26
usr.bin/awk/main.c.diff
Normal file
26
usr.bin/awk/main.c.diff
Normal file
@ -0,0 +1,26 @@
|
||||
$FreeBSD$
|
||||
|
||||
Index: main.c
|
||||
===================================================================
|
||||
RCS file: /home/ncvs/src/contrib/one-true-awk/main.c,v
|
||||
retrieving revision 1.1.1.10
|
||||
diff -u -p -r1.1.1.10 main.c
|
||||
--- main.c 16 May 2005 19:11:31 -0000 1.1.1.10
|
||||
+++ main.c 17 May 2005 14:41:20 -0000
|
||||
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
THIS SOFTWARE.
|
||||
****************************************************************/
|
||||
|
||||
-const char *version = "version 20050424";
|
||||
+const char *version = "version 20050424 (FreeBSD)";
|
||||
|
||||
#define DEBUG
|
||||
#include <stdio.h>
|
||||
@@ -58,6 +58,7 @@ int main(int argc, char *argv[])
|
||||
const char *fs = NULL;
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
+ setlocale(LC_COLLATE, "");
|
||||
setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
|
||||
cmdname = argv[0];
|
||||
if (argc == 1) {
|
18
usr.bin/awk/run.c.diff
Normal file
18
usr.bin/awk/run.c.diff
Normal file
@ -0,0 +1,18 @@
|
||||
$FreeBSD$
|
||||
|
||||
Index: run.c
|
||||
===================================================================
|
||||
RCS file: /home/ncvs/src/contrib/one-true-awk/run.c,v
|
||||
retrieving revision 1.1.1.8
|
||||
diff -u -p -r1.1.1.8 run.c
|
||||
--- run.c 16 May 2005 19:11:35 -0000 1.1.1.8
|
||||
+++ run.c 16 May 2005 19:12:47 -0000
|
||||
@@ -651,7 +651,7 @@ Cell *relop(Node **a, int n) /* a[0 < a[
|
||||
j = x->fval - y->fval;
|
||||
i = j<0? -1: (j>0? 1: 0);
|
||||
} else {
|
||||
- i = strcmp(getsval(x), getsval(y));
|
||||
+ i = strcoll(getsval(x), getsval(y));
|
||||
}
|
||||
tempfree(x);
|
||||
tempfree(y);
|
Loading…
Reference in New Issue
Block a user