home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 400-499 / ff473.lzh / CNewsSrc / cnews_src.lzh / libcnews / str3save.c < prev    next >
C/C++ Source or Header  |  1990-12-25  |  618b  |  34 lines

  1. #include <stdio.h>
  2. #ifdef unix
  3. # include <sys/types.h>
  4. #endif /* unix */
  5. #include "libc.h"
  6. #include "news.h"
  7.  
  8. /*
  9.  - str3save - malloc space for 3 strings, concatenated, and concatenate them
  10.  * This may seem kind of ad-hoc, but it's just right for filename work.
  11.  */
  12. char *
  13. str3save(s1, s2, s3)
  14. char *s1;
  15. char *s2;
  16. char *s3;
  17. {
  18.     register char *p;
  19.     static char *empty = "";
  20.  
  21.     if (s1 == NULL)
  22.         s1 = empty;
  23.     if (s2 == NULL)
  24.         s2 = empty;
  25.     if (s3 == NULL)
  26.         s3 = empty;
  27.  
  28.     p = nemalloc((unsigned)(strlen(s1) + strlen(s2) + strlen(s3) + 1));
  29.     (void) strcpy(p, s1);
  30.     (void) strcat(p, s2);
  31.     (void) strcat(p, s3);
  32.     return(p);
  33. }
  34.