Changeset 323 for trunk/kernel


Ignore:
Timestamp:
Aug 6, 2017, 8:33:00 AM (7 years ago)
Author:
max@…
Message:

Clean up, and define strstr() in libk.

Location:
trunk/kernel/libk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/string.c

    r288 r323  
    125125}
    126126
     127////////////////////////////////
     128char * strstr( char       * s,
     129               const char * find)
     130{
     131    char c, sc;
     132    size_t len;
     133
     134    if ((c = *find++) != 0) {
     135        len = strlen(find);
     136        do {
     137            do {
     138                if ((sc = *s++) == 0)
     139                    return NULL;
     140            } while (sc != c);
     141        } while (strncmp(s, find, len) != 0);
     142        s--;
     143    }
     144    return s;
     145}
     146
    127147//////////////////////////////
    128148char * strchr( const char * s,
  • trunk/kernel/libk/string.h

    r238 r323  
    103103
    104104/********************************************************************************************
     105 * This function locates the first occurence of the <find> string in the <s> string.
     106 ********************************************************************************************
     107 * @ s     : string to be analysed.
     108 * @ find  : searched string
     109 * @ return pointer on the found string / return NULL if not found.
     110 *******************************************************************************************/
     111char * strstr( char       * s,
     112               const char * find);
     113
     114/********************************************************************************************
    105115 * This function locates the first occurence of the <c> character in the <s> string.
    106116 ********************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.