Postgres-style ILIKE operator (with Unicode support) (#244)

Access's `LIKE` is actually case-insensitive, but to prevent breaking existing
programs that rely on mdbtools' case-sensitive behavior, introduce a new
`ILIKE` operator to perform a case-insensitive match. Use GLib's `g_utf8_casefold`
to make the comparison UTF-8 aware. A "poor man's" version is implemented
in fakeglib, which relies on `towlower`, and won't work with multi-grapheme
case transformations (e.g. German Eszett).

Fixes #233
This commit is contained in:
Evan Miller
2021-08-04 14:45:31 -04:00
committed by GitHub
parent 1b147b8d29
commit a44a8ed8ae
11 changed files with 74 additions and 20 deletions

View File

@@ -413,7 +413,10 @@ main(int argc, char **argv)
while (1) {
line ++;
if (s) free(s);
if (s) {
free(s);
s = NULL;
}
if (in) {
s=calloc(bufsz, 1);
@@ -434,9 +437,13 @@ main(int argc, char **argv)
s[strlen(s)-1]=0;
} else {
snprintf(prompt, sizeof(prompt), "%d => ", line);
s=readline(prompt);
if (!s)
locale = setlocale(LC_CTYPE, "");
char *l = readline(prompt);
setlocale(LC_CTYPE, locale);
if (!l)
break;
s=g_locale_to_utf8(l, -1, NULL, NULL, NULL);
free(l);
}
if (!strcmp(s,"exit") || !strcmp(s,"quit") || !strcmp(s,"bye"))