Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2. FUNCTION
  3.         <<strchrnul>>---search for character in string
  4.  
  5. INDEX
  6.         strchrnul
  7.  
  8. ANSI_SYNOPSIS
  9.         #include <string.h>
  10.         char * strchrnul(const char *<[string]>, int <[c]>);
  11.  
  12. TRAD_SYNOPSIS
  13.         #include <string.h>
  14.         char * strchrnul(<[string]>, <[c]>);
  15.         const char *<[string]>;
  16.         int <[c]>;
  17.  
  18. DESCRIPTION
  19.         This function finds the first occurence of <[c]> (converted to
  20.         a char) in the string pointed to by <[string]> (including the
  21.         terminating null character).
  22.  
  23. RETURNS
  24.         Returns a pointer to the located character, or a pointer
  25.         to the concluding null byte if <[c]> does not occur in <[string]>.
  26.  
  27. PORTABILITY
  28. <<strchrnul>> is a GNU extension.
  29.  
  30. <<strchrnul>> requires no supporting OS subroutines.  It uses
  31. strchr() and strlen() from elsewhere in this library.
  32.  
  33. QUICKREF
  34.         strchrnul
  35. */
  36.  
  37. #include <string.h>
  38.  
  39. char *
  40. _DEFUN (strchrnul, (s1, i),
  41.         _CONST char *s1 _AND
  42.         int i)
  43. {
  44.   char *s = strchr(s1, i);
  45.  
  46.   return s ? s : (char *)s1 + strlen(s1);
  47. }
  48.