missing/strchr.c


DEFINITIONS

This source file includes following functions.
  1. strchr
  2. strrchr


   1  /* public domain rewrite of strchr(3) and strrchr(3) */
   2  
   3  char *
   4  strchr(s, c)
   5      char *s;
   6      int c;
   7  {
   8      if (c == 0) return s + strlen(s);
   9      while (*s) {
  10          if (*s == c)
  11              return s;
  12          s++;
  13      }
  14      return 0;
  15  }
  16  
  17  char *
  18  strrchr(s, c)
  19      char *s;
  20      int c;
  21  {
  22      char *save = 0;
  23  
  24      while (*s) {
  25          if (*s == c)
  26              save = s;
  27          s++;
  28      }
  29      return save;
  30  }