1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-01 22:05:08 +00:00
freebsd-ports/lang/nawk/files/patch-ba
1999-11-29 10:14:16 +00:00

80 lines
1.6 KiB
Plaintext

--- b.c.orig Mon May 10 07:26:44 1999
+++ b.c Mon Nov 29 02:10:52 1999
@@ -27,6 +27,9 @@
#define DEBUG
#include <ctype.h>
+#ifdef __FreeBSD__
+#include <limits.h>
+#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -75,6 +78,24 @@
fa *fatab[NFA];
int nfatab = 0; /* entries in fatab */
+#ifdef __FreeBSD__
+static int
+collate_range_cmp(a, b)
+int a, b;
+{
+ int r;
+ static char s[2][2];
+
+ if ((unsigned char)a == (unsigned char)b)
+ return 0;
+ s[0][0] = a;
+ s[1][0] = b;
+ if ((r = strcoll(s[0], s[1])) == 0)
+ r = (unsigned char)a - (unsigned char)b;
+ return r;
+}
+#endif
+
fa *makedfa(char *s, int anchor) /* returns dfa for reg expr s */
{
int i, use, nuse;
@@ -285,6 +306,9 @@
char *cclenter(char *p) /* add a character class */
{
int i, c, c2;
+#ifdef __FreeBSD__
+ int c3;
+#endif
char *op, *bp;
static char *buf = 0;
static int bufsz = 100;
@@ -302,6 +326,23 @@
c2 = *p++;
if (c2 == '\\')
c2 = quoted(&p);
+#ifdef __FreeBSD__
+ if (collate_range_cmp(c, c2) > 0) {
+ bp--;
+ i--;
+ continue;
+ }
+ for (c3 = 0; c3 < (1 << CHAR_BIT) - 1; c3++) {
+ if (collate_range_cmp(c, c3) <= 0 &&
+ collate_range_cmp(c3, c2) <= 0) {
+ if (!adjbuf(&buf, &bufsz, bp-buf+2, 100, &bp, 0))
+ FATAL("out of space for character class [%.10s...] 2", p);
+ *bp++ = c3 + 1;
+ i++;
+ }
+ }
+#else
+ if (c > c2) { /* empty; ignore */
if (c > c2) { /* empty; ignore */
bp--;
i--;
@@ -313,6 +354,7 @@
*bp++ = ++c;
i++;
}
+#endif
continue;
}
}