@@ -67,7 +67,7 @@ static std::mutex output_mutex;
6767// On systems that support it, get a location independent locale.
6868#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) \
6969 || defined (__FreeBSD_kernel__) || defined (__OpenBSD__) \
70- || defined (__GLIBC__)
70+ || defined (__GLIBC__) || defined (__NetBSD__)
7171static locale_t c_loc = newlocale(LC_ALL_MASK , " C" , nullptr );
7272#elif defined(_WIN32)
7373static _locale_t c_loc = _create_locale(LC_ALL , " C" );
@@ -526,6 +526,14 @@ strcasecmp(const char* a, const char* b)
526526 return strcasecmp_l (a, b, c_loc);
527527#elif defined(_WIN32)
528528 return _stricmp_l (a, b, c_loc);
529+ #elif defined(__NetBSD__)
530+ const unsigned char *us1 = (const unsigned char *)a,
531+ *us2 = (const unsigned char *)b;
532+
533+ while (tolower_l (*us1, c_loc) == tolower_l (*us2++, c_loc))
534+ if (*us1++ == ' \0 ' )
535+ return (0 );
536+ return (tolower_l (*us1, c_loc) - tolower_l (*--us2, c_loc));
529537#else
530538# error ("need equivalent of strcasecmp_l on this platform");
531539#endif
@@ -541,6 +549,19 @@ strncasecmp(const char* a, const char* b, size_t size)
541549 return strncasecmp_l (a, b, size, c_loc);
542550#elif defined(_WIN32)
543551 return _strnicmp_l (a, b, size, c_loc);
552+ #elif defined(__NetBSD__)
553+ if (size != 0 ) {
554+ const unsigned char *us1 = (const unsigned char *)a,
555+ *us2 = (const unsigned char *)b;
556+
557+ do {
558+ if (tolower_l (*us1, c_loc) != tolower_l (*us2++, c_loc))
559+ return (tolower_l (*us1, c_loc) - tolower_l (*--us2, c_loc));
560+ if (*us1++ == ' \0 ' )
561+ break ;
562+ } while (--size != 0 );
563+ }
564+ return (0 );
544565#else
545566# error ("need equivalent of strncasecmp_l on this platform");
546567#endif
0 commit comments