From eab720ebeafab11a5ae4bf58320d2a9dc1f7cd69 Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Sun, 25 Aug 2024 20:02:06 +0300 Subject: [PATCH] Clean-up wvWare --- CMakeLists.txt | 4 +--- src/odr/internal/html/wvWare_wrapper.cpp | 2 -- src/odr/internal/project_info.hpp.in | 2 +- src/wvWare.c | 28 +++++++++++------------- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b8be259..5eb63fe1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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 diff --git a/src/odr/internal/html/wvWare_wrapper.cpp b/src/odr/internal/html/wvWare_wrapper.cpp index dc13baf3..48c2998e 100644 --- a/src/odr/internal/html/wvWare_wrapper.cpp +++ b/src/odr/internal/html/wvWare_wrapper.cpp @@ -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 { diff --git a/src/odr/internal/project_info.hpp.in b/src/odr/internal/project_info.hpp.in index 93d3c343..d93c9d88 100644 --- a/src/odr/internal/project_info.hpp.in +++ b/src/odr/internal/project_info.hpp.in @@ -6,6 +6,6 @@ const char *version() noexcept; } // namespace odr::internal::project_info #cmakedefine WITH_PDF2HTMLEX 1 -#include +#cmakedefine WITH_WVWARE 1 #endif // ODR_INTERNAL_PROJECT_INFO_HPP diff --git a/src/wvWare.c b/src/wvWare.c index c3f769a0..0b653702 100644 --- a/src/wvWare.c +++ b/src/wvWare.c @@ -27,8 +27,6 @@ #include #include "getopt.h" -#include - #ifdef __ANDROID_API__ #include #define ParenthesesStripper(...) __VA_ARGS__ @@ -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) { @@ -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"); }