Annotation of researchv10no/cmd/gre/egcw.c, revision 1.1.1.1

1.1       root        1: #include       "re.h"
                      2: #include       "lre.h"
                      3: #include       "hdr.h"
                      4: 
                      5: static altlist(Expr*, unsigned char *);
                      6: static word(Expr*, unsigned char*);
                      7: static re_cw *pat;
                      8: 
                      9: re_cw *
                     10: re_recw(re_re *r, unsigned char *map)
                     11: {
                     12:        unsigned char buf[20000];
                     13:        register Expr *e, *root = r->root;
                     14: 
                     15:        if(root->type != EOP)
                     16:                return(0);
                     17:        if(root->l->type != Cat)
                     18:                return(0);
                     19:        if(root->l->l->type != Star)
                     20:                return(0);
                     21:        if(root->l->l->l->type != Dot)
                     22:                return(0);
                     23:        e = root->l->r;
                     24:        pat = re_cwinit(map);
                     25:        if(altlist(e, buf) == 0)
                     26:                return(0);
                     27:        re_cwcomp(pat);
                     28:        return(pat);
                     29: }
                     30: 
                     31: static
                     32: altlist(Expr *e, unsigned char *buf)
                     33: {
                     34:        if(e->type == Alternate)
                     35:                return(altlist(e->l, buf) && altlist(e->r, buf));
                     36:        return(word(e, buf));
                     37: }
                     38: 
                     39: static unsigned char *p;
                     40: 
                     41: static
                     42: word(Expr *e, unsigned char *buf)
                     43: {
                     44:        if(buf)
                     45:                p = buf;
                     46:        if(e->type == Cat){
                     47:                if(word(e->l, (unsigned char *)0) == 0)
                     48:                        return(0);
                     49:                if(word(e->r, (unsigned char *)0) == 0)
                     50:                        return(0);
                     51:        } else if(e->type == Literal)
                     52:                *p++ = e->lit;
                     53:        else
                     54:                return(0);
                     55:        if(buf)
                     56:                re_cwadd(pat, buf, p);
                     57:        return(1);
                     58: }
                     59: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.