diff options
author | Salvador Cuñat <salvador.cunat@gmail.com> | 2017-01-22 13:43:10 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-02-10 20:30:58 -0800 |
commit | 7c91cdd89e4316c45b6fa1ea4830f4c2c879f773 (patch) | |
tree | fa7912e0e4c07e14ffde49c5e5a928eed712a5b4 | |
parent | 032c3258edc875ea39ce3124a40e23a22bd6ffe7 (diff) | |
download | subsurface-7c91cdd89e4316c45b6fa1ea4830f4c2c879f773.tar.gz |
smtk-import-Fix crash due to localization issues
Libmdbº:xturns localized strings while parsing the data bases. This is
bad for time calculations as we may end with different strings formats
(e.g. en_US vs almost the rest of the world). Solution is simple: set a
fixed locale and parse only this format.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
-rw-r--r-- | smtk-import/smartrak.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index 25df0901c..e102c1abd 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -27,6 +27,7 @@ #include <string.h> #include <mdbtools.h> #include <stdarg.h> +#include <locale.h> #include "core/dive.h" #include "core/gettext.h" @@ -104,7 +105,7 @@ static void smtk_time_to_tm(char *t_buffer, struct tm *tm_date) { char *temp = NULL; - temp = rindex(copy_string(t_buffer), ' '); + temp = index(copy_string(t_buffer), ' '); if (temp) strptime(temp, "%X", tm_date); } @@ -655,10 +656,11 @@ void smartrak_import(const char *file, struct dive_table *divetable) MdbHandle *mdb, *mdb_clon; MdbTableDef *mdb_table; MdbColumn *col[MDB_MAX_COLS]; - char *bound_values[MDB_MAX_COLS]; int i, dc_model; + // Set an european style locale to work date/time conversion + setlocale(LC_TIME, "POSIX"); mdb = mdb_open(file, MDB_NOFLAGS); if (!mdb) { report_error("[Error][smartrak_import]\tFile %s does not seem to be an Access database.", file); |