home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / strchr.c < prev    next >
C/C++ Source or Header  |  1993-05-23  |  646b  |  34 lines

  1. /* from Henry Spencer's stringlib */
  2. /* modified by ERS */
  3. #include <string.h>
  4.  
  5. /*
  6.  * strchr - find first occurrence of a character in a string
  7.  */
  8. #ifdef __GNUC__
  9. asm(".stabs \"_index\",5,0,0,_strchr"); /* dept of clean tricks */
  10. #else
  11. char *
  12. index(s, charwanted)
  13.       const char *s;
  14.       int charwanted;
  15. {
  16.       return strchr(s, charwanted);
  17. }
  18. #endif
  19.  
  20. char *                /* found char, or NULL if none */
  21. strchr(s, charwanted)
  22. const char *s;
  23. register int charwanted;
  24. {
  25.     register char c;
  26.  
  27.     /*
  28.      * The odd placement of the two tests is so NUL is findable.
  29.      */
  30.     while ((c = *s++) != (char) charwanted)
  31.         if (c == 0) return NULL;
  32.     return((char *)--s);
  33. }
  34.