Changeset ea3f90f for lib


Ignore:
Timestamp:
2022-02-17T22:23:06Z (3 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
cc0ad0a
Parents:
2dd6076
git-author:
Claes Nästén <pekdon@…> (11-02-22 19:27:32)
git-committer:
Jelmer Vernooij <jelmer@…> (17-02-22 22:23:06)
Message:

Add strcasestr compatability function

Older platforms unfortunately does not have strcasestr nor does it exist
in the glib API, add fallback implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    r2dd6076 rea3f90f  
    793793        return h;
    794794}
     795
     796#ifdef NO_STRCASESTR
     797char* strcasestr(const char* haystack, const char* needle)
     798{
     799        size_t haystackn = strlen(haystack);
     800        size_t needlen = strlen(needle);
     801
     802        const char *p = haystack;
     803        while (haystackn >= needlen) {
     804                if (g_strncasecmp(p, needle, needlen) == 0) {
     805                    return (char*) p;
     806                }
     807                p++;
     808                haystackn--;
     809        }
     810        return NULL;
     811}
     812#endif
Note: See TracChangeset for help on using the changeset viewer.