diff --git a/.clang-format b/.clang-format index 253a2f2950..c072fd5b4b 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ BasedOnStyle: Google # Modifications for Tesseract. - +ColumnLimit: 100 # Only merge empty functions. AllowShortFunctionsOnASingleLine: Empty # Do not allow short if statements. diff --git a/src/arch/dotproductsse.cpp b/src/arch/dotproductsse.cpp index 9122e9d1b1..b1b62f1d3c 100644 --- a/src/arch/dotproductsse.cpp +++ b/src/arch/dotproductsse.cpp @@ -71,9 +71,9 @@ float DotProductSSE(const float *u, const float *v, int n) { } // Add the 4 sums in sum horizontally. #if 0 - alignas(32) float tmp[4]; - _mm_store_ps(tmp, sum); - float result = tmp[0] + tmp[1] + tmp[2] + tmp[3]; + alignas(32) float tmp[4]; + _mm_store_ps(tmp, sum); + float result = tmp[0] + tmp[1] + tmp[2] + tmp[3]; #else __m128 zero = _mm_setzero_ps(); // https://www.felixcloutier.com/x86/haddps diff --git a/src/ccstruct/ratngs.cpp b/src/ccstruct/ratngs.cpp index 04c6b3e9f7..7cdaa5a9f2 100644 --- a/src/ccstruct/ratngs.cpp +++ b/src/ccstruct/ratngs.cpp @@ -475,7 +475,7 @@ WERD_CHOICE &WERD_CHOICE::operator+=(const WERD_CHOICE &second) { if (second.adjust_factor_ > adjust_factor_) { adjust_factor_ = second.adjust_factor_; } - rating_ += second.rating(); // add ratings + rating_ += second.rating(); // add ratings if (second.certainty() < certainty_) { // take min certainty_ = second.certainty(); } @@ -568,7 +568,7 @@ void WERD_CHOICE::SetScriptPositions(bool small_caps, TWERD *word, int debug) { ScriptPos sp = script_pos_[i]; if (sp == tesseract::SP_SUBSCRIPT || sp == tesseract::SP_SUPERSCRIPT) { ASSERT_HOST(position_counts[sp] > 0); - position_counts[sp]--; + position_counts[sp]--; position_counts[tesseract::SP_NORMAL]++; script_pos_[i] = tesseract::SP_NORMAL; } @@ -583,7 +583,7 @@ void WERD_CHOICE::SetScriptPositions(bool small_caps, TWERD *word, int debug) { TBLOB *tblob = word->blobs[chunk_index]; ScriptPositionOf(true, *unicharset_, tblob->bounding_box(), unichar_id(blob_index)); } - chunk_index += state_.empty() ? 1 : state_[blob_index]; + chunk_index += state_.empty() ? 1 : state_[blob_index]; } } } diff --git a/src/ccutil/ambigs.cpp b/src/ccutil/ambigs.cpp index b595661059..b69c4afc1d 100644 --- a/src/ccutil/ambigs.cpp +++ b/src/ccutil/ambigs.cpp @@ -138,7 +138,7 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET &encoder_set, TFile *ambi ASSERT_HOST(id_to_insert != INVALID_UNICHAR_ID); // Add the new unichar id to adaption_ambigs_entry (only if the // vector does not already contain it) keeping it in sorted order. - size_t j; + size_t j; for (j = 0; j < adaption_ambigs_entry->size() && (*adaption_ambigs_entry)[j] > id_to_insert; ++j) { diff --git a/src/classify/adaptmatch.cpp b/src/classify/adaptmatch.cpp index 75394f4685..5c02c6f363 100644 --- a/src/classify/adaptmatch.cpp +++ b/src/classify/adaptmatch.cpp @@ -327,7 +327,7 @@ void Classify::LearnWord(const char *fontname, WERD_RES *word) { tokens[0] = CHAR_FRAGMENT::to_string(tokens[0].c_str(), frag, word->best_state[ch], pieces_all_natural); - std::string full_string; + std::string full_string; for (unsigned i = 0; i < tokens.size(); i++) { full_string += tokens[i]; if (i != tokens.size() - 1) { @@ -1149,9 +1149,9 @@ void Classify::ExpandShapesAndApplyCorrections(ADAPT_CLASS_STRUCT **classes, boo } } for (auto &m : mapped_results) { - m.rating = ComputeCorrectedRating( - debug, m.unichar_id, cp_rating, int_result->rating, - int_result->feature_misses, bottom, top, blob_length, matcher_multiplier, cn_factors); + m.rating = ComputeCorrectedRating(debug, m.unichar_id, cp_rating, int_result->rating, + int_result->feature_misses, bottom, top, blob_length, + matcher_multiplier, cn_factors); AddNewResult(m, final_results); } return; diff --git a/src/dict/permdawg.cpp b/src/dict/permdawg.cpp index 07f3a59bae..bcdfe1fbb1 100644 --- a/src/dict/permdawg.cpp +++ b/src/dict/permdawg.cpp @@ -115,12 +115,12 @@ void Dict::go_deeper_dawg_fxn(const char *debug, const BLOB_CHOICE_LIST_VECTOR & tprintf("Failed to open output_ambig_words_file %s\n", output_ambig_words_file.c_str()); exit(1); } - std::string word_str; + std::string word_str; word->string_and_lengths(&word_str, nullptr); word_str += " "; fprintf(output_ambig_words_file_, "%s", word_str.c_str()); } - std::string word_str; + std::string word_str; word->string_and_lengths(&word_str, nullptr); word_str += " "; fprintf(output_ambig_words_file_, "%s", word_str.c_str()); diff --git a/src/tesseract.cpp b/src/tesseract.cpp index 0586e08694..e0697aa77f 100644 --- a/src/tesseract.cpp +++ b/src/tesseract.cpp @@ -371,9 +371,10 @@ static bool checkArgValues(int arg, const char *mode, int count) { // NOTE: arg_i is used here to avoid ugly *i so many times in this function static bool ParseArgs(int argc, char **argv, const char **lang, const char **image, const char **outputbase, const char **datapath, l_int32 *dpi, - bool *list_langs, bool *print_parameters, bool* print_fonts_table, std::vector *vars_vec, - std::vector *vars_values, l_int32 *arg_i, - tesseract::PageSegMode *pagesegmode, tesseract::OcrEngineMode *enginemode) { + bool *list_langs, bool *print_parameters, bool *print_fonts_table, + std::vector *vars_vec, std::vector *vars_values, + l_int32 *arg_i, tesseract::PageSegMode *pagesegmode, + tesseract::OcrEngineMode *enginemode) { bool noocr = false; int i; for (i = 1; i < argc && (*outputbase == nullptr || argv[i][0] == '-'); i++) { @@ -421,10 +422,10 @@ static bool ParseArgs(int argc, char **argv, const char **lang, const char **ima }; try { auto loglevel = loglevels.at(loglevel_string); - log_level = loglevel; - } catch(const std::out_of_range& e) { + log_level = loglevel; + } catch (const std::out_of_range &e) { // TODO: Allow numeric argument? - tprintf("Error, unsupported --loglevel %s\n", loglevel_string.c_str()); + tprintf("Error, unsupported --loglevel %s\n", loglevel_string.c_str()); return false; } } else if (strcmp(argv[i], "--user-words") == 0 && i + 1 < argc) { @@ -674,7 +675,8 @@ int main(int argc, char **argv) { #endif // HAVE_TIFFIO_H && _WIN32 if (!ParseArgs(argc, argv, &lang, &image, &outputbase, &datapath, &dpi, &list_langs, - &print_parameters, &print_fonts_table, &vars_vec, &vars_values, &arg_i, &pagesegmode, &enginemode)) { + &print_parameters, &print_fonts_table, &vars_vec, &vars_values, &arg_i, + &pagesegmode, &enginemode)) { return EXIT_FAILURE; } @@ -728,7 +730,7 @@ int main(int argc, char **argv) { #ifndef DISABLED_LEGACY_ENGINE if (print_fonts_table) { - FILE* fout = stdout; + FILE *fout = stdout; fprintf(stdout, "Tesseract fonts table:\n"); api.PrintFontsTable(fout); api.End();