|
|
1.1 ! root 1: /* ! 2: * transname - take a pathname, expand it, and translate it ! 3: * according to the replist. The result is in a buffer ! 4: * that will stay around no longer than the next call ! 5: * to transname. If no translation, transname will ! 6: * just return fullname applied to its argument. ! 7: */ ! 8: ! 9: #include "asd.h" ! 10: ! 11: char * ! 12: transname (s) ! 13: register char *s; ! 14: { ! 15: register struct replist *rl; ! 16: static char *res; ! 17: static int size; ! 18: register int n; ! 19: ! 20: s = fullname (s); ! 21: ! 22: /* look for substitution */ ! 23: for (rl = replist; rl; rl = rl->link) { ! 24: register char *p = rl->source; ! 25: register char *q = s; ! 26: ! 27: /* comparison loop */ ! 28: while (*p != '\0' && *p == *q) { ! 29: p++; ! 30: q++; ! 31: } ! 32: ! 33: if (*p == '\0') { ! 34: /* comparison successful */ ! 35: n = strlen (rl->dest) + strlen (q) + 1; ! 36: if (n > size) { ! 37: size = n; ! 38: res = ralloc (res, (unsigned) n); ! 39: } ! 40: strcpy (res, rl->dest); ! 41: strcat (res, q); ! 42: return res; ! 43: } ! 44: } ! 45: ! 46: /* search loop failed, return expanded input */ ! 47: return s; ! 48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.