Ruby 4.1.0dev (2026-09-07 revision b57404b461ba8bf34e802d86b0db78388216e182)
strncasecmp.c
1#include "prism/internal/strncasecmp.h"
2
4
8static PRISM_INLINE int
9pm_tolower(int c) {
10 if ('A' <= c && c <= 'Z') {
11 return c | 0x20;
12 }
13 return c;
14}
15
25int
26pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
27 size_t offset = 0;
28 int difference = 0;
29
30 while (offset < length && string1[offset] != '\0') {
31 if (string2[offset] == '\0') return string1[offset];
32 if ((difference = pm_tolower(string1[offset]) - pm_tolower(string2[offset])) != 0) return difference;
33 offset++;
34 }
35
36 return difference;
37}
#define PRISM_INLINE
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition inline.h:12