home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / lib / libc / src / strpbrk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.2 KB  |  88 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "plstr.h"
  20.  
  21. PR_IMPLEMENT(char *)
  22. PL_strpbrk(const char *s, const char *list)
  23. {
  24.     const char *p;
  25.  
  26.     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
  27.  
  28.     for( ; *s; s++ )
  29.         for( p = list; *p; p++ )
  30.             if( *s == *p )
  31.                 return (char *)s;
  32.  
  33.     return (char *)0;
  34. }
  35.  
  36. PR_IMPLEMENT(char *)
  37. PL_strprbrk(const char *s, const char *list)
  38. {
  39.     const char *p;
  40.     const char *r;
  41.  
  42.     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
  43.  
  44.     for( r = s; *r; r++ )
  45.         ;
  46.  
  47.     for( r--; r >= s; r-- )
  48.         for( p = list; *p; p++ )
  49.             if( *r == *p )
  50.                 return (char *)r;
  51.  
  52.     return (char *)0;
  53. }
  54.  
  55. PR_IMPLEMENT(char *)
  56. PL_strnpbrk(const char *s, const char *list, PRUint32 max)
  57. {
  58.     const char *p;
  59.  
  60.     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
  61.  
  62.     for( ; *s && max; s++, max-- )
  63.         for( p = list; *p; p++ )
  64.             if( *s == *p )
  65.                 return (char *)s;
  66.  
  67.     return (char *)0;
  68. }
  69.  
  70. PR_IMPLEMENT(char *)
  71. PL_strnprbrk(const char *s, const char *list, PRUint32 max)
  72. {
  73.     const char *p;
  74.     const char *r;
  75.  
  76.     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
  77.  
  78.     for( r = s; *r && max; r++, max-- )
  79.         ;
  80.  
  81.     for( r--; r >= s; r-- )
  82.         for( p = list; *p; p++ )
  83.             if( *r == *p )
  84.                 return (char *)r;
  85.  
  86.     return (char *)0;
  87. }
  88.