Skip to content

Commit

Permalink
Clean-up wvWare
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Aug 25, 2024
1 parent 9bcdfe7 commit eab720e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ find_package(utf8cpp REQUIRED)
configure_file("src/odr/internal/project_info.cpp.in" "src/odr/internal/project_info.cpp")
configure_file("src/odr/internal/project_info.hpp.in" "src/odr/internal/project_info.hpp")

configure_file("src/wvWare.h.in" "src/wvWare.h")

set(PRE_CONFIGURE_FILE "src/odr/internal/git_info.cpp.in")
set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/src/odr/internal/git_info.cpp")
if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
Expand Down Expand Up @@ -235,7 +233,7 @@ endif ()
install(
DIRECTORY src/ ${CMAKE_CURRENT_BINARY_DIR}/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/
FILES_MATCHING REGEX ".*\\.(h|hpp)$"
FILES_MATCHING PATTERN ".hpp"
)
install(
TARGETS odr meta translate back_translate
Expand Down
2 changes: 0 additions & 2 deletions src/odr/internal/html/wvWare_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ extern "C" {
int convert(char *inputFile, char *outputDir, const char *password);
extern int no_graphics;
extern int documentId;
extern char *s_WVDATADIR;
extern char *s_HTMLCONFIG;
}

namespace odr::internal::html {
Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/project_info.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const char *version() noexcept;
} // namespace odr::internal::project_info

#cmakedefine WITH_PDF2HTMLEX 1
#include <wvWare.h>
#cmakedefine WITH_WVWARE 1

#endif // ODR_INTERNAL_PROJECT_INFO_HPP
28 changes: 13 additions & 15 deletions src/wvWare.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <wv/wv.h>
#include "getopt.h"

#include <wvWare.h>

#ifdef __ANDROID_API__
#include <android/log.h>
#define ParenthesesStripper(...) __VA_ARGS__
Expand Down Expand Up @@ -1748,15 +1746,6 @@ myCharProc (wvParseStruct * ps, U16 eachchar, U8 chartype, U16 lid)
return (0);
}

const char *get_data_dir()
{
const char *data_dir = getenv("WVDATADIR");
if (NULL == data_dir) {
data_dir = WVDATADIR;
}
return data_dir;
}

int
wvOpenConfig (state_data *myhandle,char *config)
{
Expand All @@ -1770,21 +1759,30 @@ wvOpenConfig (state_data *myhandle,char *config)

if(tmp == NULL)
{
const char *wv_data_dir = getenv("WVDATADIR");
if (NULL == wv_data_dir) {
wvError (("Env var WVDATADIR unset!"));
return 0;
}
static char * buf = NULL;
if (NULL != buf) {
free(buf);
}
buf = strdup_and_append_twice(get_data_dir(), "/", config);
buf = strdup_and_append_twice(wv_data_dir, "/", config);
config = buf;
tmp = fopen(config, "rb");
}

if (tmp == NULL)
{
char * html_config = strdup_and_append_twice(get_data_dir(), "/", "wvHtml.xml");
const char *wv_data_dir = getenv("WVDATADIR");
if (NULL == wv_data_dir) {
wvError (("Env var WVDATADIR unset!"));
return 0;
}
char * html_config = strdup_and_append_twice(wv_data_dir, "/", "wvHtml.xml");
if (i)
wvError (
("Attempt to open %s failed, using %s\n", config, html_config));
wvError (("Attempt to open %s failed, using %s\n", config, html_config));
config = html_config;
tmp = fopen (config, "rb");
}
Expand Down

0 comments on commit eab720e

Please sign in to comment.