PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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
 

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)
 

Function Documentation

int pg_reg_colorisbegin ( const regex_t regex,
int  co 
)

Definition at line 151 of file regexport.c.

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

Referenced by addKey().

152 {
153  struct cnfa *cnfa;
154 
155  assert(regex != NULL && regex->re_magic == REMAGIC);
156  cnfa = &((struct guts *) regex->re_guts)->search;
157 
158  if (co == cnfa->bos[0] || co == cnfa->bos[1])
159  return true;
160  else
161  return false;
162 }
Definition: regguts.h:354
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
color bos[2]
Definition: regguts.h:362
Definition: regguts.h:462
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
int pg_reg_colorisend ( const regex_t regex,
int  co 
)

Definition at line 168 of file regexport.c.

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

Referenced by addKey().

169 {
170  struct cnfa *cnfa;
171 
172  assert(regex != NULL && regex->re_magic == REMAGIC);
173  cnfa = &((struct guts *) regex->re_guts)->search;
174 
175  if (co == cnfa->eos[0] || co == cnfa->eos[1])
176  return true;
177  else
178  return false;
179 }
Definition: regguts.h:354
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
color eos[2]
Definition: regguts.h:363
void pg_reg_getcharacters ( const regex_t regex,
int  co,
pg_wchar chars,
int  chars_len 
)

Definition at line 225 of file regexport.c.

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

Referenced by getColorInfo().

227 {
228  struct colormap *cm;
229  chr c;
230 
231  assert(regex != NULL && regex->re_magic == REMAGIC);
232  cm = &((struct guts *) regex->re_guts)->cmap;
233 
234  if (co <= 0 || co > cm->max || chars_len <= 0)
235  return;
236  if (cm->cd[co].flags & PSEUDO)
237  return;
238 
239  /*
240  * We need only examine the low character map; there should not be any
241  * matching entries in the high map.
242  */
243  for (c = CHR_MIN; c <= MAX_SIMPLE_CHR; c++)
244  {
245  if (cm->locolormap[c - CHR_MIN] == co)
246  {
247  *chars++ = c;
248  if (--chars_len == 0)
249  break;
250  }
251  }
252 }
color * locolormap
Definition: regguts.h:218
#define REMAGIC
Definition: regguts.h:96
struct colordesc * cd
Definition: regguts.h:214
int re_magic
Definition: regex.h:57
pg_wchar chr
Definition: regcustom.h:68
char * c
#define assert(TEST)
Definition: imath.c:37
#define CHR_MIN
Definition: regcustom.h:74
Definition: regguts.h:462
#define NULL
Definition: c.h:229
int flags
Definition: regguts.h:162
char * re_guts
Definition: regex.h:78
#define PSEUDO
Definition: regguts.h:164
static char chars[TZ_MAX_CHARS]
Definition: zic.c:381
size_t max
Definition: regguts.h:212
#define MAX_SIMPLE_CHR
Definition: regcustom.h:97
int pg_reg_getfinalstate ( const regex_t regex)

Definition at line 64 of file regexport.c.

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

Referenced by addKey().

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:354
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
int post
Definition: regguts.h:361
char * re_guts
Definition: regex.h:78
int pg_reg_getinitialstate ( const regex_t regex)

Definition at line 50 of file regexport.c.

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

Referenced by 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:354
int pre
Definition: regguts.h:360
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
int pg_reg_getnumcharacters ( const regex_t regex,
int  co 
)

Definition at line 189 of file regexport.c.

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

Referenced by getColorInfo().

