Skip to content

Commit

Permalink
reformat code (files with tabs)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Dec 10, 2022
1 parent f77c63d commit d89ff46
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BasedOnStyle: Google

# Modifications for Tesseract.

ColumnLimit: 100

This comment has been minimized.

Copy link
@stweil

stweil Dec 12, 2022

Member

Please revert that change. Many tools (and printers) still work better with the default width.

This comment has been minimized.

Copy link
@zdenop

zdenop Dec 12, 2022

Author Contributor

When I leave there default value (80) clang format reformat a lot of tesseract code. Is that intended?
Because setting (any) value and ignoring it is useless....

This comment has been minimized.

Copy link
@stweil

stweil Dec 12, 2022

Member

Egor changed the width to 100 in commit afa476b, so some code was reformatted with that setting. The default 80 was restored in commit 83cdcd0. It is intended that code which gets reformatted limits the line length to 80.

This comment has been minimized.

Copy link
@zdenop

zdenop Dec 12, 2022

Author Contributor

ok. reverted

# Only merge empty functions.
AllowShortFunctionsOnASingleLine: Empty
# Do not allow short if statements.
Expand Down
6 changes: 3 additions & 3 deletions src/arch/dotproductsse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/ccstruct/ratngs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ccutil/ambigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/classify/adaptmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/dict/permdawg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
18 changes: 10 additions & 8 deletions src/tesseract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> *vars_vec,
std::vector<std::string> *vars_values, l_int32 *arg_i,
tesseract::PageSegMode *pagesegmode, tesseract::OcrEngineMode *enginemode) {
bool *list_langs, bool *print_parameters, bool *print_fonts_table,
std::vector<std::string> *vars_vec, std::vector<std::string> *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++) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d89ff46

Please sign in to comment.