Ignore:
Timestamp:
Sep 3, 2009, 2:38:00 AM (16 years ago)
Author:
[email protected]
Message:

2009-09-03 Fumitoshi Ukai <[email protected]>

Reviewed by Eric Seidel.

Add strnstr for Linux and Windows in StringExtras.h
https://bugs.webkit.org/show_bug.cgi?id=28901

  • wtf/StringExtras.h: (strnstr):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/StringExtras.h

    r44765 r48012  
    8686#endif
    8787
     88#if PLATFORM(WIN_OS) || PLATFORM(LINUX)
     89
     90inline char* strnstr(const char* buffer, const char* target, size_t bufferLength)
     91{
     92    size_t targetLength = strlen(target);
     93    if (targetLength == 0)
     94        return const_cast<char*>(buffer);
     95    for (const char* start = buffer; *start && start + targetLength <= buffer + bufferLength; start++) {
     96        if (*start == *target && strncmp(start + 1, target + 1, targetLength - 1) == 0)
     97            return const_cast<char*>(start);
     98    }
     99    return 0;
     100}
     101
     102#endif
     103
    88104#endif // WTF_StringExtras_h
Note: See TracChangeset for help on using the changeset viewer.