home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 216.lha / EdLib_v1.0 / strtok.c < prev    next >
C/C++ Source or Header  |  1996-02-15  |  552b  |  25 lines

  1. /* edlib  version 1.0 of 04/08/88 */
  2. #define STRING_END    '\0'
  3. #ifndef NULL
  4. #define NULL    0L
  5. #endif
  6.  
  7. char *strtok(buf, separators)
  8. char *buf, *separators;
  9. {
  10.     register char *token, *end;    /* Start and end of token. */
  11.     extern char *strpbrk();
  12.     static char *fromLastTime;
  13.  
  14.     if (token = buf ? buf : fromLastTime) {
  15.         token += strspn(token, separators);    /* Find token! */
  16.         if (*token == STRING_END)
  17.             return(NULL);
  18.         fromLastTime = ((end = strpbrk(token,separators))
  19.                 ? &end[1]
  20.                 : NULL);
  21.         *end = STRING_END;            /* Cut it short! */
  22.     }
  23.     return(token);
  24. }
  25.