diff --git a/wvWare/src/main/cpp/wvWare-Android.cpp b/wvWare/src/main/cpp/wvWare-Android.cpp index f0ff21a..595a2d7 100644 --- a/wvWare/src/main/cpp/wvWare-Android.cpp +++ b/wvWare/src/main/cpp/wvWare-Android.cpp @@ -32,6 +32,8 @@ extern "C" { char *s_WVDATADIR = NULL; char *s_HTMLCONFIG = NULL; +int documentId = 0; + int convert(char *inputFile, char *outputDir, const char *password); char *strdup_and_append(const char *a, const char *b) { @@ -106,6 +108,7 @@ Java_com_viliussutkus89_android_wvware_wvWare__1convertToHTML(JNIEnv *env, jobje fclose(g_htmlOutputFileHandle); g_htmlOutputFileHandle = nullptr; + documentId++; return retVal; } diff --git a/wvWare/src/main/cpp/wvWare.c b/wvWare/src/main/cpp/wvWare.c index 0705960..35e769c 100644 --- a/wvWare/src/main/cpp/wvWare.c +++ b/wvWare/src/main/cpp/wvWare.c @@ -36,8 +36,16 @@ extern char *strdup (const char *); extern char *str_copy(char *d, size_t n, char *s); extern char *str_append(char *d, size_t n, char *s); -extern char * s_WVDATADIR; -extern char * s_HTMLCONFIG; +extern char *s_WVDATADIR; +extern char *s_HTMLCONFIG; +extern int documentId; +#define static_reinit( variable, defaultValue ) { \ + static int staticVarValue = 0; \ + if (staticVarValue != documentId) { \ + variable = defaultValue; \ + staticVarValue = documentId; \ + } \ +} extern char * strdup_and_append_twice(const char * a, const char * b, const char * c); @@ -612,6 +620,8 @@ int myelehandler (wvParseStruct * ps, wvTag tag, void *props, int dirty) { static PAP *ppap; + static_reinit(ppap, NULL) + expand_data *data = (expand_data *) ps->userData; data->anSttbfAssoc = &ps->anSttbfAssoc; data->lfo = &ps->lfo; @@ -710,6 +720,7 @@ int mydochandler (wvParseStruct * ps, wvTag tag) { static int i; + static_reinit(i, 0) expand_data *data = (expand_data *) ps->userData; data->anSttbfAssoc = &ps->anSttbfAssoc; data->lfo = &ps->lfo; @@ -1398,6 +1409,7 @@ int mySpecCharProc (wvParseStruct * ps, U16 eachchar, CHP * achp) { static int message; + static_reinit(message, 0) PICF picf; FSPA *fspa; expand_data *data = (expand_data *) ps->userData; @@ -1751,7 +1763,9 @@ wvOpenConfig (state_data *myhandle,char *config) char * figure_name (wvParseStruct * ps) { static int number; + static_reinit(number, 0) static char * b_name = 0; + static_reinit(b_name, NULL) char * f_name = 0; char buffer[10]; @@ -1812,7 +1826,9 @@ char * figure_name (wvParseStruct * ps) char * name_to_url (char * name) { static char * url = 0; + static_reinit(url, NULL) static long max = 0; + static_reinit(max, 0) char * ptr = 0; long count = 0;