@@ -490,9 +490,17 @@ c89stringutils_vsnprintf(char *s, size_t n, const char *format, va_list arg)
490490 * respectively, to be less than, to match, or be greater than s2.
491491 */
492492#if defined(C89STRINGUTILS_HAVE__STRNICMP )
493- #define c89stringutils_strncasecmp _strnicmp
493+ #define c89stringutils_strncasecmp (s1 , s2 , n ) \
494+ (((s1) == NULL && (s2) == NULL) ? 0 \
495+ : ((s1) == NULL) ? -1 \
496+ : ((s2) == NULL) ? 1 \
497+ : _strnicmp((s1), (s2), (n)))
494498#elif defined(C89STRINGUTILS_HAVE_STRNCASECMP )
495- #define c89stringutils_strncasecmp strncasecmp
499+ #define c89stringutils_strncasecmp (s1 , s2 , n ) \
500+ (((s1) == NULL && (s2) == NULL) ? 0 \
501+ : ((s1) == NULL) ? -1 \
502+ : ((s2) == NULL) ? 1 \
503+ : strncasecmp((s1), (s2), (n)))
496504#else
497505extern C89STRINGUTILS_EXPORT int
498506c89stringutils_strncasecmp (const char * s1 , const char * s2 , size_t n );
@@ -506,9 +514,17 @@ c89stringutils_strncasecmp(const char *s1, const char *s2, size_t n);
506514 * respectively, to be less than, to match, or be greater than s2.
507515 */
508516#if defined(C89STRINGUTILS_HAVE__STRICMP )
509- #define c89stringutils_strcasecmp _stricmp
517+ #define c89stringutils_strcasecmp (s1 , s2 ) \
518+ (((s1) == NULL && (s2) == NULL) ? 0 \
519+ : ((s1) == NULL) ? -1 \
520+ : ((s2) == NULL) ? 1 \
521+ : _stricmp((s1), (s2)))
510522#elif defined(C89STRINGUTILS_HAVE_STRCASECMP )
511- #define c89stringutils_strcasecmp strcasecmp
523+ #define c89stringutils_strcasecmp (s1 , s2 ) \
524+ (((s1) == NULL && (s2) == NULL) ? 0 \
525+ : ((s1) == NULL) ? -1 \
526+ : ((s2) == NULL) ? 1 \
527+ : strcasecmp((s1), (s2)))
512528#else
513529extern C89STRINGUTILS_EXPORT int c89stringutils_strcasecmp (const char * s1 ,
514530 const char * s2 );
@@ -524,7 +540,8 @@ extern C89STRINGUTILS_EXPORT int c89stringutils_strcasecmp(const char *s1,
524540 * found.
525541 */
526542#if defined(C89STRINGUTILS_HAVE_STRNSTR )
527- #define c89stringutils_strnstr strnstr
543+ #define c89stringutils_strnstr (b , t , l ) \
544+ (((b) == NULL || (t) == NULL) ? NULL : strnstr((b), (t), (l)))
528545#else
529546extern C89STRINGUTILS_EXPORT char * c89stringutils_strnstr (const char * buffer ,
530547 const char * target ,
@@ -539,7 +556,8 @@ extern C89STRINGUTILS_EXPORT char *c89stringutils_strnstr(const char *buffer,
539556 * found.
540557 */
541558#if defined(C89STRINGUTILS_HAVE_STRCASESTR )
542- #define c89stringutils_strcasestr strcasestr
559+ #define c89stringutils_strcasestr (h , n ) \
560+ (((h) == NULL || (n) == NULL) ? NULL : strcasestr((h), (n)))
543561#else
544562extern C89STRINGUTILS_EXPORT char * c89stringutils_strcasestr (const char * h ,
545563 const char * n );
0 commit comments