1: /* $Header$ */
   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: char *
  15: pathcat(p1_p2, p1, p2)
  16:     register char *p1;
  17:     register char *p2;
  18:     register char *p1_p2;
  19: {
  20:     register int plen;      /* maximum pathname length */
  21:     char *sp1_p2;           /* start of p1_p2 */
  22: 
  23:     sp1_p2 = p1_p2;
  24:     for (plen = PATHSIZE; plen > 0; plen--, p1_p2++, p1++)
  25:         if ((*p1_p2 = *p1) == '\0')
  26:             break;
  27:     if (*p2 != '\0' && plen > 0)
  28:         {
  29:         if (p1_p2 != sp1_p2 && p1_p2[-1] != _PSC)
  30:             {
  31:             *p1_p2++ = _PSC;
  32:             plen--;
  33:             }
  34:         for (; plen > 0; plen--, p1_p2++, p2++)
  35:             if ((*p1_p2 = *p2) == '\0')
  36:                 break;
  37:         }
  38:     if (plen == 0)
  39:         {
  40:         *--p1_p2 = '\0';
  41:         warn("pathname too long");
  42:         }
  43:     return(sp1_p2);
  44: }

Defined functions

Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 528
Valid CSS Valid XHTML 1.0 Strict