From fef89242a86a3e17541359fc4445a71a3748a7b5 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 23 Dec 2021 11:42:55 +0100 Subject: [PATCH] Use fmtlib for tprintf (unfinished, work in progress) Signed-off-by: Stefan Weil --- src/api/baseapi.cpp | 22 ++++++------ src/api/pdfrenderer.cpp | 4 +-- src/arch/simddetect.cpp | 2 +- src/ccmain/adaptions.cpp | 4 +-- src/ccmain/applybox.cpp | 32 ++++++++--------- src/ccmain/control.cpp | 33 +++++++++--------- src/ccmain/docqual.cpp | 48 +++++++++++++------------- src/ccmain/fixspace.cpp | 28 +++++++-------- src/ccmain/fixxht.cpp | 11 +++--- src/ccmain/linerec.cpp | 10 +++--- src/ccmain/output.cpp | 4 +-- src/ccmain/pageiterator.cpp | 4 +-- src/ccmain/paragraphs.cpp | 30 ++++++++-------- src/ccmain/pgedit.cpp | 2 +- src/ccmain/recogtraining.cpp | 8 ++--- src/ccmain/resultiterator.cpp | 16 ++++----- src/ccmain/superscript.cpp | 30 ++++++++-------- src/ccmain/tessedit.cpp | 12 +++---- src/ccstruct/blamer.cpp | 4 +-- src/ccstruct/blamer.h | 2 +- src/ccutil/object_cache.h | 7 ++-- src/ccutil/tprintf.cpp | 10 ++---- src/ccutil/tprintf.h | 17 ++++----- src/dict/dict.cpp | 32 ++++++++--------- src/textord/colfind.cpp | 3 +- src/textord/colpartition.cpp | 2 +- src/training/common/commontraining.cpp | 8 ++--- src/training/mftraining.cpp | 4 +-- src/wordrec/language_model.cpp | 4 +-- 29 files changed, 191 insertions(+), 202 deletions(-) diff --git a/src/api/baseapi.cpp b/src/api/baseapi.cpp index f78894ce..baa26ace 100644 --- a/src/api/baseapi.cpp +++ b/src/api/baseapi.cpp @@ -1005,10 +1005,10 @@ bool TessBaseAPI::ProcessPagesFileList(FILE *flist, std::string *buf, const char chomp_string(pagename); Pix *pix = pixRead(pagename); if (pix == nullptr) { - tprintf("Image file %s cannot be read!\n", pagename); + tprintf("Image file {} cannot be read!\n", pagename); return false; } - tprintf("Page %u : %s\n", page, pagename); + tprintf("Page {} : {}\n", page, pagename); bool r = ProcessPage(pix, page, pagename, retry_config, timeout_millisec, renderer); pixDestroy(&pix); if (!r) { @@ -1047,7 +1047,7 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data, size_t size, co } if (offset || page > 0) { // Only print page number for multipage TIFF file. - tprintf("Page %d\n", page + 1); + tprintf("Page {}\n", page + 1); } auto page_string = std::to_string(page); SetVariable("applybox_page", page_string.c_str()); @@ -1074,7 +1074,7 @@ bool TessBaseAPI::ProcessPages(const char *filename, const char *retry_config, i #ifndef DISABLED_LEGACY_ENGINE if (result) { if (tesseract_->tessedit_train_from_boxes && !tesseract_->WriteTRFile(output_file_.c_str())) { - tprintf("Write of TR file failed: %s\n", output_file_.c_str()); + tprintf("Write of TR file failed: {}\n", output_file_.c_str()); return false; } } @@ -1108,7 +1108,7 @@ bool TessBaseAPI::ProcessPagesInternal(const char *filename, const char *retry_c if (stdInput) { #ifdef WIN32 if (_setmode(_fileno(stdin), _O_BINARY) == -1) - tprintf("ERROR: cin to binary: %s", strerror(errno)); + tprintf("ERROR: cin to binary: {}", strerror(errno)); #endif // WIN32 } @@ -1293,7 +1293,7 @@ bool TessBaseAPI::ProcessPage(Pix *pix, int page_index, const char *filename, // Save current config variables before switching modes. FILE *fp = fopen(kOldVarsFile, "wb"); if (fp == nullptr) { - tprintf("Error, failed to open file \"%s\"\n", kOldVarsFile); + tprintf("Error, failed to open file \"{}\"\n", kOldVarsFile); } else { PrintVariables(fp); fclose(fp); @@ -1841,7 +1841,7 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char *wordstr) { SetVariable("classify_enable_learning", "0"); const std::unique_ptr text(GetUTF8Text()); if (debug) { - tprintf("Trying to adapt \"%s\" to \"%s\"\n", text.get(), wordstr); + tprintf("Trying to adapt \"{}\" to \"{}\"\n", text.get(), wordstr); } if (text != nullptr) { PAGE_RES_IT it(page_res_); @@ -2062,7 +2062,7 @@ bool TessBaseAPI::Threshold(Pix **pix) { if (user_dpi && (user_dpi < kMinCredibleResolution || user_dpi > kMaxCredibleResolution)) { tprintf( "Warning: User defined image dpi is outside of expected range " - "(%d - %d)!\n", + "({} - {})!\n", kMinCredibleResolution, kMaxCredibleResolution); } // Always use user defined dpi @@ -2071,7 +2071,7 @@ bool TessBaseAPI::Threshold(Pix **pix) { } else if (y_res < kMinCredibleResolution || y_res > kMaxCredibleResolution) { if (y_res != 0) { // Show warning only if a resolution was given. - tprintf("Warning: Invalid resolution %d dpi. Using %d instead.\n", + tprintf("Warning: Invalid resolution {} dpi. Using {} instead.\n", y_res, kMinCredibleResolution); } thresholder_->SetSourceYResolution(kMinCredibleResolution); @@ -2116,8 +2116,8 @@ bool TessBaseAPI::Threshold(Pix **pix) { kMinCredibleResolution, kMaxCredibleResolution); if (estimated_res != thresholder_->GetScaledEstimatedResolution()) { tprintf( - "Estimated internal resolution %d out of range! " - "Corrected to %d.\n", + "Estimated internal resolution {} out of range! " + "Corrected to {}.\n", thresholder_->GetScaledEstimatedResolution(), estimated_res); } tesseract_->set_source_resolution(estimated_res); diff --git a/src/api/pdfrenderer.cpp b/src/api/pdfrenderer.cpp index 774558ae..551f6016 100644 --- a/src/api/pdfrenderer.cpp +++ b/src/api/pdfrenderer.cpp @@ -303,7 +303,7 @@ static void ClipBaseline(int ppi, int x1, int y1, int x2, int y2, int *line_x1, static bool CodepointToUtf16be(int code, char utf16[kMaxBytesPerCodepoint]) { if ((code > 0xD7FF && code < 0xE000) || code > 0x10FFFF) { - tprintf("Dropping invalid codepoint %d\n", code); + tprintf("Dropping invalid codepoint {}\n", code); return false; } if (code < 0x10000) { @@ -626,7 +626,7 @@ bool TessPDFRenderer::BeginDocumentHandler() { font = buffer.data(); } else { #if !defined(NDEBUG) - tprintf("Cannot open file \"%s\"!\nUsing internal glyphless font.\n", stream.str().c_str()); + tprintf("Cannot open file \"{}\"!\nUsing internal glyphless font.\n", stream.str().c_str()); #endif font = pdf_ttf; size = sizeof(pdf_ttf); diff --git a/src/arch/simddetect.cpp b/src/arch/simddetect.cpp index 573faa0c..2f60fb75 100644 --- a/src/arch/simddetect.cpp +++ b/src/arch/simddetect.cpp @@ -319,7 +319,7 @@ void SIMDDetect::Update() { dotproduct_method = "std::inner_product"; } else { // Unsupported value of config variable. - tprintf("Warning, ignoring unsupported config variable value: dotproduct=%s\n", + tprintf("Warning, ignoring unsupported config variable value: dotproduct={}\n", dotproduct.c_str()); tprintf( "Supported values for dotproduct: auto generic native" diff --git a/src/ccmain/adaptions.cpp b/src/ccmain/adaptions.cpp index 8783b720..a2625342 100644 --- a/src/ccmain/adaptions.cpp +++ b/src/ccmain/adaptions.cpp @@ -34,7 +34,7 @@ namespace tesseract { bool Tesseract::word_adaptable( // should we adapt? WERD_RES *word, uint16_t mode) { if (tessedit_adaption_debug) { - tprintf("Running word_adaptable() for %s rating %.4f certainty %.4f\n", + tprintf("Running word_adaptable() for {} rating %.4f certainty %.4f\n", word->best_choice->unichar_string().c_str(), word->best_choice->rating(), word->best_choice->certainty()); } @@ -112,7 +112,7 @@ bool Tesseract::word_adaptable( // should we adapt? } if (tessedit_adaption_debug) { - tprintf("returning status %d\n", status); + tprintf("returning status {}\n", status); } return status; } diff --git a/src/ccmain/applybox.cpp b/src/ccmain/applybox.cpp index d550adfe..e90ea5f9 100644 --- a/src/ccmain/applybox.cpp +++ b/src/ccmain/applybox.cpp @@ -310,7 +310,7 @@ static double BoxMissMetric(const TBOX &box1, const TBOX &box2) { bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const TBOX &box, const TBOX *next_box, const char *correct_text) { if (applybox_debug > 1) { - tprintf("\nAPPLY_BOX: in ResegmentCharBox() for %s\n", correct_text); + tprintf("\nAPPLY_BOX: in ResegmentCharBox() for {}\n", correct_text); } PAGE_RES_IT page_res_it(page_res); WERD_RES *word_res; @@ -351,7 +351,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const } if (blob_count > 0) { if (applybox_debug > 1) { - tprintf("Index [%d, %d) seem good.\n", i, i + blob_count); + tprintf("Index [{}, {}) seem good.\n", i, i + blob_count); } if (!char_box.almost_equal(box, 3) && ((next_box != nullptr && box.x_gap(*next_box) < -3) || @@ -366,7 +366,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const word_res->best_state[i] = blob_count; word_res->correct_text[i] = correct_text; if (applybox_debug > 2) { - tprintf("%d Blobs match: blob box:", blob_count); + tprintf("{} Blobs match: blob box:", blob_count); word_res->box_word->BlobBox(i).print(); tprintf("Matches box:"); box.print(); @@ -386,12 +386,12 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const if (applybox_debug > 1) { tprintf("Best state = "); for (auto best_state : word_res->best_state) { - tprintf("%d ", best_state); + tprintf("{} ", best_state); } tprintf("\n"); tprintf("Correct text = [[ "); for (auto &it : word_res->correct_text) { - tprintf("%s ", it.c_str()); + tprintf("{} ", it.c_str()); } tprintf("]]\n"); } @@ -414,7 +414,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const bool Tesseract::ResegmentWordBox(BLOCK_LIST *block_list, const TBOX &box, const TBOX *next_box, const char *correct_text) { if (applybox_debug > 1) { - tprintf("\nAPPLY_BOX: in ResegmentWordBox() for %s\n", correct_text); + tprintf("\nAPPLY_BOX: in ResegmentWordBox() for {}\n", correct_text); } WERD *new_word = nullptr; BLOCK_IT b_it(block_list); @@ -503,12 +503,12 @@ void Tesseract::ReSegmentByClassification(PAGE_RES *page_res) { // Convert the correct text to a vector of UNICHAR_ID std::vector target_text; if (!ConvertStringToUnichars(word->text(), &target_text)) { - tprintf("APPLY_BOX: FAILURE: can't find class_id for '%s'\n", word->text()); + tprintf("APPLY_BOX: FAILURE: can't find class_id for '{}'\n", word->text()); pr_it.DeleteCurrentWord(); continue; } if (!FindSegmentation(target_text, word_res)) { - tprintf("APPLY_BOX: FAILURE: can't find segmentation for '%s'\n", word->text()); + tprintf("APPLY_BOX: FAILURE: can't find segmentation for '{}'\n", word->text()); pr_it.DeleteCurrentWord(); continue; } @@ -552,7 +552,7 @@ bool Tesseract::FindSegmentation(const std::vector &target_text, WER classify_piece(word_res->seam_array, i, i + j - 1, "Applybox", word_res->chopped_word, word_res->blamer_bundle); if (applybox_debug > 2) { - tprintf("%d+%d:", i, j); + tprintf("{}+{}:", i, j); print_ratings_list("Segment:", match_result, unicharset); } choices[i].push_back(match_result); @@ -662,7 +662,7 @@ void Tesseract::SearchForText(const std::vector *choices, in } } else if (choices_pos + length < choices_length && text_index + 1 < target_text.size()) { if (applybox_debug > 3) { - tprintf("Match found for %d=%s:%s, at %d+%d, recursing...\n", target_text[text_index], + tprintf("Match found for {}={}:{}, at {}+{}, recursing...\n", target_text[text_index], unicharset.id_to_unichar(target_text[text_index]), choice_it.data()->unichar_id() == target_text[text_index] ? "Match" : "Ambig", choices_pos, length); @@ -670,7 +670,7 @@ void Tesseract::SearchForText(const std::vector *choices, in SearchForText(choices, choices_pos + length, choices_length, target_text, text_index + 1, rating + choice_rating, segmentation, best_rating, best_segmentation); if (applybox_debug > 3) { - tprintf("End recursion for %d=%s\n", target_text[text_index], + tprintf("End recursion for {}={}\n", target_text[text_index], unicharset.id_to_unichar(target_text[text_index])); } } @@ -729,12 +729,12 @@ void Tesseract::TidyUp(PAGE_RES *page_res) { word_res->word->set_flag(W_EOL, pr_it.next_row() != pr_it.row()); } if (applybox_debug > 0) { - tprintf(" Found %d good blobs.\n", ok_blob_count); + tprintf(" Found {} good blobs.\n", ok_blob_count); if (bad_blob_count > 0) { - tprintf(" Leaving %d unlabelled blobs in %d words.\n", bad_blob_count, ok_word_count); + tprintf(" Leaving {} unlabelled blobs in {} words.\n", bad_blob_count, ok_word_count); } if (unlabelled_words > 0) { - tprintf(" %d remaining unlabelled words deleted.\n", unlabelled_words); + tprintf(" {} remaining unlabelled words deleted.\n", unlabelled_words); } } } @@ -742,7 +742,7 @@ void Tesseract::TidyUp(PAGE_RES *page_res) { /** Logs a bad box by line in the box file and box coords.*/ void Tesseract::ReportFailedBox(int boxfile_lineno, TBOX box, const char *box_ch, const char *err_msg) { - tprintf("APPLY_BOXES: boxfile line %d/%s ((%d,%d),(%d,%d)): %s\n", boxfile_lineno + 1, box_ch, + tprintf("APPLY_BOXES: boxfile line {}/{} (({},{}),({},{})): {}\n", boxfile_lineno + 1, box_ch, box.left(), box.bottom(), box.right(), box.top(), err_msg); } @@ -755,7 +755,7 @@ void Tesseract::ApplyBoxTraining(const std::string &fontname, PAGE_RES *page_res LearnWord(fontname.c_str(), word_res); ++word_count; } - tprintf("Generated training data for %d words\n", word_count); + tprintf("Generated training data for {} words\n", word_count); } #endif // ndef DISABLED_LEGACY_ENGINE diff --git a/src/ccmain/control.cpp b/src/ccmain/control.cpp index 6f5fcff4..d8a2257e 100644 --- a/src/ccmain/control.cpp +++ b/src/ccmain/control.cpp @@ -91,8 +91,8 @@ bool Tesseract::recog_interactive(PAGE_RES_IT *pr_it) { WERD_RES *word_res = pr_it->word(); word_char_quality(word_res, &char_qual, &good_char_qual); tprintf( - "\n%d chars; word_blob_quality: %d; outline_errs: %d; " - "char_quality: %d; good_char_quality: %d\n", + "\n{} chars; word_blob_quality: {}; outline_errs: {}; " + "char_quality: {}; good_char_quality: {}\n", word_res->reject_map.length(), word_blob_quality(word_res), word_outline_errs(word_res), char_qual, good_char_qual); } @@ -123,7 +123,7 @@ bool Tesseract::ProcessTargetWord(const TBOX &word_box, const TBOX &target_word_ backup_config_file_ = kBackUpConfigFile; FILE *config_fp = fopen(backup_config_file_, "wb"); if (config_fp == nullptr) { - tprintf("Error, failed to open file \"%s\"\n", backup_config_file_); + tprintf("Error, failed to open file \"{}\"\n", backup_config_file_); } else { ParamUtils::PrintParams(config_fp, params()); fclose(config_fp); @@ -252,8 +252,8 @@ bool Tesseract::RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT classify_word_and_language(pass_n, pr_it, word); if (tessedit_dump_choices || debug_noise_removal) { - tprintf("Pass%d: %s [%s]\n", pass_n, word->word->best_choice->unichar_string().c_str(), - word->word->best_choice->debug_string().c_str()); + tprintf("Pass{}: {} [{}]\n", pass_n, word->word->best_choice->unichar_string(), + word->word->best_choice->debug_string()); } pr_it->forward(); if (make_next_word_fuzzy && pr_it->word() != nullptr) { @@ -497,13 +497,13 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) { if (w->tesseract->getDict().valid_bigram(prev_best, this_best)) { if (tessedit_bigram_debug) { - tprintf("Top choice \"%s %s\" verified by bigram model.\n", orig_w1_str.c_str(), - orig_w2_str.c_str()); + tprintf("Top choice \"{} {}\" verified by bigram model.\n", orig_w1_str, + orig_w2_str); } continue; } if (tessedit_bigram_debug > 2) { - tprintf("Examining alt choices for \"%s %s\".\n", orig_w1_str.c_str(), orig_w2_str.c_str()); + tprintf("Examining alt choices for \"{} {}\".\n", orig_w1_str, orig_w2_str); } if (tessedit_bigram_debug > 1) { if (!w_prev->best_choices.singleton()) { @@ -549,9 +549,9 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) { EqualIgnoringCaseAndTerminalPunct(*w->best_choice, *overrides_word2[best_idx])) { if (tessedit_bigram_debug > 1) { tprintf( - "Top choice \"%s %s\" verified (sans case) by bigram " + "Top choice \"{} {}\" verified (sans case) by bigram " "model.\n", - orig_w1_str.c_str(), orig_w2_str.c_str()); + orig_w1_str, orig_w2_str); } continue; } @@ -588,9 +588,9 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) { choices_description += " compatible bigrams."; } } - tprintf("Replaced \"%s %s\" with \"%s %s\" with bigram model. %s\n", orig_w1_str.c_str(), - orig_w2_str.c_str(), new_w1_str.c_str(), new_w2_str.c_str(), - choices_description.c_str()); + tprintf("Replaced \"{} {}\" with \"{} {}\" with bigram model. %s\n", orig_w1_str, + orig_w2_str, new_w1_str, new_w2_str, + choices_description); } } } @@ -652,8 +652,7 @@ void Tesseract::rejection_passes(PAGE_RES *page_res, ETEXT_DESC *monitor, } if (tessedit_debug_quality_metrics) { - tprintf( - "QUALITY: num_chs= %d num_rejs= %d %5.3f blob_qual= %d %5.3f" + tprintf("QUALITY: num_chs= %d num_rejs= %d %5.3f blob_qual= %d %5.3f" " outline_errs= %d %5.3f char_qual= %d %5.3f good_ch_qual= %d %5.3f\n", page_res->char_count, page_res->rej_count, page_res->rej_count / static_cast(page_res->char_count), stats_.doc_blob_quality, @@ -692,13 +691,13 @@ void Tesseract::blamer_pass(PAGE_RES *page_res) { } tprintf("Blame reasons:\n"); for (int bl = 0; bl < IRR_NUM_REASONS; ++bl) { - tprintf("%s %d\n", BlamerBundle::IncorrectReasonName(static_cast(bl)), + tprintf("{} {}\n", BlamerBundle::IncorrectReasonName(static_cast(bl)), page_res->blame_reasons[bl]); } if (page_res->misadaption_log.size() > 0) { tprintf("Misadaption log:\n"); for (auto &log : page_res->misadaption_log) { - tprintf("%s\n", log.c_str()); + tprintf("{}\n", log); } } } diff --git a/src/ccmain/docqual.cpp b/src/ccmain/docqual.cpp index 8941f8f0..68f0cf02 100644 --- a/src/ccmain/docqual.cpp +++ b/src/ccmain/docqual.cpp @@ -223,12 +223,12 @@ void Tesseract::doc_and_block_rejection( // reject big chunks tessedit_reject_doc_percent) { reject_whole_page(page_res_it); if (tessedit_debug_doc_rejection) { - tprintf("REJECT ALL #chars: %d #Rejects: %d; \n", page_res_it.page_res->char_count, + tprintf("REJECT ALL #chars: {} #Rejects: {}; \n", page_res_it.page_res->char_count, page_res_it.page_res->rej_count); } } else { if (tessedit_debug_doc_rejection) { - tprintf("NO PAGE REJECTION #chars: %d # Rejects: %d; \n", page_res_it.page_res->char_count, + tprintf("NO PAGE REJECTION #chars: {} # Rejects: {}; \n", page_res_it.page_res->char_count, page_res_it.page_res->rej_count); } @@ -243,7 +243,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks (current_block->rej_count * 100.0 / current_block->char_count) > tessedit_reject_block_percent) { if (tessedit_debug_block_rejection) { - tprintf("REJECTING BLOCK %d #chars: %d; #Rejects: %d\n", block_no, + tprintf("REJECTING BLOCK {} #chars: {}; #Rejects: {}\n", block_no, current_block->char_count, current_block->rej_count); } prev_word_rejected = false; @@ -279,7 +279,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks } } else { if (tessedit_debug_block_rejection) { - tprintf("NOT REJECTING BLOCK %d #chars: %d # Rejects: %d; \n", block_no, + tprintf("NOT REJECTING BLOCK {} #chars: {} # Rejects: {}; \n", block_no, page_res_it.block()->char_count, page_res_it.block()->rej_count); } @@ -299,7 +299,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks (current_row->whole_word_rej_count * 100.0 / current_row->rej_count) < tessedit_whole_wd_rej_row_percent) { if (tessedit_debug_block_rejection) { - tprintf("REJECTING ROW %d #chars: %d; #Rejects: %d\n", row_no, + tprintf("REJECTING ROW {} #chars: {}; #Rejects: {}\n", row_no, current_row->char_count, current_row->rej_count); } prev_word_rejected = false; @@ -341,7 +341,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks } } else { if (tessedit_debug_block_rejection) { - tprintf("NOT REJECTING ROW %d #chars: %d # Rejects: %d; \n", row_no, + tprintf("NOT REJECTING ROW {} #chars: {} # Rejects: {}; \n", row_no, current_row->char_count, current_row->rej_count); } while (page_res_it.word() != nullptr && page_res_it.row() == current_row) { @@ -405,13 +405,13 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) { if ((garbage_level != G_NEVER_CRUNCH) && (terrible_word_crunch(word, garbage_level))) { if (crunch_debug > 0) { - tprintf("T CRUNCHING: \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("T CRUNCHING: \"{}\"\n", word->best_choice->unichar_string().c_str()); } word->unlv_crunch_mode = CR_KEEP_SPACE; if (prev_potential_marked) { while (copy_it.word() != word) { if (crunch_debug > 0) { - tprintf("P1 CRUNCHING: \"%s\"\n", + tprintf("P1 CRUNCHING: \"{}\"\n", copy_it.word()->best_choice->unichar_string().c_str()); } copy_it.word()->unlv_crunch_mode = CR_KEEP_SPACE; @@ -424,14 +424,14 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) { (potential_word_crunch(word, garbage_level, ok_dict_word))) { if (found_terrible_word) { if (crunch_debug > 0) { - tprintf("P2 CRUNCHING: \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("P2 CRUNCHING: \"{}\"\n", word->best_choice->unichar_string().c_str()); } word->unlv_crunch_mode = CR_KEEP_SPACE; } else if (!prev_potential_marked) { copy_it = page_res_it; prev_potential_marked = true; if (crunch_debug > 1) { - tprintf("P3 CRUNCHING: \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("P3 CRUNCHING: \"{}\"\n", word->best_choice->unichar_string().c_str()); } } } else { @@ -439,7 +439,7 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) { // Forget earlier potential crunches prev_potential_marked = false; if (crunch_debug > 2) { - tprintf("NO CRUNCH: \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("NO CRUNCH: \"{}\"\n", word->best_choice->unichar_string().c_str()); } } } @@ -476,8 +476,8 @@ bool Tesseract::terrible_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level } if (crunch_mode > 0) { if (crunch_debug > 2) { - tprintf("Terrible_word_crunch (%d) on \"%s\"\n", crunch_mode, - word->best_choice->unichar_string().c_str()); + tprintf("Terrible_word_crunch ({}) on \"{}\"\n", crunch_mode, + word->best_choice->unichar_string()); } return true; } else { @@ -506,21 +506,21 @@ bool Tesseract::potential_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_leve if (rating_per_ch > crunch_pot_poor_rate) { if (crunch_debug > 2) { - tprintf("Potential poor rating on \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("Potential poor rating on \"{}\"\n", word->best_choice->unichar_string()); } poor_indicator_count++; } if (word_crunchable && word->best_choice->certainty() < crunch_pot_poor_cert) { if (crunch_debug > 2) { - tprintf("Potential poor cert on \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("Potential poor cert on \"{}\"\n", word->best_choice->unichar_string()); } poor_indicator_count++; } if (garbage_level != G_OK) { if (crunch_debug > 2) { - tprintf("Potential garbage on \"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("Potential garbage on \"{}\"\n", word->best_choice->unichar_string()); } poor_indicator_count++; } @@ -545,8 +545,8 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) { if (delete_mode != CR_NONE) { if (word->word->flag(W_BOL) || deleting_from_bol) { if (crunch_debug > 0) { - tprintf("BOL CRUNCH DELETING(%d): \"%s\"\n", debug_delete_mode, - word->best_choice->unichar_string().c_str()); + tprintf("BOL CRUNCH DELETING({}): \"{}\"\n", debug_delete_mode, + word->best_choice->unichar_string()); } word->unlv_crunch_mode = delete_mode; deleting_from_bol = true; @@ -555,16 +555,16 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) { while (copy_it.word() != word) { x_delete_mode = word_deletable(copy_it.word(), x_debug_delete_mode); if (crunch_debug > 0) { - tprintf("EOL CRUNCH DELETING(%d): \"%s\"\n", x_debug_delete_mode, - copy_it.word()->best_choice->unichar_string().c_str()); + tprintf("EOL CRUNCH DELETING({}): \"{}\"\n", x_debug_delete_mode, + copy_it.word()->best_choice->unichar_string()); } copy_it.word()->unlv_crunch_mode = x_delete_mode; copy_it.forward(); } } if (crunch_debug > 0) { - tprintf("EOL CRUNCH DELETING(%d): \"%s\"\n", debug_delete_mode, - word->best_choice->unichar_string().c_str()); + tprintf("EOL CRUNCH DELETING({}): \"{}\"\n", debug_delete_mode, + word->best_choice->unichar_string()); } word->unlv_crunch_mode = delete_mode; deleting_from_bol = false; @@ -776,8 +776,8 @@ GARBAGE_LEVEL Tesseract::garbage_word(WERD_RES *word, bool ok_dict_word) { ok_chars = len - bad_char_count - isolated_digits - isolated_alphas - tess_rejs; if (crunch_debug > 3) { - tprintf("garbage_word: \"%s\"\n", word->best_choice->unichar_string().c_str()); - tprintf("LEN: %d bad: %d iso_N: %d iso_A: %d rej: %d\n", len, bad_char_count, + tprintf("garbage_word: \"{}\"\n", word->best_choice->unichar_string()); + tprintf("LEN: {} bad: {} iso_N: {} iso_A: {} rej: {}\n", len, bad_char_count, isolated_digits, isolated_alphas, tess_rejs); } if (bad_char_count == 0 && tess_rejs == 0 && diff --git a/src/ccmain/fixspace.cpp b/src/ccmain/fixspace.cpp index dee79395..284d9389 100644 --- a/src/ccmain/fixspace.cpp +++ b/src/ccmain/fixspace.cpp @@ -481,28 +481,28 @@ void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score, int16_t mode, boo if (debug_fix_space_level > 1) { switch (mode) { case 1: - tprintf("EXTRACTED (%d): \"", score); + tprintf("EXTRACTED ({}): \"", score); break; case 2: - tprintf("TESTED (%d): \"", score); + tprintf("TESTED ({}): \"", score); break; case 3: - tprintf("RETURNED (%d): \"", score); + tprintf("RETURNED ({}): \"", score); break; } for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) { if (!word_res_it.data()->part_of_combo) { - tprintf("%s/%1d ", word_res_it.data()->best_choice->unichar_string().c_str(), + tprintf("{}/%1d ", word_res_it.data()->best_choice->unichar_string(), static_cast(word_res_it.data()->best_choice->permuter())); } } tprintf("\"\n"); } else if (improved) { - tprintf("FIX SPACING \"%s\" => \"", stats_.dump_words_str.c_str()); + tprintf("FIX SPACING \"{}\" => \"", stats_.dump_words_str); for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) { if (!word_res_it.data()->part_of_combo) { - tprintf("%s/%1d ", word_res_it.data()->best_choice->unichar_string().c_str(), + tprintf("{}/%1d ", word_res_it.data()->best_choice->unichar_string(), static_cast(word_res_it.data()->best_choice->permuter())); } } @@ -562,7 +562,7 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK *block) } if (debug_fix_space_level > 1) { - tprintf("FP fixspace working on \"%s\"\n", word_res->best_choice->unichar_string().c_str()); + tprintf("FP fixspace working on \"{}\"\n", word_res->best_choice->unichar_string()); } word_res->word->rej_cblob_list()->sort(c_blob_comparator); sub_word_list_it.add_after_stay_put(word_res_it.extract()); @@ -706,8 +706,8 @@ int16_t Tesseract::worst_noise_blob(WERD_RES *word_res, float *worst_noise_score #ifndef SECURE_NAMES if (debug_fix_space_level > 5) { - tprintf("FP fixspace Noise metrics for \"%s\": ", - word_res->best_choice->unichar_string().c_str()); + tprintf("FP fixspace Noise metrics for \"{}\": ", + word_res->best_choice->unichar_string()); } #endif @@ -809,21 +809,21 @@ void fixspace_dbg(WERD_RES *word) { int16_t i; box.print(); - tprintf(" \"%s\" ", word->best_choice->unichar_string().c_str()); - tprintf("Blob count: %d (word); %d/%d (rebuild word)\n", word->word->cblob_list()->length(), + tprintf(" \"{}\" ", word->best_choice->unichar_string()); + tprintf("Blob count: {} (word); {}/{} (rebuild word)\n", word->word->cblob_list()->length(), word->rebuild_word->NumBlobs(), word->box_word->length()); word->reject_map.print(debug_fp); tprintf("\n"); if (show_map_detail) { - tprintf("\"%s\"\n", word->best_choice->unichar_string().c_str()); + tprintf("\"{}\"\n", word->best_choice->unichar_string()); for (i = 0; word->best_choice->unichar_string()[i] != '\0'; i++) { tprintf("**** \"%c\" ****\n", word->best_choice->unichar_string()[i]); word->reject_map[i].full_print(debug_fp); } } - tprintf("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE"); - tprintf("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE"); + tprintf("Tess Accepted: {}\n", word->tess_accepted ? "TRUE" : "FALSE"); + tprintf("Done flag: {}\n\n", word->done ? "TRUE" : "FALSE"); } /** diff --git a/src/ccmain/fixxht.cpp b/src/ccmain/fixxht.cpp index 9253673d..72bbd07a 100644 --- a/src/ccmain/fixxht.cpp +++ b/src/ccmain/fixxht.cpp @@ -2,7 +2,6 @@ * File: fixxht.cpp (Formerly fixxht.c) * Description: Improve x_ht and look out for case inconsistencies * Author: Phil Cheatle - * Created: Thu Aug 5 14:11:08 BST 1993 * * (C) Copyright 1992, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -91,7 +90,7 @@ int Tesseract::CountMisfitTops(WERD_RES *word_res) { ++bad_blobs; } if (debug_x_ht_level >= 1) { - tprintf("Class %s is %s with top %d vs limits of %d->%d, +/-%d\n", + tprintf("Class {} is {} with top {} vs limits of {}->{}, +/-{}\n", unicharset.id_to_unichar(class_id), bad ? "Misfit" : "OK", top, min_top, max_top, static_cast(x_ht_acceptance_tolerance)); } @@ -130,7 +129,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh top - (max_top + x_ht_acceptance_tolerance)); int height = top - kBlnBaselineOffset; if (debug_x_ht_level >= 2) { - tprintf("Class %s: height=%d, bottom=%d,%d top=%d,%d, actual=%d,%d: ", + tprintf("Class {}: height={}, bottom={},{} top={},{}, actual={},{}: ", unicharset.id_to_unichar(class_id), height, min_bottom, max_bottom, min_top, max_top, bottom, top); } @@ -144,7 +143,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh int min_xht = DivRounded(height * kBlnXHeight, max_top - kBlnBaselineOffset); int max_xht = DivRounded(height * kBlnXHeight, min_top - kBlnBaselineOffset); if (debug_x_ht_level >= 2) { - tprintf(" xht range min=%d, max=%d\n", min_xht, max_xht); + tprintf(" xht range min={}, max={}\n", min_xht, max_xht); } // The range of expected heights gets a vote equal to the distance // of the actual top from the expected top. @@ -158,7 +157,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh int min_shift = min_bottom - bottom; int max_shift = max_bottom - bottom; if (debug_x_ht_level >= 2) { - tprintf(" bottom shift min=%d, max=%d\n", min_shift, max_shift); + tprintf(" bottom shift min={}, max={}\n", min_shift, max_shift); } // The range of expected shifts gets a vote equal to the min distance // of the actual bottom from the expected bottom, spread over the @@ -185,7 +184,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh if (shift_stats.get_total() > top_stats.get_total()) { bottom_shift = IntCastRounded(shift_stats.median()); if (debug_x_ht_level >= 2) { - tprintf("Applying bottom shift=%d\n", bottom_shift); + tprintf("Applying bottom shift={}\n", bottom_shift); } } } while (bottom_shift != 0 && top_stats.get_total() < shift_stats.get_total()); diff --git a/src/ccmain/linerec.cpp b/src/ccmain/linerec.cpp index 91146df8..b860b87f 100644 --- a/src/ccmain/linerec.cpp +++ b/src/ccmain/linerec.cpp @@ -45,7 +45,7 @@ bool Tesseract::TrainLineRecognizer(const char *input_imagename, const std::stri if (applybox_page > 0) { // Load existing document for the previous pages. if (!images.LoadDocument(lstmf_name.c_str(), 0, 0, nullptr)) { - tprintf("Failed to read training data from %s!\n", lstmf_name.c_str()); + tprintf("Failed to read training data from {}!\n", lstmf_name); return false; } } @@ -54,17 +54,17 @@ bool Tesseract::TrainLineRecognizer(const char *input_imagename, const std::stri // Get the boxes for this page, if there are any. if (!ReadAllBoxes(applybox_page, false, input_imagename, &boxes, &texts, nullptr, nullptr) || boxes.empty()) { - tprintf("Failed to read boxes from %s\n", input_imagename); + tprintf("Failed to read boxes from {}\n", input_imagename); return false; } TrainFromBoxes(boxes, texts, block_list, &images); if (images.PagesSize() == 0) { - tprintf("Failed to read pages from %s\n", input_imagename); + tprintf("Failed to read pages from {}\n", input_imagename); return false; } images.Shuffle(); if (!images.SaveDocument(lstmf_name.c_str(), nullptr)) { - tprintf("Failed to write training data to %s!\n", lstmf_name.c_str()); + tprintf("Failed to write training data to {}!\n", lstmf_name); return false; } return true; @@ -112,7 +112,7 @@ void Tesseract::TrainFromBoxes(const std::vector &boxes, const std::vector } ImageData *imagedata = nullptr; if (best_block == nullptr) { - tprintf("No block overlapping textline: %s\n", line_str.c_str()); + tprintf("No block overlapping textline: {}\n", line_str); } else { imagedata = GetLineData(line_box, boxes, texts, start_box, end_box, *best_block); } diff --git a/src/ccmain/output.cpp b/src/ccmain/output.cpp index 73f73294..76b4bcbf 100644 --- a/src/ccmain/output.cpp +++ b/src/ccmain/output.cpp @@ -174,7 +174,7 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it, set_unlv_suspects(word); check_debug_pt(word, 120); if (tessedit_rejection_debug) { - tprintf("Dict word: \"%s\": %d\n", word->best_choice->debug_string().c_str(), + tprintf("Dict word: \"{}\": {}\n", word->best_choice->debug_string(), dict_word(*(word->best_choice))); } if (!word->word->flag(W_REP_CHAR) || !tessedit_write_rep_codes) { @@ -232,7 +232,7 @@ char determine_newline_type( // test line ends end_gap = block_box.right() - word_box.right(); end_gap -= static_cast(block->space()); width = next_box.right() - next_box.left(); - // tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n", + // tprintf("end_gap={}-{}={}, width={}-{}={}, nl={}\n", // block_box.right(),word_box.right(),end_gap, // next_box.right(),next_box.left(),width, // end_gap>width ? CTRL_HARDLINE : CTRL_NEWLINE); diff --git a/src/ccmain/pageiterator.cpp b/src/ccmain/pageiterator.cpp index 64ff7f66..fae45e4e 100644 --- a/src/ccmain/pageiterator.cpp +++ b/src/ccmain/pageiterator.cpp @@ -648,8 +648,8 @@ void PageIterator::BeginWord(int offset) { word_length_ = word_res->best_choice->length(); if (word_res->box_word != nullptr) { if (word_res->box_word->length() != static_cast(word_length_)) { - tprintf("Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ", - word_length_, word_res->best_choice->unichar_string().c_str(), + tprintf("Corrupted word! best_choice[len={}] = {}, box_word[len={}]: ", + word_length_, word_res->best_choice->unichar_string(), word_res->box_word->length()); word_res->box_word->bounding_box().print(); } diff --git a/src/ccmain/paragraphs.cpp b/src/ccmain/paragraphs.cpp index fec08810..c70cdb39 100644 --- a/src/ccmain/paragraphs.cpp +++ b/src/ccmain/paragraphs.cpp @@ -74,13 +74,13 @@ static bool AcceptableRowArgs(int debug_level, int min_num_rows, const char *fun const std::vector *rows, int row_start, int row_end) { if (row_start < 0 || static_cast(row_end) > rows->size() || row_start > row_end) { - tprintf("Invalid arguments rows[%d, %d) while rows is of size %zu.\n", row_start, row_end, + tprintf("Invalid arguments rows[{}, {}) while rows is of size {}.\n", row_start, row_end, rows->size()); return false; } if (row_end - row_start < min_num_rows) { if (debug_level > 1) { - tprintf("# Too few rows[%d, %d) for %s.\n", row_start, row_end, function_name); + tprintf("# Too few rows[{}, {}) for {}.\n", row_start, row_end, function_name); } return false; } @@ -121,7 +121,7 @@ static void PrintTable(const std::vector> &rows, const for (const auto &row : rows) { for (unsigned c = 0; c < row.size(); c++) { if (c > 0) { - tprintf("%s", colsep); + tprintf("{}", colsep); } tprintf(col_width_patterns[c].c_str(), row[c].c_str()); } @@ -172,7 +172,7 @@ static void PrintDetectorState(const ParagraphTheory &theory, tprintf("Active Paragraph Models:\n"); unsigned m = 0; for (const auto &model : theory.models()) { - tprintf(" %d: %s\n", ++m, model->ToString().c_str()); + tprintf(" {}: {}\n", ++m, model->ToString()); } } @@ -181,7 +181,7 @@ static void DebugDump(bool should_print, const char *phase, const ParagraphTheor if (!should_print) { return; } - tprintf("# %s\n", phase); + tprintf("# {}\n", phase); PrintDetectorState(theory, rows); } @@ -190,7 +190,7 @@ static void PrintRowRange(const std::vector &rows, int row_ int row_end) { tprintf("======================================\n"); for (int row = row_start; row < row_end; row++) { - tprintf("%s\n", rows[row].ri_->text.c_str()); + tprintf("{}\n", rows[row].ri_->text.c_str()); } tprintf("======================================\n"); } @@ -912,8 +912,8 @@ struct GeometricClassifierState { CalculateTabStops(r, r_start, r_end, tolerance, &left_tabs, &right_tabs); if (debug_level >= 3) { tprintf( - "Geometry: TabStop cluster tolerance = %d; " - "%zu left tabs; %zu right tabs\n", + "Geometry: TabStop cluster tolerance = {}; " + "{} left tabs; {} right tabs\n", tolerance, left_tabs.size(), right_tabs.size()); } ltr = (*r)[r_start].ri_->ltr; @@ -974,7 +974,7 @@ struct GeometricClassifierState { if (debug_level < min_debug_level) { return; } - tprintf("# %s\n", why); + tprintf("# {}\n", why); PrintRows(); } @@ -1071,7 +1071,7 @@ static void GeometricClassifyThreeTabStopTextBlock(int debug_level, GeometricCla if (debug_level > 0) { tprintf( "# Not enough variety for clear outline classification. " - "Guessing these are %s aligned based on script.\n", + "Guessing these are {} aligned based on script.\n", s.ltr ? "left" : "right"); s.PrintRows(); } @@ -1138,7 +1138,7 @@ static void GeometricClassify(int debug_level, std::vector } if (debug_level > 1) { tprintf("###############################################\n"); - tprintf("##### GeometricClassify( rows[%d:%d) ) ####\n", row_start, row_end); + tprintf("##### GeometricClassify( rows[{}:{}) ) ####\n", row_start, row_end); tprintf("###############################################\n"); } RecomputeMarginsAndClearHypotheses(rows, row_start, row_end, 10); @@ -1213,11 +1213,11 @@ static void GeometricClassify(int debug_level, std::vector } else { // Ambiguous! Probably lineated (poetry) if (debug_level > 1) { - tprintf("# Cannot determine %s indent likely to start paragraphs.\n", + tprintf("# Cannot determine {} indent likely to start paragraphs.\n", s.just == tesseract::JUSTIFICATION_LEFT ? "left" : "right"); - tprintf("# Indent of %d looks like a first line %d%% of the time.\n", + tprintf("# Indent of {} looks like a first line {}% of the time.\n", s.AlignTabs()[0].center, percent0firsts); - tprintf("# Indent of %d looks like a first line %d%% of the time.\n", + tprintf("# Indent of {} looks like a first line {}% of the time.\n", s.AlignTabs()[1].center, percent1firsts); s.PrintRows(); } @@ -2041,7 +2041,7 @@ static void StrongEvidenceClassify(int debug_level, std::vector 1) { tprintf("#############################################\n"); - tprintf("# StrongEvidenceClassify( rows[%d:%d) )\n", row_start, row_end); + tprintf("# StrongEvidenceClassify( rows[{}:{}) )\n", row_start, row_end); tprintf("#############################################\n"); } diff --git a/src/ccmain/pgedit.cpp b/src/ccmain/pgedit.cpp index 31f16b9b..834c81d4 100644 --- a/src/ccmain/pgedit.cpp +++ b/src/ccmain/pgedit.cpp @@ -881,7 +881,7 @@ bool Tesseract::word_dumper(PAGE_RES_IT *pr_it) { word_res->word->print(); if (word_res->blamer_bundle != nullptr && wordrec_debug_blamer && word_res->blamer_bundle->incorrect_result_reason() != IRR_CORRECT) { - tprintf("Current blamer debug: %s\n", word_res->blamer_bundle->debug().c_str()); + tprintf("Current blamer debug: {}\n", word_res->blamer_bundle->debug().c_str()); } return true; } diff --git a/src/ccmain/recogtraining.cpp b/src/ccmain/recogtraining.cpp index af63dec0..35d67db9 100644 --- a/src/ccmain/recogtraining.cpp +++ b/src/ccmain/recogtraining.cpp @@ -49,7 +49,7 @@ FILE *Tesseract::init_recog_training(const char *filename) { output_fname += ".txt"; FILE *output_file = fopen(output_fname.c_str(), "a+"); if (output_file == nullptr) { - tprintf("Error: Could not open file %s\n", output_fname.c_str()); + tprintf("Error: Could not open file {}\n", output_fname.c_str()); ASSERT_HOST(output_file); } return output_file; @@ -94,7 +94,7 @@ void Tesseract::recog_training_segmented(const char *filename, PAGE_RES *page_re // ReadNextBox() will close box_file FILE *box_file = fopen(box_fname.c_str(), "r"); if (box_file == nullptr) { - tprintf("Error: Could not open file %s\n", box_fname.c_str()); + tprintf("Error: Could not open file {}\n", box_fname.c_str()); ASSERT_HOST(box_file); } @@ -156,7 +156,7 @@ void Tesseract::recog_training_segmented(const char *filename, PAGE_RES *page_re "TODO(antonova): clean up recog_training_segmented; " " It examined only a small fraction of the ambigs image.\n"); } - tprintf("recog_training_segmented: examined %d / %d words.\n", examined_words, total_words); + tprintf("recog_training_segmented: examined {} / {} words.\n", examined_words, total_words); } // Helper prints the given set of blob choices. @@ -214,7 +214,7 @@ void Tesseract::ambigs_classify_and_output(const char *label, PAGE_RES_IT *pr_it // Compute the number of unichars in the label. std::vector encoding; if (!unicharset.encode_string(label, true, &encoding, nullptr, nullptr)) { - tprintf("Not outputting illegal unichar %s\n", label); + tprintf("Not outputting illegal unichar {}\n", label); return; } diff --git a/src/ccmain/resultiterator.cpp b/src/ccmain/resultiterator.cpp index 9ee348c7..2cf5f674 100644 --- a/src/ccmain/resultiterator.cpp +++ b/src/ccmain/resultiterator.cpp @@ -541,7 +541,7 @@ bool ResultIterator::Next(PageIteratorLevel level) { at_beginning_of_minor_run_ = (word_indices[j - 1] == kMinorRunStart); // awesome, we move to word_indices[j] if (BidiDebug(3)) { - tprintf("Next(RIL_WORD): %d -> %d\n", this_word_index, word_indices[j]); + tprintf("Next(RIL_WORD): {} -> {}\n", this_word_index, word_indices[j]); } PageIterator::RestartRow(); for (int k = 0; k < word_indices[j]; k++) { @@ -552,7 +552,7 @@ bool ResultIterator::Next(PageIteratorLevel level) { } } if (BidiDebug(3)) { - tprintf("Next(RIL_WORD): %d -> EOL\n", this_word_index); + tprintf("Next(RIL_WORD): {} -> EOL\n", this_word_index); } // we're going off the end of the text line. return Next(RIL_TEXTLINE); @@ -731,15 +731,13 @@ void ResultIterator::IterateAndAppendUTF8TextlineText(std::string *text) { std::vector textline_order; std::vector dirs; CalculateTextlineOrder(current_paragraph_is_ltr_, *this, &dirs, &textline_order); - tprintf("Strong Script dirs [%p/P=%s]: ", - static_cast(it_->row()), + tprintf("Strong Script dirs [{}/P={}]: ", static_cast(it_->row()), current_paragraph_is_ltr_ ? "ltr" : "rtl"); PrintScriptDirs(dirs); - tprintf("Logical textline order [%p/P=%s]: ", - static_cast(it_->row()), + tprintf("Logical textline order [{}/P={}]: ", static_cast(it_->row()), current_paragraph_is_ltr_ ? "ltr" : "rtl"); for (int i : textline_order) { - tprintf("%d ", i); + tprintf("{} ", i); } tprintf("\n"); } @@ -753,11 +751,11 @@ void ResultIterator::IterateAndAppendUTF8TextlineText(std::string *text) { AppendUTF8WordText(text); words_appended++; if (BidiDebug(2)) { - tprintf("Num spaces=%d, text=%s\n", numSpaces, text->c_str()); + tprintf("Num spaces={}, text={}\n", numSpaces, *text); } } while (Next(RIL_WORD) && !IsAtBeginningOf(RIL_TEXTLINE)); if (BidiDebug(1)) { - tprintf("%d words printed\n", words_appended); + tprintf("{} words printed\n", words_appended); } *text += line_separator_; // If we just finished a paragraph, add an extra newline. diff --git a/src/ccmain/superscript.cpp b/src/ccmain/superscript.cpp index 68ff974b..a7b25ee5 100644 --- a/src/ccmain/superscript.cpp +++ b/src/ccmain/superscript.cpp @@ -169,13 +169,13 @@ bool Tesseract::SubAndSuperscriptFix(WERD_RES *word) { } if (superscript_debug >= 1) { - tprintf("Candidate for superscript detection: %s (", + tprintf("Candidate for superscript detection: {} (", word->best_choice->unichar_string().c_str()); if (num_leading || num_remainder_leading) { - tprintf("%d.%d %s-leading ", num_leading, num_remainder_leading, leading_pos); + tprintf("{}.{} {}-leading ", num_leading, num_remainder_leading, leading_pos); } if (num_trailing || num_remainder_trailing) { - tprintf("%d.%d %s-trailing ", num_trailing, num_remainder_trailing, trailing_pos); + tprintf("{}.{} {}-trailing ", num_trailing, num_remainder_trailing, trailing_pos); } tprintf(")\n"); } @@ -404,12 +404,12 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading // Adjust our expectations about the baseline for this prefix. if (superscript_debug >= 3) { - tprintf(" recognizing first %d chopped blobs\n", num_chopped_leading); + tprintf(" recognizing first {} chopped blobs\n", num_chopped_leading); } recog_word_recursive(prefix); if (superscript_debug >= 2) { - tprintf(" The leading bits look like %s %s\n", ScriptPosToString(leading_pos), - prefix->best_choice->unichar_string().c_str()); + tprintf(" The leading bits look like {} {}\n", ScriptPosToString(leading_pos), + prefix->best_choice->unichar_string()); } // Restore the normal y-position penalties. @@ -418,7 +418,7 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading } if (superscript_debug >= 3) { - tprintf(" recognizing middle %d chopped blobs\n", + tprintf(" recognizing middle {} chopped blobs\n", num_chopped - num_chopped_leading - num_chopped_trailing); } @@ -428,12 +428,12 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading classify_integer_matcher_multiplier.set_value(0); if (superscript_debug >= 3) { - tprintf(" recognizing last %d chopped blobs\n", num_chopped_trailing); + tprintf(" recognizing last {} chopped blobs\n", num_chopped_trailing); } recog_word_recursive(suffix); if (superscript_debug >= 2) { - tprintf(" The trailing bits look like %s %s\n", ScriptPosToString(trailing_pos), - suffix->best_choice->unichar_string().c_str()); + tprintf(" The trailing bits look like {} {}\n", ScriptPosToString(trailing_pos), + suffix->best_choice->unichar_string()); } // Restore the normal y-position penalties. @@ -476,8 +476,8 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading } if (superscript_debug >= 1) { - tprintf("%s superscript fix: %s\n", *is_good ? "ACCEPT" : "REJECT", - core->best_choice->unichar_string().c_str()); + tprintf("{} superscript fix: {}\n", *is_good ? "ACCEPT" : "REJECT", + core->best_choice->unichar_string()); } return core; } @@ -550,14 +550,12 @@ bool Tesseract::BelievableSuperscript(bool debug, const WERD_RES &word, float ce } const char *char_str = wc.unicharset()->id_to_unichar(unichar_id); if (bad_certainty) { - tprintf( - " Rejecting: don't believe character %s with certainty %.2f " + tprintf(" Rejecting: don't believe character {} with certainty %.2f " "which is less than threshold %.2f\n", char_str, char_certainty, certainty_threshold); } if (bad_height) { - tprintf( - " Rejecting: character %s seems too small @ %.2f versus " + tprintf(" Rejecting: character {} seems too small @ %.2f versus " "expected %.2f\n", char_str, char_height, normal_height); } diff --git a/src/ccmain/tessedit.cpp b/src/ccmain/tessedit.cpp index c97ce83c..c83f9900 100644 --- a/src/ccmain/tessedit.cpp +++ b/src/ccmain/tessedit.cpp @@ -88,7 +88,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0, // Initialize TessdataManager. std::string tessdata_path = language_data_path_prefix + kTrainedDataSuffix; if (!mgr->is_loaded() && !mgr->Init(tessdata_path.c_str())) { - tprintf("Error opening data file %s\n", tessdata_path.c_str()); + tprintf("Error opening data file {}\n", tessdata_path.c_str()); tprintf( "Please make sure the TESSDATA_PREFIX environment variable is set" " to your \"tessdata\" directory.\n"); @@ -131,7 +131,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0, for (unsigned i = 0; i < vars_vec->size(); ++i) { if (!ParamUtils::SetParam((*vars_vec)[i].c_str(), (*vars_values)[i].c_str(), set_params_constraint, this->params())) { - tprintf("Warning: The parameter '%s' was not found.\n", (*vars_vec)[i].c_str()); + tprintf("Warning: The parameter '{}' was not found.\n", (*vars_vec)[i].c_str()); } } } @@ -142,7 +142,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0, ParamUtils::PrintParams(params_file, this->params()); fclose(params_file); } else { - tprintf("Failed to open %s for writing params.\n", tessedit_write_params_to_file.c_str()); + tprintf("Failed to open {} for writing params.\n", tessedit_write_params_to_file.c_str()); } } @@ -186,7 +186,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0, 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", + "not present in {}!!\n", tessdata_path.c_str()); return false; } @@ -327,7 +327,7 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba if (!loaded_primary) { if (result < 0) { - tprintf("Failed loading language '%s'\n", lang_str); + tprintf("Failed loading language '{}'\n", lang_str); } else { ParseLanguageString(tess_to_init->tessedit_load_sublangs, &langs_to_load, &langs_not_to_load); @@ -335,7 +335,7 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba } } else { if (result < 0) { - tprintf("Failed loading language '%s'\n", lang_str); + tprintf("Failed loading language '{}'\n", lang_str); delete tess_to_init; } else { sub_langs_.push_back(tess_to_init); diff --git a/src/ccstruct/blamer.cpp b/src/ccstruct/blamer.cpp index 92260054..72b7e011 100644 --- a/src/ccstruct/blamer.cpp +++ b/src/ccstruct/blamer.cpp @@ -551,7 +551,7 @@ void BlamerBundle::LastChanceBlame(bool debug, WERD_RES *word) { word->blamer_bundle->SetBlame(IRR_UNKNOWN, debug_str, word->best_choice, debug); } else if (irr != IRR_CORRECT && correct) { if (debug) { - tprintf("Corrected %s\n", word->blamer_bundle->debug_.c_str()); + tprintf("Corrected {}\n", word->blamer_bundle->debug_); } word->blamer_bundle->incorrect_result_reason_ = IRR_CORRECT; word->blamer_bundle->debug_ = ""; @@ -568,7 +568,7 @@ void BlamerBundle::SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debu misadaption_debug_ += "): "; FillDebugString("", best_choice, misadaption_debug_); if (debug) { - tprintf("%s\n", misadaption_debug_.c_str()); + tprintf("{}\n", misadaption_debug_); } } } diff --git a/src/ccstruct/blamer.h b/src/ccstruct/blamer.h index 2cfd6a74..763e610b 100644 --- a/src/ccstruct/blamer.h +++ b/src/ccstruct/blamer.h @@ -299,7 +299,7 @@ private: debug_ += " to blame: "; FillDebugString(msg, choice, debug_); if (debug) { - tprintf("SetBlame(): %s", debug_.c_str()); + tprintf("SetBlame(): {}", debug_); } } diff --git a/src/ccutil/object_cache.h b/src/ccutil/object_cache.h index 8d442e4c..7a81b848 100644 --- a/src/ccutil/object_cache.h +++ b/src/ccutil/object_cache.h @@ -41,10 +41,9 @@ public: for (auto &it : cache_) { if (it.count > 0) { tprintf( - "ObjectCache(%p)::~ObjectCache(): WARNING! LEAK! object %p " - "still has count %d (id %s)\n", - static_cast(this), static_cast(it.object), - it.count, it.id.c_str()); + "ObjectCache({})::~ObjectCache(): WARNING! LEAK! object {} " + "still has count {} (id {})\n", + static_cast(this), static_cast(it.object), it.count, it.id.c_str()); } else { delete it.object; it.object = nullptr; diff --git a/src/ccutil/tprintf.cpp b/src/ccutil/tprintf.cpp index 3c5f7e2f..764c25c1 100644 --- a/src/ccutil/tprintf.cpp +++ b/src/ccutil/tprintf.cpp @@ -26,7 +26,6 @@ #include "params.h" #include // for INT_MAX -#include #include namespace tesseract { @@ -38,7 +37,7 @@ INT_VAR(log_level, INT_MAX, "Logging level"); static STRING_VAR(debug_file, "", "File to send tprintf output to"); // Trace printf -void tprintf(const char *format, ...) { +void vTessPrint(fmt::string_view format, fmt::format_args args) { const char *debug_file_name = debug_file.c_str(); static FILE *debugfp = nullptr; // debug file @@ -62,14 +61,11 @@ void tprintf(const char *format, ...) { debugfp = nullptr; } - va_list args; // variable args - va_start(args, format); // variable list if (debugfp != nullptr) { - vfprintf(debugfp, format, args); + fmt::vprint(debugfp, format, args); } else { - vfprintf(stderr, format, args); + fmt::vprint(stderr, format, args); } - va_end(args); } } // namespace tesseract diff --git a/src/ccutil/tprintf.h b/src/ccutil/tprintf.h index bb995cd4..52c115ab 100644 --- a/src/ccutil/tprintf.h +++ b/src/ccutil/tprintf.h @@ -19,22 +19,23 @@ #ifndef TESSERACT_CCUTIL_TPRINTF_H #define TESSERACT_CCUTIL_TPRINTF_H -#include "params.h" // for BOOL_VAR_H +#include "params.h" // for BOOL_VAR_H +#include // for fmt #include // for TESS_API namespace tesseract { -#if !defined(__GNUC__) && !defined(__attribute__) -# define __attribute__(attr) // compiler without support for __attribute__ -#endif - // Disable some log messages by setting log_level > 0. extern TESS_API INT_VAR_H(log_level); +// Helper function for tprintf. +extern TESS_API void vTessPrint(fmt::string_view format, fmt::format_args args); + // Main logging function. -extern TESS_API void tprintf( // Trace printf - const char *format, ...) // Message - __attribute__((format(printf, 1, 2))); +template +void tprintf(const S *format, Args &&...args) { + vTessPrint(format, fmt::make_args_checked(format, args...)); +} } // namespace tesseract diff --git a/src/dict/dict.cpp b/src/dict/dict.cpp index dbb7e0b6..0411defa 100644 --- a/src/dict/dict.cpp +++ b/src/dict/dict.cpp @@ -253,7 +253,7 @@ void Dict::Load(const std::string &lang, TessdataManager *data_file) { } if (!trie_ptr->read_and_add_word_list(name.c_str(), getUnicharset(), Trie::RRP_REVERSE_IF_HAS_RTL)) { - tprintf("Error: failed to load %s\n", name.c_str()); + tprintf("Error: failed to load {}\n", name); delete trie_ptr; } else { dawgs_.push_back(trie_ptr); @@ -271,7 +271,7 @@ void Dict::Load(const std::string &lang, TessdataManager *data_file) { name += user_patterns_suffix; } if (!trie_ptr->read_pattern_list(name.c_str(), getUnicharset())) { - tprintf("Error: failed to load %s\n", name.c_str()); + tprintf("Error: failed to load {}\n", name); delete trie_ptr; } else { dawgs_.push_back(trie_ptr); @@ -326,7 +326,7 @@ void Dict::LoadLSTM(const std::string &lang, TessdataManager *data_file) { } if (!trie_ptr->read_and_add_word_list(name.c_str(), getUnicharset(), Trie::RRP_REVERSE_IF_HAS_RTL)) { - tprintf("Error: failed to load %s\n", name.c_str()); + tprintf("Error: failed to load {}\n", name); delete trie_ptr; } else { dawgs_.push_back(trie_ptr); @@ -344,7 +344,7 @@ void Dict::LoadLSTM(const std::string &lang, TessdataManager *data_file) { name += user_patterns_suffix; } if (!trie_ptr->read_pattern_list(name.c_str(), getUnicharset())) { - tprintf("Error: failed to load %s\n", name.c_str()); + tprintf("Error: failed to load {}\n", name); delete trie_ptr; } else { dawgs_.push_back(trie_ptr); @@ -411,8 +411,8 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset, if (dawg_debug_level >= 3) { tprintf( - "def_letter_is_okay: current unichar=%s word_end=%d" - " num active dawgs=%zu\n", + "def_letter_is_okay: current unichar={} word_end={}" + " num active dawgs={}\n", getUnicharset().debug_str(unichar_id).c_str(), word_end, dawg_args->active_dawgs->size()); } @@ -456,7 +456,7 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset, EDGE_REF dawg_edge = sdawg->edge_char_of(0, ch, word_end); if (dawg_edge != NO_EDGE) { if (dawg_debug_level >= 3) { - tprintf("Letter found in dawg %d\n", sdawg_index); + tprintf("Letter found in dawg {}\n", sdawg_index); } dawg_args->updated_dawgs->add_unique( DawgPosition(sdawg_index, dawg_edge, pos.punc_index, punc_transition_edge, false), @@ -529,12 +529,12 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset, : dawg->edge_char_of(node, char_for_dawg(unicharset, unichar_id, dawg), word_end); if (dawg_debug_level >= 3) { - tprintf("Active dawg: [%d, " REFFORMAT "] edge=" REFFORMAT "\n", pos.dawg_index, node, edge); + tprintf("Active dawg: [{}, {}] edge={}\n", pos.dawg_index, node, edge); } if (edge != NO_EDGE) { // the unichar was found in the current dawg if (dawg_debug_level >= 3) { - tprintf("Letter found in dawg %d\n", pos.dawg_index); + tprintf("Letter found in dawg {}\n", pos.dawg_index); } if (word_end && punc_dawg && !punc_dawg->end_of_word(pos.punc_ref)) { if (dawg_debug_level >= 3) { @@ -563,7 +563,7 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset, dawg_args->permuter = curr_perm; } if (dawg_debug_level >= 2) { - tprintf("Returning %d for permuter code for this character.\n", dawg_args->permuter); + tprintf("Returning {} for permuter code for this character.\n", dawg_args->permuter); } return dawg_args->permuter; } @@ -587,9 +587,9 @@ void Dict::ProcessPatternEdges(const Dawg *dawg, const DawgPosition &pos, UNICHA continue; } if (dawg_debug_level >= 3) { - tprintf("Pattern dawg: [%d, " REFFORMAT "] edge=" REFFORMAT "\n", pos.dawg_index, node, + tprintf("Pattern dawg: [{}, {}] edge={}\n", pos.dawg_index, node, edge); - tprintf("Letter found in pattern dawg %d\n", pos.dawg_index); + tprintf("Letter found in pattern dawg {}\n", pos.dawg_index); } if (dawg->permuter() > *curr_perm) { *curr_perm = dawg->permuter(); @@ -612,7 +612,7 @@ void Dict::init_active_dawgs(DawgPositionVector *active_dawgs, bool ambigs_mode) *active_dawgs = hyphen_active_dawgs_; if (dawg_debug_level >= 3) { for (unsigned i = 0; i < hyphen_active_dawgs_.size(); ++i) { - tprintf("Adding hyphen beginning dawg [%d, " REFFORMAT "]\n", + tprintf("Adding hyphen beginning dawg [{}, {}]\n", hyphen_active_dawgs_[i].dawg_index, hyphen_active_dawgs_[i].dawg_ref); } } @@ -632,12 +632,12 @@ void Dict::default_dawgs(DawgPositionVector *dawg_pos_vec, bool suppress_pattern if (dawg_ty == DAWG_TYPE_PUNCTUATION) { dawg_pos_vec->push_back(DawgPosition(-1, NO_EDGE, i, NO_EDGE, false)); if (dawg_debug_level >= 3) { - tprintf("Adding beginning punc dawg [%d, " REFFORMAT "]\n", i, NO_EDGE); + tprintf("Adding beginning punc dawg [{}, {}]\n", i, NO_EDGE); } } else if (!punc_dawg_available || !subsumed_by_punc) { dawg_pos_vec->push_back(DawgPosition(i, NO_EDGE, -1, NO_EDGE, false)); if (dawg_debug_level >= 3) { - tprintf("Adding beginning dawg [%d, " REFFORMAT "]\n", i, NO_EDGE); + tprintf("Adding beginning dawg [{}, {}]\n", i, NO_EDGE); } } } @@ -698,7 +698,7 @@ void Dict::add_document_word(const WERD_CHOICE &best_choice) { filename += ".doc"; FILE *doc_word_file = fopen(filename.c_str(), "a"); if (doc_word_file == nullptr) { - tprintf("Error: Could not open file %s\n", filename.c_str()); + tprintf("Error: Could not open file {}\n", filename); ASSERT_HOST(doc_word_file); } fprintf(doc_word_file, "%s\n", best_choice.debug_string().c_str()); diff --git a/src/textord/colfind.cpp b/src/textord/colfind.cpp index 3e97c285..f9be054f 100644 --- a/src/textord/colfind.cpp +++ b/src/textord/colfind.cpp @@ -707,8 +707,7 @@ bool ColumnFinder::AssignColumns(const PartSetVector &part_sets) { } else { column_set_costs[part_i][col_i] = INT32_MAX; if (debug) { - tprintf("Set id %d did not match at y=%d, lineset =%p\n", - col_i, part_i, static_cast(line_set)); + tprintf("Set id {} did not match at y={}, lineset ={}\n", col_i, part_i, static_cast(line_set)); } } } diff --git a/src/textord/colpartition.cpp b/src/textord/colpartition.cpp index 1b7029c8..b203e827 100644 --- a/src/textord/colpartition.cpp +++ b/src/textord/colpartition.cpp @@ -1001,7 +1001,7 @@ void ColPartition::ComputeLimits() { } if (TabFind::WithinTestRegion(2, bounding_box_.left(), bounding_box_.bottom())) { - tprintf("Recomputed box for partition %p\n", static_cast(this)); + tprintf("Recomputed box for partition {}\n", static_cast(this)); Print(); } } diff --git a/src/training/common/commontraining.cpp b/src/training/common/commontraining.cpp index 473cb70b..bfb44816 100644 --- a/src/training/common/commontraining.cpp +++ b/src/training/common/commontraining.cpp @@ -490,10 +490,10 @@ void MergeInsignificantProtos(LIST ProtoList, const char *label, CLUSTERER *Clus } if (best_match != nullptr && !best_match->Significant) { if (debug) { - auto bestMatchNumSamples = best_match->NumSamples; - auto prototypeNumSamples = Prototype->NumSamples; - tprintf("Merging red clusters (%d+%d) at %g,%g and %g,%g\n", bestMatchNumSamples, - prototypeNumSamples, best_match->Mean[0], best_match->Mean[1], Prototype->Mean[0], + auto BestMatchNumSamples = best_match->NumSamples; + auto PrototypeNumSamples = Prototype->NumSamples; + tprintf("Merging red clusters ({}+{}) at {},{} and {},{}\n", BestMatchNumSamples, + PrototypeNumSamples, best_match->Mean[0], best_match->Mean[1], Prototype->Mean[0], Prototype->Mean[1]); } best_match->NumSamples = diff --git a/src/training/mftraining.cpp b/src/training/mftraining.cpp index bed3a8f5..90523836 100644 --- a/src/training/mftraining.cpp +++ b/src/training/mftraining.cpp @@ -77,9 +77,9 @@ static void DisplayProtoList(const char *ch, LIST protolist) { window->DrawTo((x + dx) * 256, (y + dy) * 256); auto prototypeNumSamples = prototype->NumSamples; if (prototype->Significant) { - tprintf("Green proto at (%g,%g)+(%g,%g) %d samples\n", x, y, dx, dy, prototypeNumSamples); + tprintf("Green proto at ({},{})+({},{}) {} samples\n", x, y, dx, dy, prototypeNumSamples); } else if (prototype->NumSamples > 0 && !prototype->Merged) { - tprintf("Red proto at (%g,%g)+(%g,%g) %d samples\n", x, y, dx, dy, prototypeNumSamples); + tprintf("Red proto at ({},{})+({},{}) {} samples\n", x, y, dx, dy, prototypeNumSamples); } } window->Update(); diff --git a/src/wordrec/language_model.cpp b/src/wordrec/language_model.cpp index 50747607..0c6fac66 100644 --- a/src/wordrec/language_model.cpp +++ b/src/wordrec/language_model.cpp @@ -254,7 +254,7 @@ bool LanguageModel::UpdateState(bool just_classified, int curr_col, int curr_row tprintf("\nUpdateState: col=%d row=%d %s", curr_col, curr_row, just_classified ? "just_classified" : ""); if (language_model_debug_level > 5) { - tprintf("(parent=%p)\n", static_cast(parent_node)); + tprintf("(parent={})\n", static_cast(parent_node)); } else { tprintf("\n"); } @@ -588,7 +588,7 @@ bool LanguageModel::AddViterbiStateEntry(LanguageModelFlagsType top_choice_flags dict_->getUnicharset().id_to_unichar(b->unichar_id()), b->rating(), b->certainty(), top_choice_flags); if (language_model_debug_level > 5) { - tprintf(" parent_vse=%p\n", static_cast(parent_vse)); + tprintf(" parent_vse={}\n", static_cast(parent_vse)); } else { tprintf("\n"); }