Skip to content

Commit

Permalink
Remove parameter m_data_sub_dir (#1356)
Browse files Browse the repository at this point in the history
This further simplifies the finding of the tessdata directory.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil authored and zdenop committed Mar 3, 2018
1 parent cf66bc8 commit 9035217
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
2 changes: 0 additions & 2 deletions ccutil/ccutil.cpp
Expand Up @@ -15,8 +15,6 @@
namespace tesseract {
CCUtil::CCUtil() :
params_(),
STRING_INIT_MEMBER(m_data_sub_dir,
"tessdata/", "Directory for data files", &params_),
#ifdef _WIN32
STRING_INIT_MEMBER(tessedit_module_name, WINDLLNAME,
"Module colocated with tessdata dir", &params_),
Expand Down
1 change: 0 additions & 1 deletion ccutil/ccutil.h
Expand Up @@ -77,7 +77,6 @@ class CCUtil {
// Member parameters.
// These have to be declared and initialized after params_ member, since
// params_ should be initialized before parameters are added to it.
STRING_VAR_H(m_data_sub_dir, "tessdata/", "Directory for data files");
#ifdef _WIN32
STRING_VAR_H(tessedit_module_name, WINDLLNAME,
"Module colocated with tessdata dir");
Expand Down
11 changes: 1 addition & 10 deletions ccutil/mainblk.cpp
Expand Up @@ -77,7 +77,7 @@ void CCUtil::main_setup(const char *argv0, const char *basename) {
/* Use tessdata prefix which was compiled in. */
#define _STR(a) #a
#define _XSTR(a) _STR(a)
datadir = _XSTR(TESSDATA_PREFIX);
datadir = _XSTR(TESSDATA_PREFIX) "/tessdata";
#undef _XSTR
#undef _STR
#endif
Expand All @@ -86,21 +86,12 @@ void CCUtil::main_setup(const char *argv0, const char *basename) {
// datadir may still be empty:
if (datadir.length() == 0) {
datadir = "./";
} else {
// Remove tessdata from the end if present, as we will add it back!
int length = datadir.length();
if (length >= 8 && strcmp(&datadir[length - 8], "tessdata") == 0)
datadir.truncate_at(length - 8);
else if (length >= 9 && strcmp(&datadir[length - 9], "tessdata/") == 0)
datadir.truncate_at(length - 9);
}

// check for missing directory separator
const char *lastchar = datadir.string();
lastchar += datadir.length() - 1;
if ((strcmp(lastchar, "/") != 0) && (strcmp(lastchar, "\\") != 0))
datadir += "/";

datadir += m_data_sub_dir; /**< data directory */
}
} // namespace tesseract

0 comments on commit 9035217

Please sign in to comment.