Skip to content

Commit bcfdd5e

Browse files
committed
Fix setup of datadir on installations with Conda (issue #4230)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent f3974d4 commit bcfdd5e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/ccutil/ccutil.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) {
7777
if (datadir.empty()) {
7878
#if defined(TESSDATA_PREFIX)
7979
// Use tessdata prefix which was compiled in.
80+
datadir = TESSDATA_PREFIX "/tessdata/";
8081
// Note that some software (for example conda) patches TESSDATA_PREFIX
81-
// in the binary, so it should not be used directly with a std::string.
82-
tessdata_prefix = TESSDATA_PREFIX;
83-
datadir = tessdata_prefix;
84-
datadir += "/tessdata/";
82+
// in the binary, so it might be shorter. Recalculate its length.
83+
datadir.resize(std::strlen(datadir.c_str()));
8584
#else
8685
datadir = "./";
8786
#endif /* TESSDATA_PREFIX */

0 commit comments

Comments
 (0)