Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues reported by LGTM #2000

Merged
merged 6 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/ccmain/paragraphs_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ struct LineHypothesis {
LineHypothesis(const LineHypothesis &other)
: ty(other.ty), model(other.model) {}

// Copy assignment operator.
LineHypothesis& operator=(const LineHypothesis& other) {
ty = other.ty;
model = other.model;
return *this;
}

bool operator==(const LineHypothesis &other) const {
return ty == other.ty && model == other.model;
}
Expand Down
2 changes: 2 additions & 0 deletions src/ccstruct/blamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ struct BlamerBundle {
void SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debug);

private:
// Copy assignment operator (currently unused, therefore private).
BlamerBundle& operator=(const BlamerBundle& other);
void SetBlame(IncorrectResultReason irr, const STRING &msg,
const WERD_CHOICE *choice, bool debug) {
incorrect_result_reason_ = irr;
Expand Down
3 changes: 3 additions & 0 deletions src/ccstruct/ocrrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class ROW:public ELIST_LINK
ROW& operator= (const ROW & source);

private:
// Copy constructor (currently unused, therefore private).
ROW(const ROW& source);

int32_t kerning; //inter char gap
int32_t spacing; //inter word gap
TBOX bound_box; //bounding box
Expand Down
11 changes: 8 additions & 3 deletions src/ccstruct/params_training_featdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,19 @@ int ParamsTrainingFeatureByName(const char *name);
// Entry with features extracted from a single OCR hypothesis for a word.
struct ParamsTrainingHypothesis {
ParamsTrainingHypothesis() : cost(0.0) {
memset(features, 0, sizeof(float) * PTRAIN_NUM_FEATURE_TYPES);
memset(features, 0, sizeof(features));
}
ParamsTrainingHypothesis(const ParamsTrainingHypothesis &other) {
memcpy(features, other.features,
sizeof(float) * PTRAIN_NUM_FEATURE_TYPES);
memcpy(features, other.features, sizeof(features));
str = other.str;
cost = other.cost;
}
ParamsTrainingHypothesis& operator=(const ParamsTrainingHypothesis& other) {
memcpy(features, other.features, sizeof(features));
str = other.str;
cost = other.cost;
return *this;
}
float features[PTRAIN_NUM_FEATURE_TYPES];
STRING str; // string corresponding to word hypothesis (for debugging)
float cost; // path cost computed by segsearch
Expand Down
18 changes: 18 additions & 0 deletions src/ccstruct/ratngs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ BLOB_CHOICE::BLOB_CHOICE(const BLOB_CHOICE &other) : ELIST_LINK(other) {
fonts_ = other.fonts_;
}

// Copy assignment operator.
BLOB_CHOICE& BLOB_CHOICE::operator=(const BLOB_CHOICE& other) {
ELIST_LINK::operator=(other);
unichar_id_ = other.unichar_id();
rating_ = other.rating();
certainty_ = other.certainty();
fontinfo_id_ = other.fontinfo_id();
fontinfo_id2_ = other.fontinfo_id2();
script_id_ = other.script_id();
matrix_cell_ = other.matrix_cell_;
min_xheight_ = other.min_xheight_;
max_xheight_ = other.max_xheight_;
yshift_ = other.yshift();
classifier_ = other.classifier_;
fonts_ = other.fonts_;
return *this;
}

// Returns true if *this and other agree on the baseline and x-height
// to within some tolerance based on a given estimate of the x-height.
bool BLOB_CHOICE::PosAndSizeAgree(const BLOB_CHOICE& other, float x_height,
Expand Down
3 changes: 3 additions & 0 deletions src/ccstruct/ratngs.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ class BLOB_CHOICE: public ELIST_LINK
}

private:
// Copy assignment operator.
BLOB_CHOICE& operator=(const BLOB_CHOICE& other);

UNICHAR_ID unichar_id_; // unichar id
// Fonts and scores. Allowed to be empty.
GenericVector<tesseract::ScoredFont> fonts_;
Expand Down
2 changes: 2 additions & 0 deletions src/textord/fpchop.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class C_OUTLINE_FRAG:public ELIST_LINK
int16_t ycoord; //coord of cut pt

private:
// Copy constructor (currently unused, therefore private).
C_OUTLINE_FRAG(const C_OUTLINE_FRAG& other);
};

ELISTIZEH(C_OUTLINE_FRAG)
Expand Down