[Midnightbsd-cvs] src [10566] trunk/lib/libc/regex: tag
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Jun 7 21:11:32 EDT 2018
Revision: 10566
http://svnweb.midnightbsd.org/src/?rev=10566
Author: laffer1
Date: 2018-06-07 21:11:31 -0400 (Thu, 07 Jun 2018)
Log Message:
-----------
tag
Modified Paths:
--------------
trunk/lib/libc/regex/Makefile.inc
trunk/lib/libc/regex/Symbol.map
trunk/lib/libc/regex/cname.h
trunk/lib/libc/regex/engine.c
trunk/lib/libc/regex/grot/Makefile
trunk/lib/libc/regex/grot/debug.c
trunk/lib/libc/regex/grot/main.c
trunk/lib/libc/regex/grot/mkh
trunk/lib/libc/regex/grot/split.c
trunk/lib/libc/regex/grot/tests
trunk/lib/libc/regex/re_format.7
trunk/lib/libc/regex/regcomp.c
trunk/lib/libc/regex/regerror.c
trunk/lib/libc/regex/regex.3
trunk/lib/libc/regex/regex2.h
trunk/lib/libc/regex/regexec.c
trunk/lib/libc/regex/regfree.c
trunk/lib/libc/regex/utils.h
Property Changed:
----------------
trunk/lib/libc/regex/COPYRIGHT
trunk/lib/libc/regex/Makefile.inc
trunk/lib/libc/regex/Symbol.map
trunk/lib/libc/regex/WHATSNEW
trunk/lib/libc/regex/grot/mkh
trunk/lib/libc/regex/grot/tests
trunk/lib/libc/regex/re_format.7
trunk/lib/libc/regex/regex.3
Index: trunk/lib/libc/regex/COPYRIGHT
===================================================================
--- trunk/lib/libc/regex/COPYRIGHT 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/COPYRIGHT 2018-06-08 01:11:31 UTC (rev 10566)
Property changes on: trunk/lib/libc/regex/COPYRIGHT
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/Makefile.inc
===================================================================
--- trunk/lib/libc/regex/Makefile.inc 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/Makefile.inc 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,5 +1,6 @@
# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $FreeBSD$
+# $FreeBSD: stable/10/lib/libc/regex/Makefile.inc 156613 2006-03-13 01:15:01Z deischen $
+# $MidnightBSD$
# regex sources
.PATH: ${.CURDIR}/regex
Property changes on: trunk/lib/libc/regex/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/Symbol.map
===================================================================
--- trunk/lib/libc/regex/Symbol.map 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/Symbol.map 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,5 +1,5 @@
-/*
- * $FreeBSD$
+/* $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/regex/Symbol.map 169092 2007-04-29 14:05:22Z deischen $
*/
FBSD_1.0 {
Property changes on: trunk/lib/libc/regex/Symbol.map
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Index: trunk/lib/libc/regex/WHATSNEW
===================================================================
--- trunk/lib/libc/regex/WHATSNEW 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/WHATSNEW 2018-06-08 01:11:31 UTC (rev 10566)
Property changes on: trunk/lib/libc/regex/WHATSNEW
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/cname.h
===================================================================
--- trunk/lib/libc/regex/cname.h 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/cname.h 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -31,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)cname.h 8.3 (Berkeley) 3/20/94
- * $FreeBSD$
+ * $FreeBSD: stable/10/lib/libc/regex/cname.h 165903 2007-01-09 00:28:16Z imp $
*/
/* character-name table */
Modified: trunk/lib/libc/regex/engine.c
===================================================================
--- trunk/lib/libc/regex/engine.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/engine.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -34,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/engine.c 302168 2016-06-24 02:24:34Z pfg $");
/*
* The matching engine and friends. This file is #included by regexec.c
@@ -154,7 +155,7 @@
int eflags)
{
const char *endp;
- int i;
+ size_t i;
struct match mv;
struct match *m = &mv;
const char *dp;
@@ -606,9 +607,9 @@
return(NULL);
break;
case OBOL:
- if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags®_NEWLINE)) )
+ if ((sp == m->beginp && !(m->eflags®_NOTBOL)) ||
+ (sp > m->offp && sp < m->endp &&
+ *(sp-1) == '\n' && (m->g->cflags®_NEWLINE)))
{ /* yes */ }
else
return(NULL);
@@ -622,12 +623,9 @@
return(NULL);
break;
case OBOW:
- if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) ||
- (sp < m->endp && *(sp-1) == '\n' &&
- (m->g->cflags®_NEWLINE)) ||
- (sp > m->beginp &&
- !ISWORD(*(sp-1))) ) &&
- (sp < m->endp && ISWORD(*sp)) )
+ if (sp < m->endp && ISWORD(*sp) &&
+ ((sp == m->beginp && !(m->eflags®_NOTBOL)) ||
+ (sp > m->offp && !ISWORD(*(sp-1)))))
{ /* yes */ }
else
return(NULL);
@@ -686,19 +684,16 @@
while (m->g->strip[ss] != SOP(O_BACK, i))
ss++;
return(backref(m, sp+len, stop, ss+1, stopst, lev, rec));
- break;
case OQUEST_: /* to null or not */
dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
if (dp != NULL)
return(dp); /* not */
return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec));
- break;
case OPLUS_:
assert(m->lastpos != NULL);
assert(lev+1 <= m->g->nplus);
m->lastpos[lev+1] = sp;
return(backref(m, sp, stop, ss+1, stopst, lev+1, rec));
- break;
case O_PLUS:
if (sp == m->lastpos[lev]) /* last pass matched null */
return(backref(m, sp, stop, ss+1, stopst, lev-1, rec));
@@ -709,7 +704,6 @@
return(backref(m, sp, stop, ss+1, stopst, lev-1, rec));
else
return(dp);
- break;
case OCH_: /* find the right one, if any */
ssub = ss + 1;
esub = ss + OPND(s) - 1;
@@ -730,6 +724,7 @@
else
assert(OP(m->g->strip[esub]) == O_CH);
}
+ /* NOTREACHED */
break;
case OLPAREN: /* must undo assignment if rest fails */
i = OPND(s);
@@ -741,7 +736,6 @@
return(dp);
m->pmatch[i].rm_so = offsave;
return(NULL);
- break;
case ORPAREN: /* must undo assignment if rest fails */
i = OPND(s);
assert(0 < i && i <= m->g->nsub);
@@ -752,7 +746,6 @@
return(dp);
m->pmatch[i].rm_eo = offsave;
return(NULL);
- break;
default: /* uh oh */
assert(nope);
break;
@@ -794,7 +787,7 @@
ASSIGN(fresh, st);
SP("start", st, *p);
coldp = NULL;
- if (start == m->beginp)
+ if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL)))
c = OUT;
else {
/*
@@ -899,7 +892,7 @@
SP("sstart", st, *p);
st = step(m->g, startst, stopst, st, NOTHING, st);
matchp = NULL;
- if (start == m->beginp)
+ if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL)))
c = OUT;
else {
/*
@@ -1113,7 +1106,7 @@
FILE *d)
{
struct re_guts *g = m->g;
- int i;
+ sopno i;
int first = 1;
if (!(m->eflags®_TRACE))
Modified: trunk/lib/libc/regex/grot/Makefile
===================================================================
--- trunk/lib/libc/regex/grot/Makefile 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/grot/Makefile 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,4 +1,5 @@
-# $FreeBSD$
+# $MidnightBSD$
+# $FreeBSD: stable/10/lib/libc/regex/grot/Makefile 313221 2017-02-04 16:36:07Z ngie $
# You probably want to take -DREDEBUG out of CFLAGS, and put something like
# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
# internal assertion checking). Take -Dconst= out for an ANSI compiler.
@@ -5,10 +6,10 @@
# Do not take -DPOSIX_MISTAKE out. REGCFLAGS isn't important to you (it's
# for my use in some special contexts).
-PATHS= ${.CURDIR}/.. ${.CURDIR}/../../locale ${.CURDIR}/../../../../include
+PATHS= ${.CURDIR:H} ${.CURDIR:H:H}/locale ${SRCTOP}/include
.PATH: ${PATHS}
-CFLAGS+= -DPOSIX_MISTAKE -DREDEBUG $(REGCFLAGS)
+CFLAGS+= -static -DPOSIX_MISTAKE -DREDEBUG $(REGCFLAGS)
.for incpath in ${PATHS}
CFLAGS+= -I${incpath}
.endfor
@@ -62,7 +63,8 @@
regerror.o: regerror.ih
regerror.o: utils.h
debug.o: debug.ih
-main.o: main.ih
+main.o: debug.ih main.ih split.ih
+split.o: split.ih
r: re tests
./re <tests
Modified: trunk/lib/libc/regex/grot/debug.c
===================================================================
--- trunk/lib/libc/regex/grot/debug.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/grot/debug.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/grot/debug.c 292144 2015-12-13 03:51:49Z ngie $");
#include <stdio.h>
#include <string.h>
@@ -186,7 +187,7 @@
fprintf(d, ">");
break;
default:
- fprintf(d, "!%d(%d)!", OP(*s), opnd);
+ fprintf(d, "!%ld(%ld)!", OP(*s), (long)opnd);
break;
}
if (!done)
Modified: trunk/lib/libc/regex/grot/main.c
===================================================================
--- trunk/lib/libc/regex/grot/main.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/grot/main.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,13 +1,18 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/grot/main.c 292170 2015-12-13 21:15:03Z ngie $");
+#include <sys/types.h>
+#include <assert.h>
+#include <regex.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
-#include <regex.h>
-#include <assert.h>
+#include <unistd.h>
+#include "debug.ih"
#include "main.ih"
+#include "split.ih"
char *progname;
int debug = 0;
@@ -20,15 +25,11 @@
regoff_t endoff = 0;
-extern int split();
-extern void regprint();
-
/*
- main - do the simple case, hand off to regress() for regression
*/
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main(int argc, char **argv)
{
regex_t re;
# define NS 10
@@ -80,11 +81,11 @@
err = regcomp(&re, argv[optind++], copts);
if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
+ fprintf(stderr, "error %s, %zu/%zu `%s'\n",
+ eprint(err), len, sizeof(erbuf), erbuf);
exit(status);
}
- regprint(&re, stdout);
+ regprint(&re, stdout);
if (optind >= argc) {
regfree(&re);
@@ -91,7 +92,7 @@
exit(status);
}
- if (eopts®_STARTEND) {
+ if ((eopts & REG_STARTEND) != 0) {
subs[0].rm_so = startoff;
subs[0].rm_eo = strlen(argv[optind]) - endoff;
}
@@ -98,25 +99,25 @@
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "error %s, %d/%d `%s'\n",
- eprint(err), len, sizeof(erbuf), erbuf);
+ fprintf(stderr, "error %s, %zu/%zu `%s'\n",
+ eprint(err), len, sizeof(erbuf), erbuf);
exit(status);
}
- if (!(copts®_NOSUB)) {
+ if ((copts & REG_NOSUB) == 0) {
len = (int)(subs[0].rm_eo - subs[0].rm_so);
if (subs[0].rm_so != -1) {
if (len != 0)
- printf("match `%.*s'\n", len,
- argv[optind] + subs[0].rm_so);
+ printf("match `%.*s'\n", (int)len,
+ argv[optind] + subs[0].rm_so);
else
printf("match `'@%.1s\n",
- argv[optind] + subs[0].rm_so);
+ argv[optind] + subs[0].rm_so);
}
for (i = 1; i < NS; i++)
if (subs[i].rm_so != -1)
printf("(%d) `%.*s'\n", i,
- (int)(subs[i].rm_eo - subs[i].rm_so),
- argv[optind] + subs[i].rm_so);
+ (int)(subs[i].rm_eo - subs[i].rm_so),
+ argv[optind] + subs[i].rm_so);
}
exit(status);
}
@@ -126,8 +127,7 @@
== void regress(FILE *in);
*/
void
-regress(in)
-FILE *in;
+regress(FILE *in)
{
char inbuf[1000];
# define MAXF 10
@@ -174,13 +174,13 @@
}
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT);
if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
- ne != strlen(badpat)+1) {
+ ne != strlen(badpat)+1) {
fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
erbuf, SHORT-1, badpat);
status = 1;
}
ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
- if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
+ if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname) + 1) {
fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
erbuf, bpname);
status = 1;
@@ -191,7 +191,7 @@
fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
erbuf, (long)REG_BADPAT);
status = 1;
- } else if (ne != strlen(erbuf)+1) {
+ } else if (ne != strlen(erbuf) + 1) {
fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
erbuf, (long)REG_BADPAT);
status = 1;
@@ -201,15 +201,10 @@
/*
- try - try it, and report on problems
== void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
+ - opts: may not match f1
*/
void
-try(f0, f1, f2, f3, f4, opts)
-char *f0;
-char *f1;
-char *f2;
-char *f3;
-char *f4;
-int opts; /* may not match f1 */
+try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts)
{
regex_t re;
# define NSUBS 10
@@ -216,13 +211,11 @@
regmatch_t subs[NSUBS];
# define NSHOULD 15
char *should[NSHOULD];
- int nshould;
char erbuf[100];
- int err;
- int len;
+ size_t len;
+ int err, i, nshould;
+ char *grump;
char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
- int i;
- char *grump;
char f0copy[1000];
char f2copy[1000];
@@ -233,9 +226,8 @@
if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
/* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
+ fprintf(stderr, "%d: %s error %s, %zu/%zu `%s'\n",
+ line, type, eprint(err), len, sizeof(erbuf), erbuf);
status = 1;
} else if (err == 0 && opt('C', f1)) {
/* unexpected success */
@@ -264,9 +256,8 @@
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
/* unexpected error or wrong error */
len = regerror(err, &re, erbuf, sizeof(erbuf));
- fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
- line, type, eprint(err), len,
- sizeof(erbuf), erbuf);
+ fprintf(stderr, "%d: %s exec error %s, %zu/%zu `%s'\n",
+ line, type, eprint(err), len, sizeof(erbuf), erbuf);
status = 1;
} else if (err != 0) {
/* nothing more to check */
@@ -273,7 +264,7 @@
} else if (f3 == NULL) {
/* unexpected success */
fprintf(stderr, "%d: %s exec should have failed\n",
- line, type);
+ line, type);
status = 1;
err = 1; /* just on principle */
} else if (opts®_NOSUB) {
@@ -300,7 +291,7 @@
grump = check(f2, subs[i], should[i]);
if (grump != NULL) {
fprintf(stderr, "%d: %s $%d %s\n", line,
- type, i, grump);
+ type, i, grump);
status = 1;
err = 1;
}
@@ -311,12 +302,11 @@
/*
- options - pick options out of a regression-test string
+ - type: 'c' - compile, 'e' - exec
== int options(int type, char *s);
*/
int
-options(type, s)
-int type; /* 'c' compile, 'e' exec */
-char *s;
+options(int type, char *s)
{
char *p;
int o = (type == 'c') ? copts : eopts;
@@ -371,9 +361,7 @@
== int opt(int c, char *s);
*/
int /* predicate */
-opt(c, s)
-int c;
-char *s;
+opt(int c, char *s)
{
return(strchr(s, c) != NULL);
}
@@ -383,8 +371,7 @@
== void fixstr(char *p);
*/
void
-fixstr(p)
-char *p;
+fixstr(char *p)
{
if (p == NULL)
return;
@@ -405,10 +392,7 @@
== char *check(char *str, regmatch_t sub, char *should);
*/
char * /* NULL or complaint */
-check(str, sub, should)
-char *str;
-regmatch_t sub;
-char *should;
+check(char *str, regmatch_t sub, char *should)
{
int len;
int shlen;
@@ -442,7 +426,7 @@
/* check for in range */
if (sub.rm_eo > strlen(str)) {
sprintf(grump, "start %ld end %ld, past end of string",
- (long)sub.rm_so, (long)sub.rm_eo);
+ (long)sub.rm_so, (long)sub.rm_eo);
return(grump);
}
@@ -482,8 +466,7 @@
== static char *eprint(int err);
*/
static char *
-eprint(err)
-int err;
+eprint(int err)
{
static char epbuf[100];
size_t len;
@@ -498,8 +481,7 @@
== static int efind(char *name);
*/
static int
-efind(name)
-char *name;
+efind(char *name)
{
static char efbuf[100];
size_t n;
Modified: trunk/lib/libc/regex/grot/mkh
===================================================================
--- trunk/lib/libc/regex/grot/mkh 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/grot/mkh 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,6 +1,8 @@
#! /bin/sh
# mkh - pull headers out of C source
-# $FreeBSD$
+# $FreeBSD: stable/10/lib/libc/regex/grot/mkh 92971 2002-03-22 19:45:43Z obrien $
+# $MidnightBSD$
+
PATH=/bin:/usr/bin ; export PATH
# egrep pattern to pick out marked lines
Property changes on: trunk/lib/libc/regex/grot/mkh
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/grot/split.c
===================================================================
--- trunk/lib/libc/regex/grot/split.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/grot/split.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,19 +1,21 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/grot/split.c 292170 2015-12-13 21:15:03Z ngie $");
#include <stdio.h>
#include <string.h>
+#include "split.ih"
+
/*
- split - divide a string into fields, like awk split()
- = int split(char *string, char *fields[], int nfields, char *sep);
+ == int split(char *string, char *fields[], int nfields, char *sep);
+ - fields: list is not NULL-terminated
+ - nfields: number of entries available in fields[]
+ - sep: "" white, "c" single char, "ab" [ab]+
*/
int /* number of fields, including overflow */
-split(string, fields, nfields, sep)
-char *string;
-char *fields[]; /* list is not NULL-terminated */
-int nfields; /* number of entries available in fields[] */
-char *sep; /* "" white, "c" single char, "ab" [ab]+ */
+split(char *string, char *fields[], int nfields, char *sep)
{
char *p = string;
char c; /* latest character */
@@ -151,9 +153,7 @@
* pgm str sep n splits str by sep n times
*/
int
-main(argc, argv)
-int argc;
-char *argv[];
+main(int argc, char *argv[])
{
char buf[512];
int n;
@@ -182,9 +182,8 @@
exit(0);
}
-dosplit(string, seps)
-char *string;
-char *seps;
+void
+dosplit(char *string, char *seps)
{
# define NF 5
char *fields[NF];
@@ -194,10 +193,8 @@
print(nf, NF, fields);
}
-print(nf, nfp, fields)
-int nf;
-int nfp;
-char *fields[];
+void
+print(int nf, int nfp, char *fields[])
{
int fn;
int bound;
@@ -277,7 +274,8 @@
NULL, NULL, 0, { NULL },
};
-regress()
+void
+regress(void)
{
char buf[512];
int n;
Modified: trunk/lib/libc/regex/grot/tests
===================================================================
--- trunk/lib/libc/regex/grot/tests 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/grot/tests 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,5 +1,7 @@
# regular expression test set
-# $FreeBSD$
+# $FreeBSD: stable/10/lib/libc/regex/grot/tests 197234 2009-09-15 21:15:29Z dds $
+# $MidnightBSD$
+#
# Lines are at least three fields, separated by one or more tabs. "" stands
# for an empty field. First field is an RE. Second field is flags. If
# C flag given, regcomp() is expected to fail, and the third field is the
Property changes on: trunk/lib/libc/regex/grot/tests
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/re_format.7
===================================================================
--- trunk/lib/libc/regex/re_format.7 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/re_format.7 2018-06-08 01:11:31 UTC (rev 10566)
@@ -34,9 +34,10 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/regex/re_format.7 269484 2014-08-03 18:39:11Z pfg $
+.\" $MidnightBSD$
.\"
-.Dd March 20, 1994
+.Dd June 30, 2014
.Dt RE_FORMAT 7
.Os
.Sh NAME
@@ -314,6 +315,13 @@
.St -p1003.2 ,
and should be used with
caution in software intended to be portable to other systems.
+The additional word delimiters
+.Ql \e<
+and
+.Ql \e>
+are provided to ease compatibility with traditional
+.Xr svr4 4
+systems but are not portable and should be avoided.
.Pp
In the event that an RE could match more than one substring of a given
string,
Property changes on: trunk/lib/libc/regex/re_format.7
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/regcomp.c
===================================================================
--- trunk/lib/libc/regex/regcomp.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/regcomp.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -42,7 +43,7 @@
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/regcomp.c 325394 2017-11-04 14:45:36Z pfg $");
#include <sys/types.h>
#include <stdio.h>
@@ -51,7 +52,6 @@
#include <limits.h>
#include <stdlib.h>
#include <regex.h>
-#include <runetype.h>
#include <wchar.h>
#include <wctype.h>
@@ -86,10 +86,10 @@
#endif
/* === regcomp.c === */
-static void p_ere(struct parse *p, wint_t stop);
+static void p_ere(struct parse *p, int stop);
static void p_ere_exp(struct parse *p);
static void p_str(struct parse *p);
-static void p_bre(struct parse *p, wint_t end1, wint_t end2);
+static void p_bre(struct parse *p, int end1, int end2);
static int p_simp_re(struct parse *p, int starordinary);
static int p_count(struct parse *p);
static void p_bracket(struct parse *p);
@@ -114,7 +114,7 @@
static void doemit(struct parse *p, sop op, size_t opnd);
static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos);
static void dofwd(struct parse *p, sopno pos, sop value);
-static void enlarge(struct parse *p, sopno size);
+static int enlarge(struct parse *p, sopno size);
static void stripsnug(struct parse *p, struct re_guts *g);
static void findmust(struct parse *p, struct re_guts *g);
static int altoffset(sop *scan, int offset);
@@ -192,6 +192,7 @@
struct parse *p = &pa;
int i;
size_t len;
+ size_t maxlen;
#ifdef REDEBUG
# define GOODFLAGS(f) (f)
#else
@@ -213,7 +214,23 @@
g = (struct re_guts *)malloc(sizeof(struct re_guts));
if (g == NULL)
return(REG_ESPACE);
+ /*
+ * Limit the pattern space to avoid a 32-bit overflow on buffer
+ * extension. Also avoid any signed overflow in case of conversion
+ * so make the real limit based on a 31-bit overflow.
+ *
+ * Likely not applicable on 64-bit systems but handle the case
+ * generically (who are we to stop people from using ~715MB+
+ * patterns?).
+ */
+ maxlen = ((size_t)-1 >> 1) / sizeof(sop) * 2 / 3;
+ if (len >= maxlen) {
+ free((char *)g);
+ return(REG_ESPACE);
+ }
p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
+ assert(p->ssize >= len);
+
p->strip = (sop *)malloc(p->ssize * sizeof(sop));
p->slen = 0;
if (p->strip == NULL) {
@@ -290,7 +307,7 @@
/*
- p_ere - ERE parser top level, concatenation and alternation
- == static void p_ere(struct parse *p, int stop);
+ == static void p_ere(struct parse *p, int_t stop);
*/
static void
p_ere(struct parse *p,
@@ -412,12 +429,24 @@
case '\\':
(void)REQUIRE(MORE(), REG_EESCAPE);
wc = WGETNEXT();
- ordinary(p, wc);
+ switch (wc) {
+ case '<':
+ EMIT(OBOW, 0);
+ break;
+ case '>':
+ EMIT(OEOW, 0);
+ break;
+ default:
+ ordinary(p, wc);
+ break;
+ }
break;
case '{': /* okay as ordinary except if digit follows */
(void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
/* FALLTHROUGH */
default:
+ if (p->error != 0)
+ return;
p->next--;
wc = WGETNEXT();
ordinary(p, wc);
@@ -498,7 +527,7 @@
/*
- p_bre - BRE parser top level, anchoring and concatenation
- == static void p_bre(struct parse *p, int end1, \
+ == static void p_bre(struct parse *p, int end1, \
== int end2);
* Giving end1 as OUT essentially eliminates the end1/end2 check.
*
@@ -569,6 +598,12 @@
case '[':
p_bracket(p);
break;
+ case BACKSL|'<':
+ EMIT(OBOW, 0);
+ break;
+ case BACKSL|'>':
+ EMIT(OEOW, 0);
+ break;
case BACKSL|'{':
SETERROR(REG_BADRPT);
break;
@@ -619,6 +654,8 @@
(void)REQUIRE(starordinary, REG_BADRPT);
/* FALLTHROUGH */
default:
+ if (p->error != 0)
+ return(0); /* Definitely not $... */
p->next--;
wc = WGETNEXT();
ordinary(p, wc);
@@ -746,7 +783,6 @@
case '-':
SETERROR(REG_ERANGE);
return; /* NOTE RETURN */
- break;
default:
c = '\0';
break;
@@ -785,14 +821,14 @@
if (start == finish)
CHadd(p, cs, start);
else {
- if (table->__collate_load_error) {
- (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE);
+ if (table->__collate_load_error || MB_CUR_MAX > 1) {
+ (void)REQUIRE(start <= finish, REG_ERANGE);
CHaddrange(p, cs, start, finish);
} else {
- (void)REQUIRE(__collate_range_cmp(table, start, finish) <= 0, REG_ERANGE);
+ (void)REQUIRE(__wcollate_range_cmp(start, finish) <= 0, REG_ERANGE);
for (i = 0; i <= UCHAR_MAX; i++) {
- if ( __collate_range_cmp(table, start, i) <= 0
- && __collate_range_cmp(table, i, finish) <= 0
+ if ( __wcollate_range_cmp(start, i) <= 0
+ && __wcollate_range_cmp(i, finish) <= 0
)
CHadd(p, cs, i);
}
@@ -847,7 +883,7 @@
/*
- p_b_symbol - parse a character or [..]ed multicharacter collating symbol
- == static char p_b_symbol(struct parse *p);
+ == static wint_t p_b_symbol(struct parse *p);
*/
static wint_t /* value of symbol */
p_b_symbol(struct parse *p)
@@ -866,7 +902,7 @@
/*
- p_b_coll_elem - parse a collating-element name and look it up
- == static char p_b_coll_elem(struct parse *p, int endc);
+ == static wint_t p_b_coll_elem(struct parse *p, wint_t endc);
*/
static wint_t /* value of collating element */
p_b_coll_elem(struct parse *p,
@@ -887,7 +923,7 @@
}
len = p->next - sp;
for (cp = cnames; cp->name != NULL; cp++)
- if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
+ if (strncmp(cp->name, sp, len) == 0 && strlen(cp->name) == len)
return(cp->code); /* known name */
memset(&mbs, 0, sizeof(mbs));
if ((clen = mbrtowc(&wc, sp, len, &mbs)) == len)
@@ -901,7 +937,7 @@
/*
- othercase - return the case counterpart of an alphabetic
- == static char othercase(int ch);
+ == static wint_t othercase(wint_t ch);
*/
static wint_t /* if no counterpart, return ch */
othercase(wint_t ch)
@@ -917,7 +953,7 @@
/*
- bothcases - emit a dualcase version of a two-case character
- == static void bothcases(struct parse *p, int ch);
+ == static void bothcases(struct parse *p, wint_t ch);
*
* Boy, is this implementation ever a kludge...
*/
@@ -946,7 +982,7 @@
/*
- ordinary - emit an ordinary character
- == static void ordinary(struct parse *p, int ch);
+ == static void ordinary(struct parse *p, wint_t ch);
*/
static void
ordinary(struct parse *p, wint_t ch)
@@ -1253,8 +1289,8 @@
assert(finish >= start);
if (len == 0)
return(ret);
- enlarge(p, p->ssize + len); /* this many unexpected additions */
- assert(p->ssize >= p->slen + len);
+ if (!enlarge(p, p->ssize + len)) /* this many unexpected additions */
+ return(ret);
(void) memcpy((char *)(p->strip + p->slen),
(char *)(p->strip + start), (size_t)len*sizeof(sop));
p->slen += len;
@@ -1281,8 +1317,8 @@
/* deal with undersized strip */
if (p->slen >= p->ssize)
- enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
- assert(p->slen < p->ssize);
+ if (!enlarge(p, (p->ssize+1) / 2 * 3)) /* +50% */
+ return;
/* finally, it's all reduced to the easy case */
p->strip[p->slen++] = SOP(op, opnd);
@@ -1341,23 +1377,24 @@
/*
- enlarge - enlarge the strip
- == static void enlarge(struct parse *p, sopno size);
+ == static int enlarge(struct parse *p, sopno size);
*/
-static void
+static int
enlarge(struct parse *p, sopno size)
{
sop *sp;
if (p->ssize >= size)
- return;
+ return 1;
sp = (sop *)realloc(p->strip, size*sizeof(sop));
if (sp == NULL) {
SETERROR(REG_ESPACE);
- return;
+ return 0;
}
p->strip = sp;
p->ssize = size;
+ return 1;
}
/*
@@ -1700,8 +1737,10 @@
}
g->matchjump = (int*) malloc(g->mlen * sizeof(unsigned int));
- if (g->matchjump == NULL) /* Not a fatal error */
+ if (g->matchjump == NULL) { /* Not a fatal error */
+ free(pmatches);
return;
+ }
/* Set maximum possible jump for each character in the pattern */
for (mindex = 0; mindex < g->mlen; mindex++)
Modified: trunk/lib/libc/regex/regerror.c
===================================================================
--- trunk/lib/libc/regex/regerror.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/regerror.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -37,7 +38,7 @@
static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/regerror.c 170528 2007-06-11 03:05:54Z delphij $");
#include <sys/types.h>
#include <stdio.h>
Modified: trunk/lib/libc/regex/regex.3
===================================================================
--- trunk/lib/libc/regex/regex.3 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/regex.3 2018-06-08 01:11:31 UTC (rev 10566)
@@ -30,9 +30,10 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)regex.3 8.4 (Berkeley) 3/20/94
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/regex/regex.3 302168 2016-06-24 02:24:34Z pfg $
+.\" $MidnightBSD$
.\"
-.Dd August 17, 2005
+.Dd May 25, 2016
.Dt REGEX 3
.Os
.Sh NAME
@@ -235,11 +236,16 @@
argument is the bitwise OR of zero or more of the following flags:
.Bl -tag -width REG_STARTEND
.It Dv REG_NOTBOL
-The first character of
-the string
-is not the beginning of a line, so the
-.Ql ^\&
-anchor should not match before it.
+The first character of the string is treated as the continuation
+of a line.
+This means that the anchors
+.Ql ^\& ,
+.Ql [[:<:]] ,
+and
+.Ql \e<
+do not match before it; but see
+.Dv REG_STARTEND
+below.
This does not affect the behavior of newlines under
.Dv REG_NEWLINE .
.It Dv REG_NOTEOL
@@ -247,19 +253,16 @@
the string
does not end a line, so the
.Ql $\&
-anchor should not match before it.
+anchor does not match before it.
This does not affect the behavior of newlines under
.Dv REG_NEWLINE .
.It Dv REG_STARTEND
The string is considered to start at
-.Fa string
-+
-.Fa pmatch Ns [0]. Ns Va rm_so
-and to have a terminating NUL located at
-.Fa string
-+
-.Fa pmatch Ns [0]. Ns Va rm_eo
-(there need not actually be a NUL at that location),
+.Fa string No +
+.Fa pmatch Ns [0]. Ns Fa rm_so
+and to end before the byte located at
+.Fa string No +
+.Fa pmatch Ns [0]. Ns Fa rm_eo ,
regardless of the value of
.Fa nmatch .
See below for the definition of
@@ -271,13 +274,37 @@
.St -p1003.2 ,
and should be used with
caution in software intended to be portable to other systems.
-Note that a non-zero
-.Va rm_so
-does not imply
-.Dv REG_NOTBOL ;
-.Dv REG_STARTEND
-affects only the location of the string,
-not how it is matched.
+.Pp
+Without
+.Dv REG_NOTBOL ,
+the position
+.Fa rm_so
+is considered the beginning of a line, such that
+.Ql ^
+matches before it, and the beginning of a word if there is a word
+character at this position, such that
+.Ql [[:<:]]
+and
+.Ql \e<
+match before it.
+.Pp
+With
+.Dv REG_NOTBOL ,
+the character at position
+.Fa rm_so
+is treated as the continuation of a line, and if
+.Fa rm_so
+is greater than 0, the preceding character is taken into consideration.
+If the preceding character is a newline and the regular expression was compiled
+with
+.Dv REG_NEWLINE ,
+.Ql ^
+matches before the string; if the preceding character is not a word character
+but the string starts with a word character,
+.Ql [[:<:]]
+and
+.Ql \e<
+match before the string.
.El
.Pp
See
Property changes on: trunk/lib/libc/regex/regex.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/regex/regex2.h
===================================================================
--- trunk/lib/libc/regex/regex2.h 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/regex2.h 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -31,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)regex2.h 8.4 (Berkeley) 3/20/94
- * $FreeBSD$
+ * $FreeBSD: stable/10/lib/libc/regex/regex2.h 165903 2007-01-09 00:28:16Z imp $
*/
/*
Modified: trunk/lib/libc/regex/regexec.c
===================================================================
--- trunk/lib/libc/regex/regexec.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/regexec.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -37,7 +38,7 @@
static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/regexec.c 170528 2007-06-11 03:05:54Z delphij $");
/*
* the outer shell of regexec()
Modified: trunk/lib/libc/regex/regfree.c
===================================================================
--- trunk/lib/libc/regex/regfree.c 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/regfree.c 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -37,7 +38,7 @@
static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/regex/regfree.c 170528 2007-06-11 03:05:54Z delphij $");
#include <sys/types.h>
#include <stdio.h>
Modified: trunk/lib/libc/regex/utils.h
===================================================================
--- trunk/lib/libc/regex/utils.h 2018-06-08 01:08:35 UTC (rev 10565)
+++ trunk/lib/libc/regex/utils.h 2018-06-08 01:11:31 UTC (rev 10566)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -31,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)utils.h 8.3 (Berkeley) 3/20/94
- * $FreeBSD$
+ * $FreeBSD: stable/10/lib/libc/regex/utils.h 165903 2007-01-09 00:28:16Z imp $
*/
/* utility definitions */
More information about the Midnightbsd-cvs
mailing list