re_guts catspace[] is only written to (via categories[]), and never used
for anything, so don't bother keeping that.

Index: lib/libc/regex/regcomp.c
===================================================================
RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v
retrieving revision 1.38
diff -u -p -r1.38 regcomp.c
--- lib/libc/regex/regcomp.c    30 Dec 2020 08:59:17 -0000      1.38
+++ lib/libc/regex/regcomp.c    31 Dec 2020 07:20:39 -0000
@@ -92,7 +92,6 @@ static int firstch(struct parse *, cset 
 static int nch(struct parse *, cset *);
 static int isinsets(struct re_guts *, int);
 static int samesets(struct re_guts *, int, int);
-static void categorize(struct parse *, struct re_guts *);
 static sopno dupl(struct parse *, sopno, sopno);
 static void doemit(struct parse *, sop, size_t);
 static void doinsert(struct parse *, sop, size_t, sopno);
@@ -198,9 +197,6 @@ regcomp(regex_t *preg, const char *patte
        g->must = NULL;
        g->mlen = 0;
        g->nsub = 0;
-       g->ncategories = 1;     /* category 0 is "everything else" */
-       g->categories = &g->catspace[-(CHAR_MIN)];
-       memset(g->catspace, 0, sizeof(g->catspace));
        g->backrefs = 0;
 
        /* do it */
@@ -216,7 +212,6 @@ regcomp(regex_t *preg, const char *patte
        g->laststate = THERE();
 
        /* tidy up loose ends and fill things in */
-       categorize(p, g);
        stripsnug(p, g);
        findmust(p, g);
        g->nplus = pluscount(p, g);
@@ -883,15 +878,10 @@ bothcases(struct parse *p, int ch)
 static void
 ordinary(struct parse *p, int ch)
 {
-       cat_t *cap = p->g->categories;
-
        if ((p->g->cflags&REG_ICASE) && isalpha((uch)ch) && othercase(ch) != ch)
                bothcases(p, ch);
-       else {
+       else
                EMIT(OCHAR, (uch)ch);
-               if (cap[ch] == 0)
-                       cap[ch] = p->g->ncategories++;
-       }
 }
 
 /*
@@ -1195,31 +1180,6 @@ samesets(struct re_guts *g, int c1, int 
                if (col[uc1] != col[uc2])
                        return(0);
        return(1);
-}
-
-/*
- - categorize - sort out character categories
- */
-static void
-categorize(struct parse *p, struct re_guts *g)
-{
-       cat_t *cats = g->categories;
-       int c;
-       int c2;
-       cat_t cat;
-
-       /* avoid making error situations worse */
-       if (p->error != 0)
-               return;
-
-       for (c = CHAR_MIN; c <= CHAR_MAX; c++)
-               if (cats[c] == 0 && isinsets(g, c)) {
-                       cat = g->ncategories++;
-                       cats[c] = cat;
-                       for (c2 = c+1; c2 <= CHAR_MAX; c2++)
-                               if (cats[c2] == 0 && samesets(g, c, c2))
-                                       cats[c2] = cat;
-               }
 }
 
 /*
Index: lib/libc/regex/regex2.h
===================================================================
RCS file: /OpenBSD/src/lib/libc/regex/regex2.h,v
retrieving revision 1.9
diff -u -p -r1.9 regex2.h
--- lib/libc/regex/regex2.h     30 Dec 2020 08:54:42 -0000      1.9
+++ lib/libc/regex/regex2.h     31 Dec 2020 07:20:39 -0000
@@ -112,9 +112,6 @@ typedef struct {
 #define        CHsub(cs, c)    ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash 
-= (c))
 #define        CHIN(cs, c)     ((cs)->ptr[(uch)(c)] & (cs)->mask)
 
-/* stuff for character categories */
-typedef unsigned char cat_t;
-
 /*
  * main compiled-expression structure
  */
@@ -136,15 +133,11 @@ struct re_guts {
 #              define  BAD     04      /* something wrong */
        int nbol;               /* number of ^ used */
        int neol;               /* number of $ used */
-       int ncategories;        /* how many character categories */
-       cat_t *categories;      /* ->catspace[-CHAR_MIN] */
        char *must;             /* match must contain this string */
        int mlen;               /* length of must */
        size_t nsub;            /* copy of re_nsub */
        int backrefs;           /* does it use back references? */
        sopno nplus;            /* how deep does it nest +s? */
-       /* catspace must be last */
-       cat_t catspace[NC];     /* actually [NC] */
 };
 
 /* misc utilities */
Index: regress/lib/libc/regex/debug.c
===================================================================
RCS file: /OpenBSD/src/regress/lib/libc/regex/debug.c,v
retrieving revision 1.4
diff -u -p -r1.4 debug.c
--- regress/lib/libc/regex/debug.c      31 Jul 2003 21:48:03 -0000      1.4
+++ regress/lib/libc/regex/debug.c      31 Dec 2020 07:20:39 -0000
@@ -26,10 +26,8 @@ FILE *d;
        register int i;
        register int c;
        register int last;
-       int nincat[NC];
 
-       fprintf(d, "%ld states, %d categories", (long)g->nstates,
-                                                       g->ncategories);
+       fprintf(d, "%ld states", (long)g->nstates);
        fprintf(d, ", first %ld last %ld", (long)g->firststate,
                                                (long)g->laststate);
        if (g->iflags&USEBOL)
@@ -49,41 +47,6 @@ FILE *d;
                fprintf(d, ", nplus %ld", (long)g->nplus);
        fprintf(d, "\n");
        s_print(g, d);
-       for (i = 0; i < g->ncategories; i++) {
-               nincat[i] = 0;
-               for (c = CHAR_MIN; c <= CHAR_MAX; c++)
-                       if (g->categories[c] == i)
-                               nincat[i]++;
-       }
-       fprintf(d, "cc0#%d", nincat[0]);
-       for (i = 1; i < g->ncategories; i++)
-               if (nincat[i] == 1) {
-                       for (c = CHAR_MIN; c <= CHAR_MAX; c++)
-                               if (g->categories[c] == i)
-                                       break;
-                       fprintf(d, ", %d=%s", i, regchar(c));
-               }
-       fprintf(d, "\n");
-       for (i = 1; i < g->ncategories; i++)
-               if (nincat[i] != 1) {
-                       fprintf(d, "cc%d\t", i);
-                       last = -1;
-                       for (c = CHAR_MIN; c <= CHAR_MAX+1; c++)        /* +1 
does flush */
-                               if (c <= CHAR_MAX && g->categories[c] == i) {
-                                       if (last < 0) {
-                                               fprintf(d, "%s", regchar(c));
-                                               last = c;
-                                       }
-                               } else {
-                                       if (last >= 0) {
-                                               if (last != c-1)
-                                                       fprintf(d, "-%s",
-                                                               regchar(c-1));
-                                               last = -1;
-                                       }
-                               }
-                       fprintf(d, "\n");
-               }
 }
 
 /*

Reply via email to