PostgreSQL Source Code  git master
regexport.h File Reference
#include "regex/regex.h"
Include dependency graph for regexport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  regex_arc_t
 

Macros

#define COLOR_WHITE   0 /* color for chars not appearing in regex */
 
#define COLOR_RAINBOW   (-2) /* represents all colors except pseudocolors */
 

Functions

int pg_reg_getnumstates (const regex_t *regex)
 
int pg_reg_getinitialstate (const regex_t *regex)
 
int pg_reg_getfinalstate (const regex_t *regex)
 
int pg_reg_getnumoutarcs (const regex_t *regex, int st)
 
void pg_reg_getoutarcs (const regex_t *regex, int st, regex_arc_t *arcs, int arcs_len)
 
int pg_reg_getnumcolors (const regex_t *regex)
 
int pg_reg_colorisbegin (const regex_t *regex, int co)
 
int pg_reg_colorisend (const regex_t *regex, int co)
 
int pg_reg_getnumcharacters (const regex_t *regex, int co)
 
void pg_reg_getcharacters (const regex_t *regex, int co, pg_wchar *chars, int chars_len)
 

Macro Definition Documentation

◆ COLOR_RAINBOW

#define COLOR_RAINBOW   (-2) /* represents all colors except pseudocolors */

Definition at line 35 of file regexport.h.

◆ COLOR_WHITE

#define COLOR_WHITE   0 /* color for chars not appearing in regex */

Definition at line 34 of file regexport.h.

Function Documentation

◆ pg_reg_colorisbegin()

int pg_reg_colorisbegin ( const regex_t regex,
int  co 
)

Definition at line 191 of file regexport.c.

References assert, cnfa::bos, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by addKey().

192 {
193  struct cnfa *cnfa;
194 
195  assert(regex != NULL && regex->re_magic == REMAGIC);
196  cnfa = &((struct guts *) regex->re_guts)->search;
197 
198  if (co == cnfa->bos[0] || co == cnfa->bos[1])
199  return true;
200  else
201  return false;
202 }
Definition: regguts.h:401
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
color bos[2]
Definition: regguts.h:410
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80

◆ pg_reg_colorisend()

int pg_reg_colorisend ( const regex_t regex,
int  co 
)

Definition at line 208 of file regexport.c.

References assert, cnfa::eos, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by addKey().

209 {
210  struct cnfa *cnfa;
211 
212  assert(regex != NULL && regex->re_magic == REMAGIC);
213  cnfa = &((struct guts *) regex->re_guts)->search;
214 
215  if (co == cnfa->eos[0] || co == cnfa->eos[1])
216  return true;
217  else
218  return false;
219 }
Definition: regguts.h:401
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80
color eos[2]
Definition: regguts.h:411

◆ pg_reg_getcharacters()

void pg_reg_getcharacters ( const regex_t regex,
int  co,
pg_wchar chars,
int  chars_len 
)

Definition at line 266 of file regexport.c.

References assert, colormap::cd, CHR_MIN, colordesc::flags, colormap::locolormap, colormap::max, MAX_SIMPLE_CHR, PSEUDO, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by getColorInfo().

268 {
269  struct colormap *cm;
270  chr c;
271 
272  assert(regex != NULL && regex->re_magic == REMAGIC);
273  cm = &((struct guts *) regex->re_guts)->cmap;
274 
275  if (co <= 0 || co > cm->max || chars_len <= 0)
276  return;
277  if (cm->cd[co].flags & PSEUDO)
278  return;
279 
280  /*
281  * We need only examine the low character map; there should not be any
282  * matching entries in the high map.
283  */
284  for (c = CHR_MIN; c <= MAX_SIMPLE_CHR; c++)
285  {
286  if (cm->locolormap[c - CHR_MIN] == co)
287  {
288  *chars++ = c;
289  if (--chars_len == 0)
290  break;
291  }
292  }
293 }
color * locolormap
Definition: regguts.h:235
#define REMAGIC
Definition: regguts.h:96
struct colordesc * cd
Definition: regguts.h:231
int re_magic
Definition: regex.h:57
pg_wchar chr
Definition: regcustom.h:66
char * c
#define assert(TEST)
Definition: imath.c:73
#define CHR_MIN
Definition: regcustom.h:72
Definition: regguts.h:526
int flags
Definition: regguts.h:179
char * re_guts
Definition: regex.h:80
#define PSEUDO
Definition: regguts.h:181
static char chars[TZ_MAX_CHARS]
Definition: zic.c:399
size_t max
Definition: regguts.h:229
#define MAX_SIMPLE_CHR
Definition: regcustom.h:95

◆ pg_reg_getfinalstate()

int pg_reg_getfinalstate ( const regex_t regex)

Definition at line 64 of file regexport.c.

References assert, cnfa::post, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by addKey(), and packArcInfoCmp().

65 {
66  struct cnfa *cnfa;
67 
68  assert(regex != NULL && regex->re_magic == REMAGIC);
69  cnfa = &((struct guts *) regex->re_guts)->search;
70 
71  return cnfa->post;
72 }
Definition: regguts.h:401
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
int post
Definition: regguts.h:409
char * re_guts
Definition: regex.h:80

◆ pg_reg_getinitialstate()

int pg_reg_getinitialstate ( const regex_t regex)

Definition at line 50 of file regexport.c.

References assert, cnfa::pre, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by packArcInfoCmp(), and transformGraph().

