| 
            Last change
 on this file was             2, checked in by bird, 23 years ago           | 
        
        
          | 
             
Initial revision 
 
           | 
        
        
          
            
              - 
Property                 cvs2svn:cvs-rev
 set to                 
1.1
               
              - 
Property                 svn:eol-style
 set to                 
native
               
              - 
Property                 svn:executable
 set to                 
*
               
             
           | 
        
        
          | 
            File size:
            997 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | /* Simple implementation of strstr for systems without it.
 | 
|---|
| 2 |    This function is in the public domain.  */
 | 
|---|
| 3 | 
 | 
|---|
| 4 | /*
 | 
|---|
| 5 | 
 | 
|---|
| 6 | @deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
 | 
|---|
| 7 | 
 | 
|---|
| 8 | This function searches for the substring @var{sub} in the string
 | 
|---|
| 9 | @var{string}, not including the terminating null characters.  A pointer
 | 
|---|
| 10 | to the first occurrence of @var{sub} is returned, or @code{NULL} if the
 | 
|---|
| 11 | substring is absent.  If @var{sub} points to a string with zero
 | 
|---|
| 12 | length, the function returns @var{string}.
 | 
|---|
| 13 | 
 | 
|---|
| 14 | @end deftypefn
 | 
|---|
| 15 | 
 | 
|---|
| 16 | 
 | 
|---|
| 17 | */
 | 
|---|
| 18 | 
 | 
|---|
| 19 | 
 | 
|---|
| 20 | /* FIXME:  The above description is ANSI compiliant.  This routine has not
 | 
|---|
| 21 |    been validated to comply with it.  -fnf */
 | 
|---|
| 22 | 
 | 
|---|
| 23 | char *
 | 
|---|
| 24 | strstr (s1, s2)
 | 
|---|
| 25 |   char *s1, *s2;
 | 
|---|
| 26 | {
 | 
|---|
| 27 |   register char *p = s1;
 | 
|---|
| 28 |   extern char *strchr ();
 | 
|---|
| 29 |   extern int strncmp ();
 | 
|---|
| 30 | #if __GNUC__==2
 | 
|---|
| 31 |   extern __SIZE_TYPE__ strlen ();
 | 
|---|
| 32 | #endif
 | 
|---|
| 33 |   register int len = strlen (s2);
 | 
|---|
| 34 | 
 | 
|---|
| 35 |   for (; (p = strchr (p, *s2)) != 0; p++)
 | 
|---|
| 36 |     {
 | 
|---|
| 37 |       if (strncmp (p, s2, len) == 0)
 | 
|---|
| 38 |         {
 | 
|---|
| 39 |           return (p);
 | 
|---|
| 40 |         }
 | 
|---|
| 41 |     }
 | 
|---|
| 42 |   return (0);
 | 
|---|
| 43 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.