-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setup of datadir on installations with Conda (issue #4230) #4240
Conversation
…#4230) Signed-off-by: Stefan Weil <sw@weilnetz.de>
tessdata_prefix = TESSDATA_PREFIX; | ||
datadir = tessdata_prefix; | ||
datadir += "/tessdata/"; | ||
// in the binary, so it might be shorter. Recalculate its length. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since std::string is initialized from "const char*", I wonder how it can be shorter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length is calculated at compile time and not updated at runtime if the const char *
was patched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have a locally built tesseract
installed in /usr/local/bin (= with prefix /usr/local), you can patch the binary for example using perl -pi -e 's,/usr/l,/tmp/\0,' /usr/local/bin/tesseract
. Then try tesseract --list-langs
to get the endless recursion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand, if the patched path is longer than the original one, the data in std::string is truncated. If so, it probably makes sense to call strlen() on the string literal rather than on c_str().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not possible to replace the original TESSDATA_PREFIX by a longer one because that would destroy other data. Therefore Conda uses a very long placeholder for TESSDATA_PREFIX.
No description provided.