|
|
1.1 ! root 1: /* $Header: pathcat.c,v 1.2 85/03/17 15:23:03 nicklin Exp $ */ ! 2: ! 3: /* ! 4: * Author: Peter J. Nicklin ! 5: */ ! 6: ! 7: /* ! 8: * pathcat() concatenates path components p1 and p2 into character buffer ! 9: * p1_p2. Returns p1_p2. ! 10: */ ! 11: #include <stdio.h> ! 12: #include "path.h" ! 13: ! 14: extern char *PGN; /* program name */ ! 15: ! 16: char * ! 17: pathcat(p1_p2, p1, p2) ! 18: register char *p1; ! 19: register char *p2; ! 20: register char *p1_p2; ! 21: { ! 22: register int plen; /* maximum pathname length */ ! 23: char *sp1_p2; /* start of p1_p2 */ ! 24: ! 25: sp1_p2 = p1_p2; ! 26: for (plen = PATHSIZE; plen > 0; plen--, p1_p2++, p1++) ! 27: if ((*p1_p2 = *p1) == '\0') ! 28: break; ! 29: if (*p2 != '\0' && plen > 0) ! 30: { ! 31: if (p1_p2 != sp1_p2 && p1_p2[-1] != _PSC) ! 32: { ! 33: *p1_p2++ = _PSC; ! 34: plen--; ! 35: } ! 36: for (; plen > 0; plen--, p1_p2++, p2++) ! 37: if ((*p1_p2 = *p2) == '\0') ! 38: break; ! 39: } ! 40: if (plen == 0) ! 41: { ! 42: *--p1_p2 = '\0'; ! 43: if (*PGN != '\0') ! 44: fprintf(stderr, "%s: ", PGN); ! 45: fprintf(stderr, "pathname too long\n"); ! 46: } ! 47: return(sp1_p2); ! 48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.