/[anubis]/anubis/src/regex.c
ViewVC logotype

Diff of /anubis/src/regex.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by gray, Sun Jun 29 15:02:34 2003 UTC revision 1.14 by gray, Mon Jun 30 18:17:03 2003 UTC
# Line 103  regex_vtab_lookup(int flags) Line 103  regex_vtab_lookup(int flags)
103    
104    
105  /* ************************** Interface Functions ************************** */  /* ************************** Interface Functions ************************** */
106    #define ASSERT_RE(re,vp) \
107     if (!(re) || (vp = regex_vtab_lookup((re)->flags)) == NULL) {\
108            anubis_error(HARD,\
109                        _("INTERNAL ERROR at %s:%d: missing or invalid regex"),\
110                        __FILE__, __LINE__);\
111                    abort();\
112     }
113    
114  void  void
115  regex_print_flags(int flags)  regex_print_flags(int flags)
116  {  {
# Line 133  anubis_regex_match(RC_REGEX *re, char *l Line 141  anubis_regex_match(RC_REGEX *re, char *l
141          int so, eo;          int so, eo;
142          struct regex_vtab *vp;          struct regex_vtab *vp;
143    
144          if (!re)          ASSERT_RE(re, vp);
                 return -1;  
         vp = regex_vtab_lookup(re->flags);  
         if (!vp)  
                 return -1;  
145          return vp->match(re, line, refc, refv, &so, &eo) == 0;          return vp->match(re, line, refc, refv, &so, &eo) == 0;
146  }  }
147    
# Line 154  anubis_regex_replace(RC_REGEX *re, char Line 158  anubis_regex_replace(RC_REGEX *re, char
158          int alloc = 0;          int alloc = 0;
159          struct regex_vtab *vp;          struct regex_vtab *vp;
160    
161          if (!re)          ASSERT_RE(re, vp);
                 return NULL;  
         vp = regex_vtab_lookup(re->flags);  
         if (!vp)  
                 return NULL;  
162          while (vp->match(re, line + off, &refc, &refv, &so, &eo) == 0) {          while (vp->match(re, line + off, &refc, &refv, &so, &eo) == 0) {
163                  char *p;                  char *p;
164                  int plen;                  int plen;
# Line 202  anubis_regex_refcnt(RC_REGEX *re) Line 202  anubis_regex_refcnt(RC_REGEX *re)
202  {  {
203          struct regex_vtab *vp;          struct regex_vtab *vp;
204    
205          if (!re)          ASSERT_RE(re, vp);
                 return 0;  
         vp = regex_vtab_lookup(re->flags);  
         if (!vp)  
                 return 0;  
206          return vp->refcnt(re);          return vp->refcnt(re);
207  }  }
208    
# Line 215  anubis_regex_compile(char *line, int opt Line 211  anubis_regex_compile(char *line, int opt
211  {  {
212          struct regex_vtab *vp = regex_vtab_lookup(opt);          struct regex_vtab *vp = regex_vtab_lookup(opt);
213          RC_REGEX *p;          RC_REGEX *p;
214            
215          if (!vp)          if (!vp)
216                  return 0;                  return 0;
217          p = xmalloc(sizeof(*p));          p = xmalloc(sizeof(*p));
# Line 228  anubis_regex_compile(char *line, int opt Line 225  anubis_regex_compile(char *line, int opt
225  }  }
226    
227  void  void
228  anubis_regex_free(RC_REGEX *re)  anubis_regex_free(RC_REGEX **pre)
229  {  {
230          struct regex_vtab *vp;          struct regex_vtab *vp;
231    
232          if (!re)          ASSERT_RE(*pre, vp);
233                  return;          free((*pre)->src);
234          vp = regex_vtab_lookup(re->flags);          vp->free(*pre);
235          free(re->src);          xfree(*pre);
         if (vp)  
                 vp->free(re);  
         xfree(re);  
236  }  }
237    
238  char *  char *

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26