From 4dcd8fa591350fa03122954ea99751cf5c0c9a3e Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 24 Aug 2021 20:04:23 +0200 Subject: [PATCH] Fix handling of TESSDATA_PREFIX containing // (fixes issue #3527) Signed-off-by: Stefan Weil --- Makefile.am | 4 ++-- cmake/Configure.cmake | 3 +-- src/ccutil/mainblk.cpp | 8 ++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8360ed82cb..aa9fa714c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -347,7 +347,7 @@ endif libtesseract_ccutil_la_CPPFLAGS = $(AM_CPPFLAGS) libtesseract_ccutil_la_CPPFLAGS += $(libarchive_CFLAGS) if !NO_TESSDATA_PREFIX -libtesseract_ccutil_la_CPPFLAGS += -DTESSDATA_PREFIX=@datadir@ +libtesseract_ccutil_la_CPPFLAGS += -DTESSDATA_PREFIX='"@datadir@"' endif noinst_HEADERS += src/ccutil/ccutil.h @@ -513,7 +513,7 @@ libtesseract_lstm_la_CPPFLAGS += -DINCLUDE_TENSORFLOW libtesseract_lstm_la_CPPFLAGS += -I/usr/include/tensorflow endif if !NO_TESSDATA_PREFIX -libtesseract_lstm_la_CPPFLAGS += -DTESSDATA_PREFIX=@datadir@ +libtesseract_lstm_la_CPPFLAGS += -DTESSDATA_PREFIX='"@datadir@"' endif noinst_HEADERS += src/lstm/convolve.h diff --git a/cmake/Configure.cmake b/cmake/Configure.cmake index 61ac626505..37000cb792 100644 --- a/cmake/Configure.cmake +++ b/cmake/Configure.cmake @@ -115,9 +115,8 @@ file(APPEND ${AUTOCONFIG_SRC} " ") if(TESSDATA_PREFIX) - add_definitions(-DTESSDATA_PREFIX=${TESSDATA_PREFIX}) file(APPEND ${AUTOCONFIG_SRC} " -#cmakedefine TESSDATA_PREFIX ${TESSDATA_PREFIX} +#cmakedefine TESSDATA_PREFIX \"${TESSDATA_PREFIX}\" ") endif() diff --git a/src/ccutil/mainblk.cpp b/src/ccutil/mainblk.cpp index 6e665b5fec..c1621b8a37 100644 --- a/src/ccutil/mainblk.cpp +++ b/src/ccutil/mainblk.cpp @@ -68,12 +68,8 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) { #endif /* _WIN32 */ #if defined(TESSDATA_PREFIX) } else { -/* Use tessdata prefix which was compiled in. */ -# define _STR(a) # a -# define _XSTR(a) _STR(a) - datadir = _XSTR(TESSDATA_PREFIX) "/tessdata"; -# undef _XSTR -# undef _STR + // Use tessdata prefix which was compiled in. + datadir = TESSDATA_PREFIX "/tessdata"; #endif }