Ruby: prism/util/pm_strncasecmp.c Source File

Ruby 3.3.7p123 (2025-01-15 revision be31f993d7fa0219d85f7b3c694d454da4ecc10b)

pm_strncasecmp.c
1#include "prism/util/pm_strncasecmp.h"
2
12int
13pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
14 size_t offset = 0;
15 int difference = 0;
16
17 while (offset < length && string1[offset] != '\0') {
18 if (string2[offset] == '\0') return string1[offset];
19 if ((difference = tolower(string1[offset]) - tolower(string2[offset])) != 0) return difference;
20 offset++;
21 }
22
23 return difference;
24}
pm_strncasecmp.h
A custom strncasecmp implementation.