51 {
52  struct cnfa *cnfa;
53 
54  assert(regex != NULL && regex->re_magic == REMAGIC);
55  cnfa = &((struct guts *) regex->re_guts)->search;
56 
57  return cnfa->pre;
58 }
Definition: regguts.h:401
int pre
Definition: regguts.h:408
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80

◆ pg_reg_getnumcharacters()

int pg_reg_getnumcharacters ( const regex_t regex,
int  co 
)

Definition at line 230 of file regexport.c.

References assert, colormap::cd, colordesc::flags, colormap::max, colordesc::nschrs, colordesc::nuchrs, PSEUDO, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by getColorInfo().

231 {
232  struct colormap *cm;
233 
234  assert(regex != NULL && regex->re_magic == REMAGIC);
235  cm = &((struct guts *) regex->re_guts)->cmap;
236 
237  if (co <= 0 || co > cm->max) /* <= 0 rejects WHITE and RAINBOW */
238  return -1;
239  if (cm->cd[co].flags & PSEUDO) /* also pseudocolors (BOS etc) */
240  return -1;
241 
242  /*
243  * If the color appears anywhere in the high colormap, treat its number of
244  * members as uncertain. In principle we could determine all the specific
245  * chrs corresponding to each such entry, but it would be expensive
246  * (particularly if character class tests are required) and it doesn't
247  * seem worth it.
248  */
249  if (cm->cd[co].nuchrs != 0)
250  return -1;
251 
252  /* OK, return the known number of member chrs */
253  return cm->cd[co].nschrs;
254 }
#define REMAGIC
Definition: regguts.h:96
struct colordesc * cd
Definition: regguts.h:231
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
int nschrs
Definition: regguts.h:173
int flags
Definition: regguts.h:179
char * re_guts
Definition: regex.h:80
#define PSEUDO
Definition: regguts.h:181
int nuchrs
Definition: regguts.h:174
size_t max
Definition: regguts.h:229

◆ pg_reg_getnumcolors()

int pg_reg_getnumcolors ( const regex_t regex)

Definition at line 174 of file regexport.c.

References assert, colormap::max, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by getColorInfo().

175 {
176  struct colormap *cm;
177 
178  assert(regex != NULL && regex->re_magic == REMAGIC);
179  cm = &((struct guts *) regex->re_guts)->cmap;
180 
181  return cm->max + 1;
182 }
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80
size_t max
Definition: regguts.h:229

◆ pg_reg_getnumoutarcs()

int pg_reg_getnumoutarcs ( const regex_t regex,
int  st 
)

Definition at line 134 of file regexport.c.

References assert, cnfa::nstates, regex_t::re_guts, regex_t::re_magic, REMAGIC, and traverse_lacons().

Referenced by addArcs(), addKey(), and packArcInfoCmp().

135 {
136  struct cnfa *cnfa;
137  int arcs_count;
138 
139  assert(regex != NULL && regex->re_magic == REMAGIC);
140  cnfa = &((struct guts *) regex->re_guts)->search;
141 
142  if (st < 0 || st >= cnfa->nstates)
143  return 0;
144  arcs_count = 0;
145  traverse_lacons(cnfa, st, &arcs_count, NULL, 0);
146  return arcs_count;
147 }
static void traverse_lacons(struct cnfa *cnfa, int st, int *arcs_count, regex_arc_t *arcs, int arcs_len)
Definition: regexport.c:93
Definition: regguts.h:401
#define REMAGIC
Definition: regguts.h:96
int nstates
Definition: regguts.h:403
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80

◆ pg_reg_getnumstates()

int pg_reg_getnumstates ( const regex_t regex)

Definition at line 36 of file regexport.c.

References assert, cnfa::nstates, regex_t::re_guts, regex_t::re_magic, and REMAGIC.

Referenced by packArcInfoCmp().

37 {
38  struct cnfa *cnfa;
39 
40  assert(regex != NULL && regex->re_magic == REMAGIC);
41  cnfa = &((struct guts *) regex->re_guts)->search;
42 
43  return cnfa->nstates;
44 }
Definition: regguts.h:401
#define REMAGIC
Definition: regguts.h:96
int nstates
Definition: regguts.h:403
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80

◆ pg_reg_getoutarcs()

void pg_reg_getoutarcs ( const regex_t regex,
int  st,
regex_arc_t arcs,
int  arcs_len 
)

Definition at line 155 of file regexport.c.

References assert, cnfa::nstates, regex_t::re_guts, regex_t::re_magic, REMAGIC, and traverse_lacons().

Referenced by addArcs(), addKey(), and packArcInfoCmp().

157 {
158  struct cnfa *cnfa;
159  int arcs_count;
160 
161  assert(regex != NULL && regex->re_magic == REMAGIC);
162  cnfa = &((struct guts *) regex->re_guts)->search;
163 
164  if (st < 0 || st >= cnfa->nstates || arcs_len <= 0)
165  return;
166  arcs_count = 0;
167  traverse_lacons(cnfa, st, &arcs_count, arcs, arcs_len);
168 }
static void traverse_lacons(struct cnfa *cnfa, int st, int *arcs_count, regex_arc_t *arcs, int arcs_len)
Definition: regexport.c:93
Definition: regguts.h:401
#define REMAGIC
Definition: regguts.h:96
int nstates
Definition: regguts.h:403
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:73
Definition: regguts.h:526
char * re_guts
Definition: regex.h:80