Changeset 445

Show
Ignore:
Timestamp:
08/13/07 19:56:32 (1 year ago)
Author:
athomas
Message:

On Dir: All enter/leave blocks whose patterns match will execute, in order.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ondir/trunk/ondir.c

    r333 r445  
    1616int add_envar(const char *var, const char *val); 
    1717int check_regex(const char *regex, const char *line, regmatch_t match[10]); 
    18 struct odpath_t *find_path(const char *path, pathtype_t type, regmatch_t match[10]); 
    19 struct odpath_t *find_enter(const char *path, regmatch_t match[10]); 
    20 struct odpath_t *find_leave(const char *path, regmatch_t match[10]); 
     18struct odpath_t *find_path(struct odpath_t *last, const char *path, pathtype_t type, regmatch_t match[10]); 
    2119void usage(const char *msg); 
    2220 
     
    8280        while (strncmp(working, dst, len)) { 
    8381        regmatch_t match[10]; 
    84         struct odpath_t *p = find_leave(working, match)
    85  
    86                 if (p) { 
     82        struct odpath_t *p
     83 
     84                for (p = find_path(NULL, working, PT_LEAVE, match); p; p = find_path(p, working, PT_LEAVE, match)) { 
    8785                char *sub; 
    8886 
     
    109107                        } 
    110108                        printf("%s\n", sub); 
    111                         free (sub); 
     109                        free(sub); 
    112110                } 
    113111#ifdef USE_ONENTERLEAVE 
     
    132130                strncpy(working, dst, len); 
    133131                working[len] = 0; 
    134                 if ((p = find_enter(working, match))) { 
     132                for (p = find_path(NULL, working, PT_ENTER, match); p; p = find_path(p, working, PT_ENTER, match)) { 
    135133                char *sub; 
    136134                int i = 0; 
     
    248246} 
    249247 
    250 struct odpath_t *find_path(const char *path, pathtype_t type, regmatch_t match[10]) { 
     248struct odpath_t *find_path(struct odpath_t *last, const char *path, pathtype_t type, regmatch_t match[10]) { 
    251249struct odpath_t *i; 
    252250int j; 
    253251 
    254         for (i = root; i != NULL; i = i->next) 
     252        if (last) 
     253                last = last->next; 
     254        else 
     255                last = root; 
     256 
     257        for (i = last; i != NULL; i = i->next) 
    255258                if (i->type == type) { 
    256259                        for (j = 0; j < i->npaths; ++j) 
     
    301304} 
    302305#endif 
    303  
    304 struct odpath_t *find_enter(const char *path, regmatch_t match[10]) { 
    305         return find_path(path, PT_ENTER, match); 
    306 } 
    307  
    308 struct odpath_t *find_leave(const char *path, regmatch_t match[10]) { 
    309         return find_path(path, PT_LEAVE, match); 
    310 } 
    311306 
    312307void usage(const char *msg) {