Skip to content

Commit

Permalink
Fix usage of tesserr stream
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Dec 19, 2024
1 parent 1ea0ef2 commit bb9604f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/ccmain/tessedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "params.h"
#include "stopper.h"
#include "tesseractclass.h"
#include "tesserrstream.h" // for tesserr
#include "tessvars.h"
#include "tprintf.h"
#ifndef DISABLED_LEGACY_ENGINE
Expand Down Expand Up @@ -86,10 +87,9 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,

// Initialize TessdataManager.
if (!mgr->is_loaded() && !mgr->Init(tessdata_path.string().c_str())) {
tprintf("Error opening data file %s\n", tessdata_path.string());
tprintf(
tesserr << "Error opening data file " << tessdata_path.string() << '\n' <<
"Please make sure the TESSDATA_PREFIX environment variable is set"
" to your \"tessdata\" directory.\n");
" to your \"tessdata\" directory.\n";
return false;
}
#ifdef DISABLED_LEGACY_ENGINE
Expand Down Expand Up @@ -182,9 +182,8 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
}
#ifndef DISABLED_LEGACY_ENGINE
else if (!mgr->GetComponent(TESSDATA_UNICHARSET, &fp) || !unicharset.load_from_file(&fp, false)) {
tprintf(
"Error: Tesseract (legacy) engine requested, but components are "
"not present in %s!!\n", tessdata_path.string());
tesserr << "Error: Tesseract (legacy) engine requested, but components are "
"not present in " << tessdata_path.string() << "!!\n";
return false;
}
#endif // ndef DISABLED_LEGACY_ENGINE
Expand Down
4 changes: 2 additions & 2 deletions src/ccutil/ccutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// limitations under the License.

#include "ccutil.h"
#include "tesserrstream.h" // for tesserr
#include "tprintf.h" // for tprintf

#include <cstdlib>
Expand Down Expand Up @@ -51,8 +52,7 @@ std::filesystem::path find_data_path(const std::string &argv0) {
if (!argv0.empty()) {
std::filesystem::path path(argv0);
if (!std::filesystem::is_directory(path)) {
tprintf("Warning (tessdata): '%s' is not a valid directory.\n",
argv0);
tesserr << "Warning (tessdata): '" << argv0 << "' is not a valid directory.\n";
}
return path;
}
Expand Down

0 comments on commit bb9604f

Please sign in to comment.