Skip to content

Commit

Permalink
classify: Replace BOOL8, TRUE, FALSE by bool, true, false
Browse files Browse the repository at this point in the history
Simplify also some related code.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Mar 31, 2019
1 parent 30ee3af commit 87a9736
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 47 deletions.
20 changes: 9 additions & 11 deletions src/classify/adaptmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "fontinfo.h" // for ScoredFont, FontSet
#include "genericvector.h" // for GenericVector
#include "helpers.h" // for IntCastRounded, ClipToRange
#include "host.h" // for FALSE, TRUE
#include "intfx.h" // for BlobToTrainingSample, INT_FX_RESULT_S...
#include "intmatcher.h" // for CP_RESULT_STRUCT, IntegerMatcher
#include "intproto.h" // for INT_FEATURE_STRUCT, (anonymous), Clas...
Expand Down Expand Up @@ -454,8 +453,8 @@ void Classify::LearnPieces(const char* fontname, int start, int length,
*
* Globals:
* - #AdaptedTemplates current set of adapted templates
* - #classify_save_adapted_templates TRUE if templates should be saved
* - #classify_enable_adaptive_matcher TRUE if adaptive matcher is enabled
* - #classify_save_adapted_templates true if templates should be saved
* - #classify_enable_adaptive_matcher true if adaptive matcher is enabled
*/
void Classify::EndAdaptiveClassifier() {
STRING Filename;
Expand Down Expand Up @@ -648,7 +647,7 @@ void Classify::StartBackupAdaptiveClassifier() {
*
* Globals:
* - #EnableLearning
* set to TRUE by this routine
* set to true by this routine
*/
void Classify::SettupPass1() {
EnableLearning = classify_enable_learning;
Expand All @@ -665,10 +664,10 @@ void Classify::SettupPass1() {
* learning is disabled.
*
* Globals:
* - #EnableLearning set to FALSE by this routine
* - #EnableLearning set to false by this routine
*/
void Classify::SettupPass2() {
EnableLearning = FALSE;
EnableLearning = false;
getDict().SettupStopperPass2();

} /* SettupPass2 */
Expand Down Expand Up @@ -811,8 +810,7 @@ int Classify::GetAdaptiveFeatures(TBLOB *Blob,
-----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Return TRUE if the specified word is
* acceptable for adaptation.
* Return true if the specified word is acceptable for adaptation.
*
* Globals: none
*
Expand Down Expand Up @@ -1979,7 +1977,7 @@ void Classify::MakePermanent(ADAPT_TEMPLATES Templates,
*
* Globals: none
*
* @return TRUE if TempProto is converted, FALSE otherwise
* @return true if TempProto is converted, false otherwise
*/
int MakeTempProtoPerm(void *item1, void *item2) {
ADAPT_CLASS Class;
Expand All @@ -1995,14 +1993,14 @@ int MakeTempProtoPerm(void *item1, void *item2) {

if (TempProto->ProtoId > Config->MaxProtoId ||
!test_bit (Config->Protos, TempProto->ProtoId))
return FALSE;
return false;

MakeProtoPermanent(Class, TempProto->ProtoId);
AddProtoToClassPruner(&(TempProto->Proto), ProtoKey->ClassId,
ProtoKey->Templates->Templates);
FreeTempProto(TempProto);

return TRUE;
return true;
} /* MakeTempProtoPerm */

/*---------------------------------------------------------------------------*/
Expand Down
20 changes: 5 additions & 15 deletions src/classify/clusttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,8 @@ PARAM_DESC *ReadParamDesc(TFile *fp, uint16_t N) {
"%" QUOTED_TOKENSIZE "s %" QUOTED_TOKENSIZE "s %f %f",
linear_token, essential_token, &ParamDesc[i].Min,
&ParamDesc[i].Max) == 4);
if (linear_token[0] == 'c')
ParamDesc[i].Circular = TRUE;
else
ParamDesc[i].Circular = FALSE;

if (linear_token[0] == 'e')
ParamDesc[i].NonEssential = FALSE;
else
ParamDesc[i].NonEssential = TRUE;
ParamDesc[i].Circular = (linear_token[0] == 'c');
ParamDesc[i].NonEssential = (linear_token[0] != 'e');
ParamDesc[i].Range = ParamDesc[i].Max - ParamDesc[i].Min;
ParamDesc[i].HalfRange = ParamDesc[i].Range / 2;
ParamDesc[i].MidRange = (ParamDesc[i].Max + ParamDesc[i].Min) / 2;
Expand Down Expand Up @@ -110,10 +103,7 @@ PROTOTYPE *ReadPrototype(TFile *fp, uint16_t N) {
}
Proto = (PROTOTYPE *)Emalloc(sizeof(PROTOTYPE));
Proto->Cluster = nullptr;
if (sig_token[0] == 's')
Proto->Significant = TRUE;
else
Proto->Significant = FALSE;
Proto->Significant = (sig_token[0] == 's');

switch (shape_token[0]) {
case 's':
Expand Down Expand Up @@ -334,8 +324,8 @@ void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle) {
* @param N number of dimensions in feature space
* @param ParamDesc descriptions for each dimension
* @param ProtoList list of prototypes to be written
* @param WriteSigProtos TRUE to write out significant prototypes
* @param WriteInsigProtos TRUE to write out insignificants
* @param WriteSigProtos true to write out significant prototypes
* @param WriteInsigProtos true to write out insignificants
* @note Globals: None
* @return None
*/
Expand Down
3 changes: 1 addition & 2 deletions src/classify/intmatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
** Filename: intmatcher.h
** Purpose: Interface to high level generic classifier routines.
** Author: Robert Moss
** History: Wed Feb 13 15:24:15 MST 1991, RWM, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,7 +23,7 @@
// but turned on/off on the language-by-language basis or depending
// on particular properties of the corpus (e.g. when we expect the
// images to have low exposure).
extern BOOL_VAR_H(disable_character_fragments, FALSE,
extern BOOL_VAR_H(disable_character_fragments, false,
"Do not include character fragments in the"
" results of the classifier");

Expand Down
11 changes: 5 additions & 6 deletions src/classify/intproto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
** Filename: intproto.c
** Purpose: Definition of data structures for integer protos.
** Author: Dan Johnson
** History: Thu Feb 7 14:38:16 1991, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1153,8 +1152,8 @@ void DoFill(FILL_SPEC *FillSpec,
FillSpec->YEnd = NUM_CP_BUCKETS - 1;

for (Y = FillSpec->YStart; Y <= FillSpec->YEnd; Y++)
for (Angle = FillSpec->AngleStart;
TRUE; CircularIncrement (Angle, NUM_CP_BUCKETS)) {
for (Angle = FillSpec->AngleStart; ;
CircularIncrement(Angle, NUM_CP_BUCKETS)) {
OldWord = Pruner->p[X][Y][Angle][WordIndex];
if (ClassCount > (OldWord & ClassMask)) {
OldWord &= ~ClassMask;
Expand All @@ -1167,10 +1166,10 @@ void DoFill(FILL_SPEC *FillSpec,
} /* DoFill */

/**
* Return TRUE if the specified table filler is done, i.e.
* Return true if the specified table filler is done, i.e.
* if it has no more lines to fill.
* @param Filler table filler to check if done
* @return TRUE if no more lines to fill, FALSE otherwise.
* @return true if no more lines to fill, false otherwise.
* @note Globals: none
*/
bool FillerDone(TABLE_FILLER* Filler) {
Expand Down Expand Up @@ -1212,7 +1211,7 @@ void FillPPCircularBits(uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR]
if (LastBucket >= NUM_PP_BUCKETS)
LastBucket -= NUM_PP_BUCKETS;
if (debug) tprintf("Circular fill from %d to %d", FirstBucket, LastBucket);
for (i = FirstBucket; TRUE; CircularIncrement (i, NUM_PP_BUCKETS)) {
for (i = FirstBucket; true; CircularIncrement (i, NUM_PP_BUCKETS)) {
SET_BIT (ParamTable[i], Bit);

/* exit loop after we have set the bit for the last bucket */
Expand Down
10 changes: 4 additions & 6 deletions src/classify/mfoutline.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
** Filename: mfoutline.h
** Purpose: Interface spec for fx outline structures
** Author: Dan Johnson
** History: Thu May 17 08:55:32 1990, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,7 +22,6 @@
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "blobs.h"
#include "host.h"
#include "oldlist.h"
#include "fpoint.h"
#include "params.h"
Expand All @@ -41,8 +39,8 @@ typedef struct {
FPOINT Point;
float Slope;
unsigned Padding:20;
BOOL8 Hidden:TRUE;
BOOL8 ExtremityMark:TRUE;
bool Hidden:true;
bool ExtremityMark:true;
DIRECTION Direction:4;
DIRECTION PreviousDirection:4;
} MFEDGEPT;
Expand Down Expand Up @@ -70,8 +68,8 @@ typedef enum {
#define MakeOutlineCircular(O) (set_rest (last (O), (O)))

/* macros for manipulating micro-feature outline edge points */
#define ClearMark(P) ((P)->ExtremityMark = FALSE)
#define MarkPoint(P) ((P)->ExtremityMark = TRUE)
#define ClearMark(P) ((P)->ExtremityMark = false)
#define MarkPoint(P) ((P)->ExtremityMark = true)

/**----------------------------------------------------------------------------
Public Function Prototypes
Expand Down
7 changes: 3 additions & 4 deletions src/classify/ocrfeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
** Filename: ocrfeatures.cpp
** Purpose: Generic definition of a feature.
** Author: Dan Johnson
** History: Mon May 21 10:49:04 1990, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -31,12 +30,12 @@
----------------------------------------------------------------------------*/
/**
* Add a feature to a feature set. If the feature set is
* already full, FALSE is returned to indicate that the
* feature could not be added to the set; otherwise, TRUE is
* already full, false is returned to indicate that the
* feature could not be added to the set; otherwise, true is
* returned.
* @param FeatureSet set of features to add Feature to
* @param Feature feature to be added to FeatureSet
* @return TRUE if feature added to set, FALSE if set is already full.
* @return true if feature added to set, false if set is already full.
*/
bool AddFeature(FEATURE_SET FeatureSet, FEATURE Feature) {
if (FeatureSet->NumFeatures >= FeatureSet->MaxNumFeatures) {
Expand Down
5 changes: 2 additions & 3 deletions src/classify/ocrfeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
** Filename: features.h
** Purpose: Generic definition of a feature.
** Author: Dan Johnson
** History: Sun May 20 10:28:30 1990, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -41,8 +40,8 @@ struct INT_FX_RESULT_STRUCT;
// parameters are required to be the first parameters in the feature.

struct PARAM_DESC {
int8_t Circular; // TRUE if dimension wraps around
int8_t NonEssential; // TRUE if dimension not used in searches
bool Circular; // true if dimension wraps around
bool NonEssential; // true if dimension not used in searches
float Min; // low end of range for circular dimensions
float Max; // high end of range for circular dimensions
float Range; // Max - Min
Expand Down

0 comments on commit 87a9736

Please sign in to comment.