Skip to content

Commit 9035217

Browse files
stweilzdenop
authored andcommitted
Remove parameter m_data_sub_dir (#1356)
This further simplifies the finding of the tessdata directory. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent cf66bc8 commit 9035217

File tree

3 files changed

+1
-13
lines changed

3 files changed

+1
-13
lines changed

ccutil/ccutil.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
namespace tesseract {
1616
CCUtil::CCUtil() :
1717
params_(),
18-
STRING_INIT_MEMBER(m_data_sub_dir,
19-
"tessdata/", "Directory for data files", &params_),
2018
#ifdef _WIN32
2119
STRING_INIT_MEMBER(tessedit_module_name, WINDLLNAME,
2220
"Module colocated with tessdata dir", &params_),

ccutil/ccutil.h

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class CCUtil {
7777
// Member parameters.
7878
// These have to be declared and initialized after params_ member, since
7979
// params_ should be initialized before parameters are added to it.
80-
STRING_VAR_H(m_data_sub_dir, "tessdata/", "Directory for data files");
8180
#ifdef _WIN32
8281
STRING_VAR_H(tessedit_module_name, WINDLLNAME,
8382
"Module colocated with tessdata dir");

ccutil/mainblk.cpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void CCUtil::main_setup(const char *argv0, const char *basename) {
7777
/* Use tessdata prefix which was compiled in. */
7878
#define _STR(a) #a
7979
#define _XSTR(a) _STR(a)
80-
datadir = _XSTR(TESSDATA_PREFIX);
80+
datadir = _XSTR(TESSDATA_PREFIX) "/tessdata";
8181
#undef _XSTR
8282
#undef _STR
8383
#endif
@@ -86,21 +86,12 @@ void CCUtil::main_setup(const char *argv0, const char *basename) {
8686
// datadir may still be empty:
8787
if (datadir.length() == 0) {
8888
datadir = "./";
89-
} else {
90-
// Remove tessdata from the end if present, as we will add it back!
91-
int length = datadir.length();
92-
if (length >= 8 && strcmp(&datadir[length - 8], "tessdata") == 0)
93-
datadir.truncate_at(length - 8);
94-
else if (length >= 9 && strcmp(&datadir[length - 9], "tessdata/") == 0)
95-
datadir.truncate_at(length - 9);
9689
}
9790

9891
// check for missing directory separator
9992
const char *lastchar = datadir.string();
10093
lastchar += datadir.length() - 1;
10194
if ((strcmp(lastchar, "/") != 0) && (strcmp(lastchar, "\\") != 0))
10295
datadir += "/";
103-
104-
datadir += m_data_sub_dir; /**< data directory */
10596
}
10697
} // namespace tesseract

0 commit comments

Comments
 (0)