home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / gnu / mntlib16.lzh / MNTLIB16 / STRCHR.C < prev    next >
C/C++ Source or Header  |  1993-07-29  |  670b  |  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__(".text; .even; .globl _index; _index:"); /* dept of dirty tricks */
  10. #else
  11. char *
  12. index(s, charwanted)
  13.     const char *s;
  14.     char 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 char 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++) != charwanted)
  31.         if (c == 0) return NULL;
  32.     return((char *)--s);
  33. }
  34.