Merge pull request #905 from stweil/formatstring

Replace Tesseract's format macros by standard macros and fix some related issues
This commit is contained in:
zdenop 2017-05-11 19:41:51 +02:00 committed by GitHub
commit 8b65bb3ae7
9 changed files with 29 additions and 18 deletions

View File

@ -544,8 +544,7 @@ BOOL8 Tesseract::process_cmd_win_event( // UI command semantics
break;
default:
sprintf(msg, "Unrecognised event " INT32FORMAT "(%s)",
cmd_event, new_value);
sprintf(msg, "Unrecognised event %" PRId32 "(%s)", cmd_event, new_value);
image_win->AddMessage(msg);
break;
}

View File

@ -734,8 +734,8 @@ class TO_BLOCK:public ELIST_LINK
for (row_it.mark_cycle_pt(); !row_it.cycled_list();
row_it.forward()) {
row = row_it.data();
tprintf("Row range (%g,%g), para_c=%g, blobcount=" INT32FORMAT
"\n", row->min_y(), row->max_y(), row->parallel_c(),
tprintf("Row range (%g,%g), para_c=%g, blobcount=%" PRId32 "\n",
row->min_y(), row->max_y(), row->parallel_c(),
row->blob_list()->length());
}
}

View File

@ -492,8 +492,8 @@ inT64 DocumentData::UnCache() {
pages_offset_ = -1;
set_total_pages(-1);
set_memory_used(0);
tprintf("Unloaded document %s, saving %d memory\n", document_name_.string(),
memory_saved);
tprintf("Unloaded document %s, saving %" PRId64 " memory\n",
document_name_.string(), memory_saved);
return memory_saved;
}

View File

@ -196,7 +196,7 @@ void PDBLK::plot( //draw outline
// serial,startpt.x(),startpt.y());
char temp_buff[34];
#if defined(__UNIX__) || defined(MINGW)
sprintf(temp_buff, INT32FORMAT, serial);
sprintf(temp_buff, "%" PRId32, serial);
#else
ultoa (serial, temp_buff, 10);
#endif

View File

@ -254,7 +254,7 @@ void POLY_BLOCK::plot(ScrollView* window, inT32 num) {
window->TextAttributes("Times", 80, false, false, false);
char temp_buff[34];
#if defined(__UNIX__) || defined(MINGW)
sprintf(temp_buff, INT32FORMAT, num);
sprintf(temp_buff, "%" PRId32, num);
#else
ltoa (num, temp_buff, 10);
#endif

View File

@ -68,7 +68,8 @@
#undef max
#endif
#include <stdint.h> // int32_t, ...
#include <inttypes.h> // PRId32, ...
#include <stdint.h> // int32_t, ...
/********************************************************/
/* __MAC__ */
@ -111,8 +112,19 @@ typedef float FLOAT32;
typedef double FLOAT64;
typedef unsigned char BOOL8;
#define INT32FORMAT "%d"
#define INT64FORMAT "%lld"
#if defined(_WIN32)
/* MinGW defines the standard PRI... macros, but MSVS doesn't. */
#if !defined(PRId32)
# define PRId32 "d"
#endif
#if !defined(PRId64)
# define PRId64 "I64d"
#endif
#endif /* _WIN32 */
#define MAX_INT8 0x7f
#define MAX_INT16 0x7fff

View File

@ -89,7 +89,7 @@ enum DawgType {
#define WERD_END_FLAG (inT64) 4
#define LETTER_START_BIT 0
#define NUM_FLAG_BITS 3
#define REFFORMAT "%lld"
#define REFFORMAT "%" PRId64
static const bool kDawgSuccessors[DAWG_TYPE_COUNT][DAWG_TYPE_COUNT] = {
{ 0, 1, 1, 0 }, // for DAWG_TYPE_PUNCTUATION

View File

@ -572,7 +572,7 @@ bool Trie::eliminate_redundant_edges(NODE_REF node,
const EDGE_RECORD &edge1,
const EDGE_RECORD &edge2) {
if (debug_level_ > 1) {
tprintf("\nCollapsing node %d:\n", node);
tprintf("\nCollapsing node %" PRIi64 ":\n", node);
print_node(node, MAX_NODE_EDGES_DISPLAY);
tprintf("Candidate edges: ");
print_edge_rec(edge1);

View File

@ -673,8 +673,8 @@ void FontUtils::GetAllRenderableCharacters(const std::vector<string>& fonts,
std::vector<bool>* unichar_bitmap) {
// Form the union of coverage maps from the fonts
PangoCoverage* all_coverage = pango_coverage_new();
tlog(1, "Processing %d fonts\n", fonts.size());
for (int i = 0; i < fonts.size(); ++i) {
tlog(1, "Processing %u fonts\n", static_cast<unsigned>(fonts.size()));
for (unsigned i = 0; i < fonts.size(); ++i) {
PangoFontInfo font_info(fonts[i]);
PangoCoverage* coverage =
pango_font_get_coverage(font_info.ToPangoFont(), nullptr);
@ -738,7 +738,7 @@ string FontUtils::BestFonts(
int most_ok_chars = 0;
int best_raw_score = 0;
const std::vector<string>& font_names = FontUtils::ListAvailableFonts();
for (int i = 0; i < font_names.size(); ++i) {
for (unsigned i = 0; i < font_names.size(); ++i) {
std::vector<bool> ch_flags;
int raw_score = 0;
int ok_chars = FontScore(ch_map, font_names[i], &raw_score, &ch_flags);
@ -763,7 +763,7 @@ string FontUtils::BestFonts(
int override_enough = static_cast<int>(most_ok_chars * kMinWeightedFraction);
string font_list;
for (int i = 0; i < font_names.size(); ++i) {
for (unsigned i = 0; i < font_names.size(); ++i) {
int score = font_scores[i];
int raw_score = raw_scores[i];
if ((score >= least_good_enough && raw_score >= least_raw_enough) ||
@ -798,7 +798,7 @@ bool FontUtils::SelectFont(const char* utf8_word, const int utf8_len,
string* font_name, std::vector<string>* graphemes) {
if (font_name) font_name->clear();
if (graphemes) graphemes->clear();
for (int i = 0; i < all_fonts.size(); ++i) {
for (unsigned i = 0; i < all_fonts.size(); ++i) {
PangoFontInfo font;
std::vector<string> found_graphemes;
ASSERT_HOST_MSG(font.ParseFontDescriptionName(all_fonts[i]),