mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-01-02 12:27:09 +08:00
Let LC_COLLATE influence string-comparison operations
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.
This commit is contained in:
@@ -64,6 +64,7 @@ NOTES
|
|||||||
The -i command can be passed the string 'stdin' to test entering text as if using a pipe.
|
The -i command can be passed the string 'stdin' to test entering text as if using a pipe.
|
||||||
|
|
||||||
ENVIRONMENT
|
ENVIRONMENT
|
||||||
|
LC_COLLATE Defines the locale for string-comparison operations. See locale(1).
|
||||||
MDB_JET3_CHARSET Defines the charset of the input JET3 (access 97) file. Default is CP1252. See iconv(1).
|
MDB_JET3_CHARSET Defines the charset of the input JET3 (access 97) file. Default is CP1252. See iconv(1).
|
||||||
MDBICONV Defines the output charset. Default is UTF-8. mdbtools must have been compiled with iconv.
|
MDBICONV Defines the output charset. Default is UTF-8. mdbtools must have been compiled with iconv.
|
||||||
MDBOPTS Colon-separated list of options:
|
MDBOPTS Colon-separated list of options:
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ int rc;
|
|||||||
if (node->op == MDB_LIKE) {
|
if (node->op == MDB_LIKE) {
|
||||||
return mdb_like_cmp(s,node->value.s);
|
return mdb_like_cmp(s,node->value.s);
|
||||||
}
|
}
|
||||||
rc = strncmp(node->value.s, s, 255);
|
rc = strcoll(node->value.s, s);
|
||||||
switch (node->op) {
|
switch (node->op) {
|
||||||
case MDB_EQUAL:
|
case MDB_EQUAL:
|
||||||
if (rc==0) return 1;
|
if (rc==0) return 1;
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ mdb_sql_eval_expr(MdbSQL *sql, char *const1, int op, char *const2)
|
|||||||
MdbSargNode *node;
|
MdbSargNode *node;
|
||||||
|
|
||||||
if (const1[0]=='\'' && const2[0]=='\'') {
|
if (const1[0]=='\'' && const2[0]=='\'') {
|
||||||
value = strcmp(const1, const2);
|
value = strcoll(const1, const2);
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case MDB_EQUAL: compar = (value ? 0 : 1); break;
|
case MDB_EQUAL: compar = (value ? 0 : 1); break;
|
||||||
case MDB_GT: compar = (value > 0); break;
|
case MDB_GT: compar = (value > 0); break;
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setlocale(LC_COLLATE, "");
|
||||||
/* initialize the SQL engine */
|
/* initialize the SQL engine */
|
||||||
sql = mdb_sql_init();
|
sql = mdb_sql_init();
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user