#include "m_ctype.h"Include dependency graph for my_regex.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | my_regex_t |
| struct | my_regmatch_t |
Defines | |
| #define | _REGEX_H_ |
| #define | REG_BASIC 0000 |
| #define | REG_EXTENDED 0001 |
| #define | REG_ICASE 0002 |
| #define | REG_NOSUB 0004 |
| #define | REG_NEWLINE 0010 |
| #define | REG_NOSPEC 0020 |
| #define | REG_PEND 0040 |
| #define | REG_DUMP 0200 |
| #define | REG_NOMATCH 1 |
| #define | REG_BADPAT 2 |
| #define | REG_ECOLLATE 3 |
| #define | REG_ECTYPE 4 |
| #define | REG_EESCAPE 5 |
| #define | REG_ESUBREG 6 |
| #define | REG_EBRACK 7 |
| #define | REG_EPAREN 8 |
| #define | REG_EBRACE 9 |
| #define | REG_BADBR 10 |
| #define | REG_ERANGE 11 |
| #define | REG_ESPACE 12 |
| #define | REG_BADRPT 13 |
| #define | REG_EMPTY 14 |
| #define | REG_ASSERT 15 |
| #define | REG_INVARG 16 |
| #define | REG_ATOI 255 |
| #define | REG_ITOA 0400 |
| #define | REG_NOTBOL 00001 |
| #define | REG_NOTEOL 00002 |
| #define | REG_STARTEND 00004 |
| #define | REG_TRACE 00400 |
| #define | REG_LARGE 01000 |
| #define | REG_BACKR 02000 |
Typedefs | |
| typedef off_t | regoff_t |
Functions | |
| int | my_regcomp (my_regex_t *, const char *, int, CHARSET_INFO *charset) |
| size_t | my_regerror (int, const my_regex_t *, char *, size_t) |
| int | my_regexec (const my_regex_t *, const char *, size_t, my_regmatch_t[], int) |
| void | my_regfree (my_regex_t *) |
| void | my_regex_init (CHARSET_INFO *cs) |
| void | my_regex_end (void) |
| #define _REGEX_H_ |
Definition at line 2 of file my_regex.h.
| #define REG_ASSERT 15 |
| #define REG_ATOI 255 |
| #define REG_BACKR 02000 |
| #define REG_BADBR 10 |
| #define REG_BADPAT 2 |
| #define REG_BADRPT 13 |
| #define REG_BASIC 0000 |
Definition at line 32 of file my_regex.h.
| #define REG_DUMP 0200 |
Definition at line 39 of file my_regex.h.
| #define REG_EBRACE 9 |
| #define REG_EBRACK 7 |
Definition at line 49 of file my_regex.h.
Referenced by p_b_coll_elem(), p_b_symbol(), p_b_term(), and p_bracket().
| #define REG_ECOLLATE 3 |
Definition at line 45 of file my_regex.h.
Referenced by p_b_coll_elem(), p_b_symbol(), and p_b_term().
| #define REG_ECTYPE 4 |
| #define REG_EESCAPE 5 |
| #define REG_EMPTY 14 |
| #define REG_EPAREN 8 |
| #define REG_ERANGE 11 |
| #define REG_ESPACE 12 |
Definition at line 54 of file my_regex.h.
Referenced by allocset(), enlarge(), matcher(), my_regcomp(), and stripsnug().
| #define REG_ESUBREG 6 |
| #define REG_EXTENDED 0001 |
Definition at line 33 of file my_regex.h.
Referenced by init_re_comp(), my_regcomp(), options(), reg_replace(), regress(), and rx_try().
| #define REG_ICASE 0002 |
Definition at line 34 of file my_regex.h.
Referenced by init_re_comp(), options(), ordinary(), p_bracket(), and reg_replace().
| #define REG_INVARG 16 |
| #define REG_ITOA 0400 |
Definition at line 60 of file my_regex.h.
Referenced by eprint(), my_regerror(), re_eprint(), and regress().
| #define REG_LARGE 01000 |
| #define REG_NEWLINE 0010 |
Definition at line 36 of file my_regex.h.
Referenced by backref(), fast(), options(), p_bracket(), p_ere_exp(), p_simp_re(), and slow().
| #define REG_NOMATCH 1 |
Definition at line 43 of file my_regex.h.
Referenced by match_re(), matcher(), reg_replace(), and rx_try().
| #define REG_NOSPEC 0020 |
| #define REG_NOSUB 0004 |
Definition at line 35 of file my_regex.h.
Referenced by init_re_comp(), main(), matcher(), options(), and rx_try().
| #define REG_NOTBOL 00001 |
Definition at line 66 of file my_regex.h.
Referenced by backref(), fast(), options(), reg_replace(), and slow().
| #define REG_NOTEOL 00002 |
| #define REG_PEND 0040 |
| #define REG_STARTEND 00004 |
| #define REG_TRACE 00400 |
Definition at line 14 of file my_regex.h.
| int my_regcomp | ( | my_regex_t * | , | |
| const char * | , | |||
| int | , | |||
| CHARSET_INFO * | charset | |||
| ) |
Definition at line 103 of file regcomp.c.
References re_guts::backrefs, BAD, re_guts::categories, categorize(), re_guts::catspace, re_guts::cflags, charset, re_guts::csetsize, EMIT, findmust(), re_guts::firststate, free, parse::g, GOODFLAGS, re_guts::iflags, re_guts::laststate, re_guts::magic, MAGIC1, MAGIC2, malloc, memset, re_guts::mlen, re_guts::must, my_regex_init(), my_regfree(), re_guts::nbol, NC, re_guts::ncategories, re_guts::ncsets, re_guts::neol, NPAREN, re_guts::nplus, re_guts::nsub, NULL, OEND, OUT, p, p_bre(), p_ere(), p_str(), pluscount(), REG_ASSERT, REG_ESPACE, REG_EXTENDED, REG_INVARG, REG_NOSPEC, REG_PEND, re_guts::setbits, SETERROR, re_guts::sets, stripsnug(), strlen(), and THERE.
Referenced by init_re_comp(), main(), reg_replace(), and rx_try().
00108 { 00109 struct parse pa; 00110 register struct re_guts *g; 00111 register struct parse *p = &pa; 00112 register int i; 00113 register size_t len; 00114 #ifdef REDEBUG 00115 # define GOODFLAGS(f) (f) 00116 #else 00117 # define GOODFLAGS(f) ((f)&~REG_DUMP) 00118 #endif 00119 00120 my_regex_init(charset); /* Init cclass if neaded */ 00121 preg->charset=charset; 00122 cflags = GOODFLAGS(cflags); 00123 if ((cflags®_EXTENDED) && (cflags®_NOSPEC)) 00124 return(REG_INVARG); 00125 00126 if (cflags®_PEND) { 00127 if (preg->re_endp < pattern) 00128 return(REG_INVARG); 00129 len = preg->re_endp - pattern; 00130 } else 00131 len = strlen((char *)pattern); 00132 00133 /* do the mallocs early so failure handling is easy */ 00134 g = (struct re_guts *)malloc(sizeof(struct re_guts) + 00135 (NC-1)*sizeof(cat_t)); 00136 if (g == NULL) 00137 return(REG_ESPACE); 00138 p->ssize = (long) (len/(size_t)2*(size_t)3 + (size_t)1); /* ugh */ 00139 p->strip = (sop *)malloc(p->ssize * sizeof(sop)); 00140 p->slen = 0; 00141 if (p->strip == NULL) { 00142 free((char *)g); 00143 return(REG_ESPACE); 00144 } 00145 00146 /* set things up */ 00147 p->g = g; 00148 p->next = (char *)pattern; /* convenience; we do not modify it */ 00149 p->end = p->next + len; 00150 p->error = 0; 00151 p->ncsalloc = 0; 00152 p->charset = preg->charset; 00153 for (i = 0; i < NPAREN; i++) { 00154 p->pbegin[i] = 0; 00155 p->pend[i] = 0; 00156 } 00157 g->csetsize = NC; 00158 g->sets = NULL; 00159 g->setbits = NULL; 00160 g->ncsets = 0; 00161 g->cflags = cflags; 00162 g->iflags = 0; 00163 g->nbol = 0; 00164 g->neol = 0; 00165 g->must = NULL; 00166 g->mlen = 0; 00167 g->nsub = 0; 00168 g->ncategories = 1; /* category 0 is "everything else" */ 00169 g->categories = &g->catspace[-(CHAR_MIN)]; 00170 (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); 00171 g->backrefs = 0; 00172 00173 /* do it */ 00174 EMIT(OEND, 0); 00175 g->firststate = THERE(); 00176 if (cflags®_EXTENDED) 00177 p_ere(p, OUT); 00178 else if (cflags®_NOSPEC) 00179 p_str(p); 00180 else 00181 p_bre(p, OUT, OUT); 00182 EMIT(OEND, 0); 00183 g->laststate = THERE(); 00184 00185 /* tidy up loose ends and fill things in */ 00186 categorize(p, g); 00187 stripsnug(p, g); 00188 findmust(p, g); 00189 g->nplus = pluscount(p, g); 00190 g->magic = MAGIC2; 00191 preg->re_nsub = g->nsub; 00192 preg->re_g = g; 00193 preg->re_magic = MAGIC1; 00194 #ifndef REDEBUG 00195 /* not debugging, so can't rely on the assert() in regexec() */ 00196 if (g->iflags&BAD) 00197 SETERROR(REG_ASSERT); 00198 #endif 00199 00200 /* win or lose, we're done */ 00201 if (p->error != 0) /* lose */ 00202 my_regfree(preg); 00203 return(p->error); 00204 }
Here is the call graph for this function:

Here is the caller graph for this function:

| size_t my_regerror | ( | int | , | |
| const my_regex_t * | , | |||
| char * | , | |||
| size_t | ||||
| ) |
Definition at line 59 of file regerror.c.
References assert, rerr::code, rerr::explain, rerr::name, REG_ATOI, REG_ITOA, regatoi(), rerrs, and strlen().
Referenced by check_regerr(), efind(), eprint(), init_re_comp(), main(), match_re(), re_eprint(), regress(), and rx_try().
00060 { 00061 register struct rerr *r; 00062 register size_t len; 00063 register int target = errcode &~ REG_ITOA; 00064 register char *s; 00065 char convbuf[50]; 00066 00067 if (errcode == REG_ATOI) 00068 s = regatoi(preg, convbuf); 00069 else { 00070 for (r = rerrs; r->code != 0; r++) 00071 if (r->code == target) 00072 break; 00073 00074 if (errcode®_ITOA) { 00075 if (r->code != 0) 00076 (void) strcpy(convbuf, r->name); 00077 else 00078 sprintf(convbuf, "REG_0x%x", target); 00079 assert(strlen(convbuf) < sizeof(convbuf)); 00080 s = convbuf; 00081 } else 00082 s = (char*) r->explain; 00083 } 00084 00085 len = strlen(s) + 1; 00086 if (errbuf_size > 0) { 00087 if (errbuf_size > len) 00088 (void) strcpy(errbuf, s); 00089 else { 00090 (void) strncpy(errbuf, s, errbuf_size-1); 00091 errbuf[errbuf_size-1] = '\0'; 00092 } 00093 } 00094 00095 return(len); 00096 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void my_regex_end | ( | void | ) |
Definition at line 70 of file reginit.c.
References CCLASS_LAST, cclasses, free, and regex_inited.
Referenced by clean_up(), and free_re().
00071 { 00072 if (regex_inited) 00073 { 00074 int i; 00075 for (i=0; i < CCLASS_LAST ; i++) 00076 free((char*) cclasses[i].chars); 00077 regex_inited=0; 00078 } 00079 }
Here is the caller graph for this function:

| void my_regex_init | ( | CHARSET_INFO * | cs | ) |
Definition at line 10 of file reginit.c.
References bzero, CCLASS_ALNUM, CCLASS_ALPHA, CCLASS_BLANK, CCLASS_CNTRL, CCLASS_DIGIT, CCLASS_GRAPH, CCLASS_LAST, CCLASS_LOWER, CCLASS_PRINT, CCLASS_PUNCT, CCLASS_SPACE, CCLASS_UPPER, CCLASS_XDIGIT, cclasses, cclass::chars, count, exit, malloc, memcpy, my_isalnum, my_isalpha, my_iscntrl, my_isdigit, my_isgraph, my_islower, my_isprint, my_ispunct, my_isspace, my_isupper, my_isxdigit, and regex_inited.
Referenced by init_common_variables(), and my_regcomp().
00011 { 00012 char buff[CCLASS_LAST][256]; 00013 int count[CCLASS_LAST]; 00014 uint i; 00015 00016 if (!regex_inited) 00017 { 00018 regex_inited=1; 00019 bzero((gptr) &count,sizeof(count)); 00020 00021 for (i=1 ; i<= 255; i++) 00022 { 00023 if (my_isalnum(cs,i)) 00024 buff[CCLASS_ALNUM][count[CCLASS_ALNUM]++]=(char) i; 00025 if (my_isalpha(cs,i)) 00026 buff[CCLASS_ALPHA][count[CCLASS_ALPHA]++]=(char) i; 00027 if (my_iscntrl(cs,i)) 00028 buff[CCLASS_CNTRL][count[CCLASS_CNTRL]++]=(char) i; 00029 if (my_isdigit(cs,i)) 00030 buff[CCLASS_DIGIT][count[CCLASS_DIGIT]++]=(char) i; 00031 if (my_isgraph(cs,i)) 00032 buff[CCLASS_GRAPH][count[CCLASS_GRAPH]++]=(char) i; 00033 if (my_islower(cs,i)) 00034 buff[CCLASS_LOWER][count[CCLASS_LOWER]++]=(char) i; 00035 if (my_isprint(cs,i)) 00036 buff[CCLASS_PRINT][count[CCLASS_PRINT]++]=(char) i; 00037 if (my_ispunct(cs,i)) 00038 buff[CCLASS_PUNCT][count[CCLASS_PUNCT]++]=(char) i; 00039 if (my_isspace(cs,i)) 00040 buff[CCLASS_SPACE][count[CCLASS_SPACE]++]=(char) i; 00041 if (my_isupper(cs,i)) 00042 buff[CCLASS_UPPER][count[CCLASS_UPPER]++]=(char) i; 00043 if (my_isxdigit(cs,i)) 00044 buff[CCLASS_XDIGIT][count[CCLASS_XDIGIT]++]=(char) i; 00045 } 00046 buff[CCLASS_BLANK][0]=' '; 00047 buff[CCLASS_BLANK][1]='\t'; 00048 count[CCLASS_BLANK]=2; 00049 for (i=0; i < CCLASS_LAST ; i++) 00050 { 00051 char *tmp=(char*) malloc(count[i]+1); 00052 if (!tmp) 00053 { 00054 /* 00055 This is very unlikely to happen as this function is called once 00056 at program startup 00057 */ 00058 fprintf(stderr, 00059 "Fatal error: Can't allocate memory in regex_init\n"); 00060 exit(1); 00061 } 00062 memcpy(tmp,buff[i],count[i]*sizeof(char)); 00063 tmp[count[i]]=0; 00064 cclasses[i].chars=tmp; 00065 } 00066 } 00067 return; 00068 }
Here is the caller graph for this function:

| int my_regexec | ( | const my_regex_t * | , | |
| const char * | , | |||
| size_t | , | |||
| my_regmatch_t | [], | |||
| int | ||||
| ) |
Referenced by main(), match_re(), reg_replace(), and rx_try().
Here is the caller graph for this function:

| void my_regfree | ( | my_regex_t * | ) |
Definition at line 15 of file regfree.c.
References free, re_guts::magic, MAGIC1, MAGIC2, re_guts::must, NULL, re_guts::setbits, re_guts::sets, and re_guts::strip.
Referenced by free_re(), main(), my_regcomp(), reg_replace(), and rx_try().
00017 { 00018 register struct re_guts *g; 00019 00020 if (preg->re_magic != MAGIC1) /* oops */ 00021 return; /* nice to complain, but hard */ 00022 00023 g = preg->re_g; 00024 if (g == NULL || g->magic != MAGIC2) /* oops again */ 00025 return; 00026 preg->re_magic = 0; /* mark it invalid */ 00027 g->magic = 0; /* mark it invalid */ 00028 00029 if (g->strip != NULL) 00030 free((char *)g->strip); 00031 if (g->sets != NULL) 00032 free((char *)g->sets); 00033 if (g->setbits != NULL) 00034 free((char *)g->setbits); 00035 if (g->must != NULL) 00036 free(g->must); 00037 free((char *)g); 00038 }
Here is the caller graph for this function:

1.4.7

