Skip to content

Commit

Permalink
Fix handling of TESSDATA_PREFIX containing // (fixes issue tesseract-…
Browse files Browse the repository at this point in the history
…ocr#3527)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Aug 24, 2021
1 parent e57a311 commit 4dcd8fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cmake/Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 2 additions & 6 deletions src/ccutil/mainblk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 4dcd8fa

Please sign in to comment.