Skip to content

Commit a859e64

Browse files
committed
Clean up another pre-ANSI-C-ism in regex code: get rid of pcolor typedef.
pcolor was used to represent function arguments that are nominally of type color, but when using a pre-ANSI C compiler would be passed as the promoted integer type. We really don't need that anymore.
1 parent 6eefd24 commit a859e64

File tree

6 files changed

+21
-22
lines changed

6 files changed

+21
-22
lines changed

src/backend/regex/regc_color.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ cmtreefree(struct colormap * cm,
148148
static color /* previous color */
149149
setcolor(struct colormap * cm,
150150
chr c,
151-
pcolor co)
151+
color co)
152152
{
153153
uchr uc = c;
154154
int shift;
@@ -199,7 +199,7 @@ setcolor(struct colormap * cm,
199199

200200
b = uc & BYTMASK;
201201
prev = t->tcolor[b];
202-
t->tcolor[b] = (color) co;
202+
t->tcolor[b] = co;
203203
return prev;
204204
}
205205

@@ -293,7 +293,7 @@ newcolor(struct colormap * cm)
293293
*/
294294
static void
295295
freecolor(struct colormap * cm,
296-
pcolor co)
296+
color co)
297297
{
298298
struct colordesc *cd = &cm->cd[co];
299299
color pco,
@@ -393,7 +393,7 @@ subcolor(struct colormap * cm, chr c)
393393
*/
394394
static color
395395
newsub(struct colormap * cm,
396-
pcolor co)
396+
color co)
397397
{
398398
color sco; /* new subcolor */
399399

@@ -658,7 +658,7 @@ static void
658658
rainbow(struct nfa * nfa,
659659
struct colormap * cm,
660660
int type,
661-
pcolor but, /* COLORLESS if no exceptions */
661+
color but, /* COLORLESS if no exceptions */
662662
struct state * from,
663663
struct state * to)
664664
{

src/backend/regex/regc_nfa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ destroystate(struct nfa * nfa,
275275
static void
276276
newarc(struct nfa * nfa,
277277
int t,
278-
pcolor co,
278+
color co,
279279
struct state * from,
280280
struct state * to)
281281
{
@@ -321,7 +321,7 @@ newarc(struct nfa * nfa,
321321
static void
322322
createarc(struct nfa * nfa,
323323
int t,
324-
pcolor co,
324+
color co,
325325
struct state * from,
326326
struct state * to)
327327
{
@@ -334,7 +334,7 @@ createarc(struct nfa * nfa,
334334
assert(a != NULL);
335335

336336
a->type = t;
337-
a->co = (color) co;
337+
a->co = co;
338338
a->to = to;
339339
a->from = from;
340340

@@ -553,7 +553,7 @@ hasnonemptyout(struct state * s)
553553
static struct arc *
554554
findarc(struct state * s,
555555
int type,
556-
pcolor co)
556+
color co)
557557
{
558558
struct arc *a;
559559

src/backend/regex/regcomp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ static chr chrnamed(struct vars *, const chr *, const chr *, chr);
9797
static void initcm(struct vars *, struct colormap *);
9898
static void freecm(struct colormap *);
9999
static void cmtreefree(struct colormap *, union tree *, int);
100-
static color setcolor(struct colormap *, chr, pcolor);
100+
static color setcolor(struct colormap *, chr, color);
101101
static color maxcolor(struct colormap *);
102102
static color newcolor(struct colormap *);
103-
static void freecolor(struct colormap *, pcolor);
103+
static void freecolor(struct colormap *, color);
104104
static color pseudocolor(struct colormap *);
105105
static color subcolor(struct colormap *, chr c);
106-
static color newsub(struct colormap *, pcolor);
106+
static color newsub(struct colormap *, color);
107107
static void subrange(struct vars *, chr, chr, struct state *, struct state *);
108108
static void subblock(struct vars *, chr, struct state *, struct state *);
109109
static void okcolors(struct nfa *, struct colormap *);
110110
static void colorchain(struct colormap *, struct arc *);
111111
static void uncolorchain(struct colormap *, struct arc *);
112-
static void rainbow(struct nfa *, struct colormap *, int, pcolor, struct state *, struct state *);
112+
static void rainbow(struct nfa *, struct colormap *, int, color, struct state *, struct state *);
113113
static void colorcomplement(struct nfa *, struct colormap *, int, struct state *, struct state *, struct state *);
114114

115115
#ifdef REG_DEBUG
@@ -125,13 +125,13 @@ static struct state *newfstate(struct nfa *, int flag);
125125
static void dropstate(struct nfa *, struct state *);
126126
static void freestate(struct nfa *, struct state *);
127127
static void destroystate(struct nfa *, struct state *);
128-
static void newarc(struct nfa *, int, pcolor, struct state *, struct state *);
129-
static void createarc(struct nfa *, int, pcolor, struct state *, struct state *);
128+
static void newarc(struct nfa *, int, color, struct state *, struct state *);
129+
static void createarc(struct nfa *, int, color, struct state *, struct state *);
130130
static struct arc *allocarc(struct nfa *, struct state *);
131131
static void freearc(struct nfa *, struct arc *);
132132
static void changearctarget(struct arc *, struct state *);
133133
static int hasnonemptyout(struct state *);
134-
static struct arc *findarc(struct state *, int, pcolor);
134+
static struct arc *findarc(struct state *, int, color);
135135
static void cparc(struct nfa *, struct arc *, struct state *, struct state *);
136136
static void sortins(struct nfa *, struct state *);
137137
static int sortins_cmp(const void *, const void *);

src/backend/regex/rege_dfa.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ static struct sset *
603603
miss(struct vars * v,
604604
struct dfa * d,
605605
struct sset * css,
606-
pcolor co,
606+
color co,
607607
chr *cp, /* next chr */
608608
chr *start) /* where the attempt got started */
609609
{
@@ -731,7 +731,7 @@ miss(struct vars * v,
731731
css->outs[co] = p;
732732
css->inchain[co] = p->ins;
733733
p->ins.ss = css;
734-
p->ins.co = (color) co;
734+
p->ins.co = co;
735735
}
736736
return p;
737737
}
@@ -743,7 +743,7 @@ static int /* predicate: constraint satisfied? */
743743
lacon(struct vars * v,
744744
struct cnfa * pcnfa, /* parent cnfa */
745745
chr *cp,
746-
pcolor co) /* "color" of the lookaround constraint */
746+
color co) /* "color" of the lookaround constraint */
747747
{
748748
int n;
749749
struct subre *sub;

src/backend/regex/regexec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ static struct dfa *newdfa(struct vars *, struct cnfa *, struct colormap *, struc
159159
static void freedfa(struct dfa *);
160160
static unsigned hash(unsigned *, int);
161161
static struct sset *initialize(struct vars *, struct dfa *, chr *);
162-
static struct sset *miss(struct vars *, struct dfa *, struct sset *, pcolor, chr *, chr *);
163-
static int lacon(struct vars *, struct cnfa *, chr *, pcolor);
162+
static struct sset *miss(struct vars *, struct dfa *, struct sset *, color, chr *, chr *);
163+
static int lacon(struct vars *, struct cnfa *, chr *, color);
164164
static struct sset *getvacant(struct vars *, struct dfa *, chr *, chr *);
165165
static struct sset *pickss(struct vars *, struct dfa *, chr *, chr *);
166166

src/include/regex/regguts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
* which are of much more manageable number.
150150
*/
151151
typedef short color; /* colors of characters */
152-
typedef int pcolor; /* what color promotes to */
153152

154153
#define MAX_COLOR 32767 /* max color (must fit in 'color' datatype) */
155154
#define COLORLESS (-1) /* impossible color */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy