Changeset 445
- Timestamp:
- 08/13/07 19:56:32 (1 year ago)
- Files:
-
- ondir/trunk/ondir.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ondir/trunk/ondir.c
r333 r445 16 16 int add_envar(const char *var, const char *val); 17 17 int 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]); 18 struct odpath_t *find_path(struct odpath_t *last, const char *path, pathtype_t type, regmatch_t match[10]); 21 19 void usage(const char *msg); 22 20 … … 82 80 while (strncmp(working, dst, len)) { 83 81 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)) { 87 85 char *sub; 88 86 … … 109 107 } 110 108 printf("%s\n", sub); 111 free (sub);109 free(sub); 112 110 } 113 111 #ifdef USE_ONENTERLEAVE … … 132 130 strncpy(working, dst, len); 133 131 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)) { 135 133 char *sub; 136 134 int i = 0; … … 248 246 } 249 247 250 struct odpath_t *find_path( const char *path, pathtype_t type, regmatch_t match[10]) {248 struct odpath_t *find_path(struct odpath_t *last, const char *path, pathtype_t type, regmatch_t match[10]) { 251 249 struct odpath_t *i; 252 250 int j; 253 251 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) 255 258 if (i->type == type) { 256 259 for (j = 0; j < i->npaths; ++j) … … 301 304 } 302 305 #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 }311 306 312 307 void usage(const char *msg) {
