Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/regex Add REG_POSIX, and make compile on linu...



details:   https://anonhg.NetBSD.org/src/rev/eff875f45bac
branches:  trunk
changeset: 959744:eff875f45bac
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Feb 23 15:00:01 2021 +0000

description:
Add REG_POSIX, and make compile on linux where we don't have a lot of the
internal flags.

diffstat:

 tests/lib/libc/regex/main.c |  31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diffs (100 lines):

diff -r 667c0daae5e9 -r eff875f45bac tests/lib/libc/regex/main.c
--- a/tests/lib/libc/regex/main.c       Tue Feb 23 14:59:09 2021 +0000
+++ b/tests/lib/libc/regex/main.c       Tue Feb 23 15:00:01 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.2 2011/09/16 16:13:18 plunky Exp $  */
+/*     $NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $        */
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -52,6 +52,16 @@
 static char *eprint(int);
 static int efind(char *);
 
+#ifndef REG_ATOI
+#define REG_ATOI 0
+#define REG_ITOA 0
+#define REG_PEND 0
+#define REG_TRACE 0
+#define REG_BACKR 0
+#define REG_NOSPEC 0
+#define REG_LARGE 0
+#endif
+
 /*
  * main - do the simple case, hand off to regress() for regression
  */
@@ -72,7 +82,7 @@
 
        progname = argv[0];
 
-       while ((c = getopt(argc, argv, "c:e:S:E:x")) != -1)
+       while ((c = getopt(argc, argv, "c:E:e:S:x")) != -1)
                switch (c) {
                case 'c':       /* compile options */
                        copts = options('c', optarg);
@@ -80,12 +90,12 @@
                case 'e':       /* execute options */
                        eopts = options('e', optarg);
                        break;
+               case 'E':       /* end offset */
+                       endoff = (regoff_t)atoi(optarg);
+                       break;
                case 'S':       /* start offset */
                        startoff = (regoff_t)atoi(optarg);
                        break;
-               case 'E':       /* end offset */
-                       endoff = (regoff_t)atoi(optarg);
-                       break;
                case 'x':       /* Debugging. */
                        debug++;
                        break;
@@ -211,7 +221,9 @@
                                                erbuf, bpname);
                status = 1;
        }
+#if REG_ATOI
        re.re_endp = bpname;
+#endif
        ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
        if (atoi(erbuf) != (int)REG_BADPAT) {
                fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
@@ -247,7 +259,9 @@
        char f2copy[1000];
 
        strcpy(f0copy, f0);
+#if REG_ATOI
        re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
+#endif
        fixstr(f0copy);
        err = regcomp(&re, f0copy, opts);
        if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
@@ -338,7 +352,7 @@
 {
        char *p;
        int o = (type == 'c') ? copts : eopts;
-       const char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
+       const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl";
 
        for (p = s; *p != '\0'; p++)
                if (strchr(legal, *p) != NULL)
@@ -362,6 +376,9 @@
                        case 'p':
                                o |= REG_PEND;
                                break;
+                       case 'P':
+                               o |= REG_POSIX;
+                               break;
                        case '^':
                                o |= REG_NOTBOL;
                                break;
@@ -517,7 +534,9 @@
 
        sprintf(efbuf, "REG_%s", name);
        assert(strlen(efbuf) < sizeof(efbuf));
+#if REG_ATOI
        re.re_endp = efbuf;
+#endif
        (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
        return(atoi(efbuf));
 }



Home | Main Index | Thread Index | Old Index