mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-01-02 12:27:09 +08:00
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:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user