From bcfdd5e51164311ee96cacec33bce4f68632f68e Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 13 May 2024 08:23:56 +0200 Subject: [PATCH] Fix setup of datadir on installations with Conda (issue #4230) Signed-off-by: Stefan Weil --- src/ccutil/ccutil.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ccutil/ccutil.cpp b/src/ccutil/ccutil.cpp index 5d99ec2390..7cf57f2ee9 100644 --- a/src/ccutil/ccutil.cpp +++ b/src/ccutil/ccutil.cpp @@ -77,11 +77,10 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) { if (datadir.empty()) { #if defined(TESSDATA_PREFIX) // Use tessdata prefix which was compiled in. + datadir = TESSDATA_PREFIX "/tessdata/"; // Note that some software (for example conda) patches TESSDATA_PREFIX - // in the binary, so it should not be used directly with a std::string. - tessdata_prefix = TESSDATA_PREFIX; - datadir = tessdata_prefix; - datadir += "/tessdata/"; + // in the binary, so it might be shorter. Recalculate its length. + datadir.resize(std::strlen(datadir.c_str())); #else datadir = "./"; #endif /* TESSDATA_PREFIX */