190 {
191  struct colormap *cm;
192 
193  assert(regex != NULL && regex->re_magic == REMAGIC);
194  cm = &((struct guts *) regex->re_guts)->cmap;
195 
196  if (co <= 0 || co > cm->max) /* we reject 0 which is WHITE */
197  return -1;
198  if (cm->cd[co].flags & PSEUDO) /* also pseudocolors (BOS etc) */
199  return -1;
200 
201  /*
202  * If the color appears anywhere in the high colormap, treat its number of
203  * members as uncertain. In principle we could determine all the specific
204  * chrs corresponding to each such entry, but it would be expensive
205  * (particularly if character class tests are required) and it doesn't
206  * seem worth it.
207  */
208  if (cm->cd[co].nuchrs != 0)
209  return -1;
210 
211  /* OK, return the known number of member chrs */
212  return cm->cd[co].nschrs;
213 }
#define REMAGIC
Definition: regguts.h:96
struct colordesc * cd
Definition: regguts.h:214
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
int nschrs
Definition: regguts.h:156
int flags
Definition: regguts.h:162
char * re_guts
Definition: regex.h:78
#define PSEUDO
Definition: regguts.h:164
int nuchrs
Definition: regguts.h:157
size_t max
Definition: regguts.h:212
int pg_reg_getnumcolors ( const regex_t regex)

Definition at line 134 of file regexport.c.

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

Referenced by getColorInfo().

135 {
136  struct colormap *cm;
137 
138  assert(regex != NULL && regex->re_magic == REMAGIC);
139  cm = &((struct guts *) regex->re_guts)->cmap;
140 
141  return cm->max + 1;
142 }
#define REMAGIC
Definition: regguts.h:96
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
size_t max
Definition: regguts.h:212
int pg_reg_getnumoutarcs ( const regex_t regex,
int  st 
)

Definition at line 80 of file regexport.c.

References assert, carc::co, COLORLESS, cnfa::ncolors, cnfa::nstates, NULL, regex_t::re_guts, regex_t::re_magic, REMAGIC, and cnfa::states.

Referenced by addArcs(), and addKey().

81 {
82  struct cnfa *cnfa;
83  struct carc *ca;
84  int count;
85 
86  assert(regex != NULL && regex->re_magic == REMAGIC);
87  cnfa = &((struct guts *) regex->re_guts)->search;
88 
89  if (st < 0 || st >= cnfa->nstates)
90  return 0;
91  count = 0;
92  for (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)
93  {
94  if (ca->co < cnfa->ncolors)
95  count++;
96  }
97  return count;
98 }
Definition: regguts.h:354
#define REMAGIC
Definition: regguts.h:96
struct carc ** states
Definition: regguts.h:366
int nstates
Definition: regguts.h:356
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
color co
Definition: regguts.h:350
#define COLORLESS
Definition: regguts.h:137
int ncolors
Definition: regguts.h:357
Definition: regguts.h:348
int pg_reg_getnumstates ( const regex_t regex)

Definition at line 36 of file regexport.c.

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

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:354
#define REMAGIC
Definition: regguts.h:96
int nstates
Definition: regguts.h:356
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
void pg_reg_getoutarcs ( const regex_t regex,
int  st,
regex_arc_t arcs,
int  arcs_len 
)

Definition at line 106 of file regexport.c.

References assert, regex_arc_t::co, carc::co, COLORLESS, cnfa::ncolors, cnfa::nstates, NULL, regex_t::re_guts, regex_t::re_magic, REMAGIC, cnfa::states, regex_arc_t::to, and carc::to.

Referenced by addArcs(), and addKey().

108 {
109  struct cnfa *cnfa;
110  struct carc *ca;
111 
112  assert(regex != NULL && regex->re_magic == REMAGIC);
113  cnfa = &((struct guts *) regex->re_guts)->search;
114 
115  if (st < 0 || st >= cnfa->nstates || arcs_len <= 0)
116  return;
117  for (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)
118  {
119  if (ca->co < cnfa->ncolors)
120  {
121  arcs->co = ca->co;
122  arcs->to = ca->to;
123  arcs++;
124  if (--arcs_len == 0)
125  break;
126  }
127  }
128 }
Definition: regguts.h:354
#define REMAGIC
Definition: regguts.h:96
struct carc ** states
Definition: regguts.h:366
int nstates
Definition: regguts.h:356
int re_magic
Definition: regex.h:57
#define assert(TEST)
Definition: imath.c:37
Definition: regguts.h:462
int to
Definition: regguts.h:351
#define NULL
Definition: c.h:229
char * re_guts
Definition: regex.h:78
color co
Definition: regguts.h:350
#define COLORLESS
Definition: regguts.h:137
int ncolors
Definition: regguts.h:357
Definition: regguts.h:348