mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-09-18 18:22:07 +08:00
Use re-entrant functions in a couple of places
Replace strtok and gmtime with their re-entrant versions. More to come.
This commit is contained in:
@@ -50,9 +50,10 @@ load_options()
|
|||||||
{
|
{
|
||||||
char *opt;
|
char *opt;
|
||||||
char *s;
|
char *s;
|
||||||
|
char *ctx;
|
||||||
|
|
||||||
if (!optset && (s=getenv("MDBOPTS"))) {
|
if (!optset && (s=getenv("MDBOPTS"))) {
|
||||||
opt = strtok(s, ":");
|
opt = strtok_r(s, ":", &ctx);
|
||||||
while (opt) {
|
while (opt) {
|
||||||
if (!strcmp(opt, "use_index")) opts |= MDB_USE_INDEX;
|
if (!strcmp(opt, "use_index")) opts |= MDB_USE_INDEX;
|
||||||
if (!strcmp(opt, "no_memo")) opts |= MDB_NO_MEMO;
|
if (!strcmp(opt, "no_memo")) opts |= MDB_NO_MEMO;
|
||||||
@@ -70,7 +71,7 @@ load_options()
|
|||||||
opts |= MDB_DEBUG_ROW;
|
opts |= MDB_DEBUG_ROW;
|
||||||
opts |= MDB_DEBUG_PROPS;
|
opts |= MDB_DEBUG_PROPS;
|
||||||
}
|
}
|
||||||
opt = strtok(NULL,":");
|
opt = strtok_r(NULL,":", &ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
optset = 1;
|
optset = 1;
|
||||||
|
@@ -760,8 +760,9 @@ int mdb_sql_find_sargcol(MdbSargNode *node, gpointer data)
|
|||||||
* Plain integers are UNIX timestamps for backwards compatibility of parser
|
* Plain integers are UNIX timestamps for backwards compatibility of parser
|
||||||
*/
|
*/
|
||||||
if (col->col_type == MDB_DATETIME && node->val_type == MDB_INT) {
|
if (col->col_type == MDB_DATETIME && node->val_type == MDB_INT) {
|
||||||
struct tm *tm = gmtime((time_t*)&node->value.i);
|
struct tm tm;
|
||||||
mdb_tm_to_date(tm, &node->value.d);
|
gmtime_r((time_t*)&node->value.i, &tm);
|
||||||
|
mdb_tm_to_date(&tm, &node->value.d);
|
||||||
node->val_type = MDB_DOUBLE;
|
node->val_type = MDB_DOUBLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user