| 1 | #cxx . . $ `<file>/src/util/pm_strncasecmp.c`/include "prism/util/pm_strncasecmp.h"cxx . . $ `<file>/include/prism/util/pm_strncasecmp.h`/ |
| 2 | |
| 3 | /** |
| 4 | * A locale-insensitive version of `tolower(3)` |
| 5 | */ |
| 6 | static inline int |
| 7 | pm_tolowercxx . . $ pm_tolower(7864480464b09eea).(int c) |
| 8 | { |
| 9 | if ('A' <= c && c <= 'Z') { |
| 10 | return c | 0x20; |
| 11 | } |
| 12 | return c; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Compare two strings, ignoring case, up to the given length. Returns 0 if the |
| 17 | * strings are equal, a negative number if string1 is less than string2, or a |
| 18 | * positive number if string1 is greater than string2. |
| 19 | * |
| 20 | * Note that this is effectively our own implementation of strncasecmp, but it's |
| 21 | * not available on all of the platforms we want to support so we're rolling it |
| 22 | * here. |
| 23 | */ |
| 24 | int |
| 25 | pm_strncasecmpcxx . . $ pm_strncasecmp(26660e80ecdf3800).(const uint8_tcxx . . $ uint8_t# *string1, const uint8_tcxx . . $ uint8_t# *string2, size_t length) { |
| 26 | size_t offset = 0; |
| 27 | int difference = 0; |
| 28 | |
| 29 | while (offset < length && string1[offset] != '\0') { |
| 30 | if (string2[offset] == '\0') return string1[offset]; |
| 31 | if ((difference = pm_tolowercxx . . $ pm_tolower(7864480464b09eea).(string1[offset]) - pm_tolowercxx . . $ pm_tolower(7864480464b09eea).(string2[offset])) != 0) return difference; |
| 32 | offset++; |
| 33 | } |
| 34 | |
| 35 | return difference; |
| 36 | } |