Changeset ea3f90f


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.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • configure

    r2dd6076 rea3f90f  
    928928        echo 'STRIP=\# skip strip' >> Makefile.settings
    929929        echo '#define NO_FD_PASSING' >> config.h
     930        if [ "$arch_rel" = "5.10" ]; then
     931                echo '#define NO_STRCASESTR' >> config.h
     932        fi
    930933;;
    931934AIX )
  • 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.