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
By default this will be set to the C locale, but set it to the user's
locale when string comparisons are performed from mdb-sql. Note that
this can be overridden with the LC_COLLATE environment variable.
We could infer the collation locale from the file itself, but this will
likely require a big ball of glue between the Windows locales and Unix
ones.
GLib will automatically convert command line options to UTF-8 provided that setlocale(LC_TYPE, "") is called first, and the argument type is STRING (but not FILENAME). Update the CLI tools to take advantage of this behavior, and likewise implement it in fakeglib.
GLib does not automatically convert non-option arguments (i.e. everything remaining in argv after option processing), so manually call g_locale_to_utf8 on these arguments when they represent table names. This should fix the CLI tools when processing non-ASCII table names in non-UTF-8 locales. Also update fakeglib to implement a fast and loose version of g_locale_to_utf8, and factor out some of the code page => iconv name logic in iconv.c so it can be used in our fake g_locale_to_utf8. This adds a new symbol mdb_iconv_name_from_code_page that is not advertised in the main header file. I did not want to include mdbtools.h from fakeglib.c, but maybe that's not important.
There are more modern tools for memory debugging, get rid of DMALLOC
crap in the source code.
I've left one reference in backend.c to prevent a merge conflict but
this can be removed later.
The memory for sql->bound_values is now freed by mdb_sql_reset, so these values no longer should be freed in dump_results_pp. Also, this fixes a memory leak that was occurring when results were not being pretty printed.
SQL engine was being reset in both dump_results functions. Rather than having several different functions responsible for resetting the engine depending on the circumstances, the reset now only occurs in run_query, the same function where the query is executed.
One can now compile with CFLAGS="-std=c99 -D_POSIX_C_SOURCE=1 -pedantic"
Trade getopt.h function for glib equivalents:
This mean all utilities now have long option names.
Adjust manuals and bash_completion accordingly.
Added missing manual and bash_completion for mdb-import.