Changeset: fab41aa10761 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/fab41aa10761 Modified Files: monetdb5/modules/atoms/str.c Branch: Dec2023 Log Message:
Uppercase and lowercase versions aren't necessarily the same length. diffs (33 lines): diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -3809,15 +3809,23 @@ str_is_suffix(const char *s, const char return strcmp(s + sl - sul, suffix); } +/* case insensitive endswith check */ int str_is_isuffix(const char *s, const char *suffix, int sul) { - int sl = str_strlen(s); - - if (sl < sul) - return -1; - else - return utf8casecmp(s + sl - sul, suffix); + const char *e = s + strlen(s); + const char *sf; + + (void) sul; + /* note that the uppercase and lowercase forms of a character aren't + * necessarily the same length in their UTF-8 encodings */ + for (sf = suffix; *sf && e > s; sf++) { + if ((*sf & 0xC0) != 0x80) { + while ((*--e & 0xC0) == 0x80) + ; + } + } + return *sf != 0 || utf8casecmp(e, suffix) != 0; } int _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org