|
|
1.1 ! root 1: /* ! 2: * fullname -- return the full pathname corresponding to the ! 3: * abbreviated pathname given as argument. Returned value ! 4: * is in a buffer that will stay around no longer than its ! 5: * argument or the next call to fullname, whichever is earlier. ! 6: */ ! 7: ! 8: #include "asd.h" ! 9: ! 10: char * ! 11: fullname (s) ! 12: register char *s; ! 13: { ! 14: register char *t; ! 15: static char *r; ! 16: static int size; ! 17: register unsigned n; ! 18: ! 19: /* if first char is slash, absolute path */ ! 20: if (s[0] == '/') ! 21: return s; ! 22: ! 23: /* strip leading './' */ ! 24: while (s[0] == '.' && s[1] == '/') ! 25: s += 2; ! 26: ! 27: t = pwd(); ! 28: ! 29: /* null string or "." means current directory */ ! 30: if (s[0] == '\0' || strcmp (s, ".") == 0) ! 31: return t; ! 32: ! 33: n = strlen (s) + strlen (t) + 2; ! 34: if (n > size) { ! 35: r = ralloc (r, n); ! 36: size = n; ! 37: } ! 38: ! 39: strcpy (r, t); ! 40: strcat (r, "/"); ! 41: strcat (r, s); ! 42: ! 43: return r; ! 44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.