Apply patches directly to sources. Their effect is as follows:

- Make one-true-awk respect locale's collating order in [a-z]
  bracket expressions, until a more complete fix (like handing
  BREs) is ready.

- Don't require a space between -[fv] and its argument.
This commit is contained in:
Ruslan Ermilov 2010-01-10 08:02:07 +00:00
parent 97507d7183
commit d98dd8e5f9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201989
7 changed files with 50 additions and 151 deletions

View file

@ -24,6 +24,9 @@ THIS SOFTWARE.
/* lasciate ogne speranza, voi ch'intrate. */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define DEBUG
#include <ctype.h>
@ -285,9 +288,21 @@ int quoted(char **pp) /* pick up next thing after a \\ */
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;
@ -306,15 +321,18 @@ char *cclenter(const char *argp) /* add a character class */
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, "cclenter1"))
FATAL("out of space for character class [%.10s...] 2", p);
*bp++ = ++c;
*bp++ = j;
i++;
}
continue;

View file

@ -22,7 +22,10 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
const char *version = "version 20091126";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
const char *version = "version 20091126 (FreeBSD)";
#define DEBUG
#include <stdio.h>
@ -58,6 +61,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) {
@ -86,13 +90,18 @@ int main(int argc, char *argv[])
safe = 1;
break;
case 'f': /* next argument is program filename */
argc--;
argv++;
if (argc <= 1)
FATAL("no program filename");
if (npfile >= MAX_PFILE - 1)
FATAL("too many -f options");
pfile[npfile++] = argv[1];
if (argv[1][2] != 0) { /* arg is -fsomething */
if (npfile >= MAX_PFILE - 1)
FATAL("too many -f options");
pfile[npfile++] = &argv[1][2];
} else { /* arg is -f something */
argc--; argv++;
if (argc <= 1)
FATAL("no program filename");
if (npfile >= MAX_PFILE - 1)
FATAL("too many -f options");
pfile[npfile++] = argv[1];
}
break;
case 'F': /* set field separator */
if (argv[1][2] != 0) { /* arg is -Fsomething */
@ -111,8 +120,14 @@ int main(int argc, char *argv[])
WARNING("field separator FS is empty");
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1]))
setclvar(argv[1]);
if (argv[1][2] != 0) { /* arg is -vsomething */
if (argv[1][2] != 0)
setclvar(&argv[1][2]);
} else { /* arg is -v something */
argc--; argv++;
if (argc > 1 && isclvar(argv[1]))
setclvar(argv[1]);
}
break;
case 'd':
dbg = atoi(&argv[1][2]);

View file

@ -22,6 +22,9 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define DEBUG
#include <stdio.h>
#include <ctype.h>
@ -653,7 +656,7 @@ Cell *relop(Node **a, int n) /* a[0 < a[1], etc. */
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);

View file

@ -27,10 +27,4 @@ proctab.c: maketab
build-tools: maketab
maketab: ytab.h ${AWKSRC}/maketab.c
.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>

View file

@ -1,50 +0,0 @@
$FreeBSD$
Index: b.c
===================================================================
--- b.c (revision 201951)
+++ b.c (working copy)
@@ -285,9 +285,21 @@ int quoted(char **pp) /* pick up next thing after
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;
@@ -306,15 +318,18 @@ char *cclenter(const char *argp) /* add a characte
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, "cclenter1"))
FATAL("out of space for character class [%.10s...] 2", p);
- *bp++ = ++c;
+ *bp++ = j;
i++;
}
continue;

View file

@ -1,66 +0,0 @@
$FreeBSD$
Index: main.c
===================================================================
--- main.c (revision 201951)
+++ main.c (working copy)
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PE
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20091126";
+const char *version = "version 20091126 (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) {
@@ -86,13 +87,18 @@ int main(int argc, char *argv[])
safe = 1;
break;
case 'f': /* next argument is program filename */
- argc--;
- argv++;
- if (argc <= 1)
- FATAL("no program filename");
- if (npfile >= MAX_PFILE - 1)
- FATAL("too many -f options");
- pfile[npfile++] = argv[1];
+ if (argv[1][2] != 0) { /* arg is -fsomething */
+ if (npfile >= MAX_PFILE - 1)
+ FATAL("too many -f options");
+ pfile[npfile++] = &argv[1][2];
+ } else { /* arg is -f something */
+ argc--; argv++;
+ if (argc <= 1)
+ FATAL("no program filename");
+ if (npfile >= MAX_PFILE - 1)
+ FATAL("too many -f options");
+ pfile[npfile++] = argv[1];
+ }
break;
case 'F': /* set field separator */
if (argv[1][2] != 0) { /* arg is -Fsomething */
@@ -111,8 +117,14 @@ int main(int argc, char *argv[])
WARNING("field separator FS is empty");
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
- if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1]))
- setclvar(argv[1]);
+ if (argv[1][2] != 0) { /* arg is -vsomething */
+ if (argv[1][2] != 0)
+ setclvar(&argv[1][2]);
+ } else { /* arg is -v something */
+ argc--; argv++;
+ if (argc > 1 && isclvar(argv[1]))
+ setclvar(argv[1]);
+ }
break;
case 'd':
dbg = atoi(&argv[1][2]);

View file

@ -1,15 +0,0 @@
$FreeBSD$
Index: run.c
===================================================================
--- run.c (revision 201951)
+++ run.c (working copy)
@@ -653,7 +653,7 @@ Cell *relop(Node **a, int n) /* a[0 < a[1], etc. *
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);