mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-11 12:43:17 +08:00
Fix compiler warnings (-Wstringop-truncation)
gcc warnings: src/api/tesseractmain.cpp:252:14: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 255 equals destination size [-Wstringop-truncation] src/ccutil/unicharset.h:66:12: warning: ‘char* strncpy(char*, const char*, size_t)’ output may be truncated copying 30 bytes from a string of length 30 [-Wstringop-truncation] src/ccutil/unicharset.cpp:806:12: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 64 equals destination size [-Wstringop-truncation] Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
ec8f02c0de
commit
aa2dcca295
@ -249,7 +249,7 @@ static void SetVariablesFromCLArgs(tesseract::TessBaseAPI* api, int argc,
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
*p = 0;
|
||||
strncpy(opt2, strchr(argv[i + 1], '=') + 1, 255);
|
||||
strncpy(opt2, strchr(argv[i + 1], '=') + 1, sizeof(opt2) - 1);
|
||||
opt2[254] = 0;
|
||||
++i;
|
||||
|
||||
|
@ -803,7 +803,7 @@ bool UNICHARSET::load_via_fgets(
|
||||
unsigned int properties;
|
||||
char script[64];
|
||||
|
||||
strncpy(script, null_script, sizeof(script));
|
||||
strncpy(script, null_script, sizeof(script) - 1);
|
||||
int min_bottom = 0;
|
||||
int max_bottom = UINT8_MAX;
|
||||
int min_top = 0;
|
||||
|
@ -63,7 +63,7 @@ class CHAR_FRAGMENT {
|
||||
set_natural(natural);
|
||||
}
|
||||
inline void set_unichar(const char *uch) {
|
||||
strncpy(this->unichar, uch, UNICHAR_LEN);
|
||||
strncpy(this->unichar, uch, sizeof(this->unichar));
|
||||
this->unichar[UNICHAR_LEN] = '\0';
|
||||
}
|
||||
inline void set_pos(int p) { this->pos = p; }
|
||||
|
Loading…
Reference in New Issue
Block a user