home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / string / strsep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-02  |  486 b   |  33 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <string.h>
  3.  
  4. char *
  5. strsep(char **stringp, const char *delim)
  6. {
  7.   char *s;
  8.   const char *spanp;
  9.   int c, sc;
  10.   char *tok;
  11.  
  12.   if ((s = *stringp) == 0)
  13.     return 0;
  14.  
  15.   tok = s;
  16.   while (1)
  17.   {
  18.     c = *s++;
  19.     spanp = delim;
  20.     do {
  21.       if ((sc = *spanp++) == c)
  22.       {
  23.     if (c == 0)
  24.       s = 0;
  25.     else
  26.       s[-1] = 0;
  27.     *stringp = s;
  28.     return tok;
  29.       }
  30.     } while (sc != 0);
  31.   }
  32. }
  33.