home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / unixlib36d / UnixLib36d / src / c / strtok < prev    next >
Encoding:
Text File  |  1994-03-08  |  604 b   |  41 lines

  1. #ifdef __STDC__
  2. static char sccs_id[] = "@(#) strtok.c 1.1 " __DATE__ " HJR";
  3. #else
  4. static char sccs_id[] = "@(#) strtok.c 1.1 26/9/90 HJR";
  5. #endif
  6.  
  7. /* strtok.c (c) Copyright 1990 H.Rogers */
  8.  
  9. #ifndef __STDC__
  10. #include "sys/types.h"
  11. #endif
  12. #include <string.h>
  13.  
  14. #ifdef __STDC__
  15. char *
  16. strtok (register char *s1, register const char *s2)
  17. #else
  18. char *
  19. strtok (s1, s2)
  20.      register char *s1;
  21.      register const char *s2;
  22. #endif
  23. {
  24.   static char *s;
  25.  
  26.   if (!s1)
  27.     {
  28.       if (!s)
  29.     return (0);
  30.       else
  31.     s1 = s;
  32.     }
  33.  
  34.   s1 += strspn (s1, s2);
  35.  
  36.   if (s = strpbrk (s1, s2))
  37.     *s++ = 0;
  38.  
  39.   return (s1);
  40. }
  41.