Skip to content

Commit

Permalink
On each conversion reset static values in wvWare.c
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Jan 15, 2020
1 parent fe5a052 commit 789c714
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions wvWare/src/main/cpp/wvWare-Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -106,6 +108,7 @@ Java_com_viliussutkus89_android_wvware_wvWare__1convertToHTML(JNIEnv *env, jobje
fclose(g_htmlOutputFileHandle);
g_htmlOutputFileHandle = nullptr;

documentId++;
return retVal;
}

Expand Down
20 changes: 18 additions & 2 deletions wvWare/src/main/cpp/wvWare.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 789c714

Please sign in to comment.