mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 20:13:24 +00:00
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>
This commit is contained in:
parent
032c3258ed
commit
7c91cdd89e
1 changed files with 4 additions and 2 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <mdbtools.h>
|
#include <mdbtools.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
#include "core/gettext.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;
|
char *temp = NULL;
|
||||||
|
|
||||||
temp = rindex(copy_string(t_buffer), ' ');
|
temp = index(copy_string(t_buffer), ' ');
|
||||||
if (temp)
|
if (temp)
|
||||||
strptime(temp, "%X", tm_date);
|
strptime(temp, "%X", tm_date);
|
||||||
}
|
}
|
||||||
|
@ -655,10 +656,11 @@ void smartrak_import(const char *file, struct dive_table *divetable)
|
||||||
MdbHandle *mdb, *mdb_clon;
|
MdbHandle *mdb, *mdb_clon;
|
||||||
MdbTableDef *mdb_table;
|
MdbTableDef *mdb_table;
|
||||||
MdbColumn *col[MDB_MAX_COLS];
|
MdbColumn *col[MDB_MAX_COLS];
|
||||||
|
|
||||||
char *bound_values[MDB_MAX_COLS];
|
char *bound_values[MDB_MAX_COLS];
|
||||||
int i, dc_model;
|
int i, dc_model;
|
||||||
|
|
||||||
|
// Set an european style locale to work date/time conversion
|
||||||
|
setlocale(LC_TIME, "POSIX");
|
||||||
mdb = mdb_open(file, MDB_NOFLAGS);
|
mdb = mdb_open(file, MDB_NOFLAGS);
|
||||||
if (!mdb) {
|
if (!mdb) {
|
||||||
report_error("[Error][smartrak_import]\tFile %s does not seem to be an Access database.", file);
|
report_error("[Error][smartrak_import]\tFile %s does not seem to be an Access database.", file);
|
||||||
|
|
Loading…
Add table
Reference in a new issue