From 46fa59aadc6f147373f8b2319cd76cff4be6713f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 31 Mar 2019 17:48:24 +0200 Subject: [PATCH] ccstruct: Replace BOOL8, TRUE, FALSE by bool, true, false and modernize code Signed-off-by: Stefan Weil --- src/ccstruct/blobbox.cpp | 4 ++-- src/ccstruct/blread.cpp | 6 ++---- src/ccstruct/coutln.cpp | 3 +-- src/ccstruct/ocrblock.cpp | 3 +-- src/ccstruct/ocrblock.h | 9 ++++----- src/ccstruct/ocrrow.cpp | 9 ++++----- src/ccstruct/pageres.cpp | 9 ++++----- src/ccstruct/pageres.h | 3 +-- src/ccstruct/pdblock.cpp | 6 +++--- src/ccstruct/polyaprx.cpp | 6 ++---- src/ccstruct/quspline.cpp | 2 +- src/ccstruct/statistc.cpp | 5 ++--- src/ccstruct/stepblob.cpp | 8 +++----- 13 files changed, 30 insertions(+), 43 deletions(-) diff --git a/src/ccstruct/blobbox.cpp b/src/ccstruct/blobbox.cpp index db664b8d4d..b5ccfec228 100644 --- a/src/ccstruct/blobbox.cpp +++ b/src/ccstruct/blobbox.cpp @@ -29,7 +29,7 @@ #include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE, C_OUTLINE_LIST #include "environ.h" // for l_uint32 #include "helpers.h" // for UpdateRange, IntCastRounded -#include "host.h" // for NearlyEqual, TRUE +#include "host.h" // for NearlyEqual #include "points.h" // for operator+=, ICOORD::rotate struct Pix; @@ -94,7 +94,7 @@ void BLOBNBOX::merge( //merge blobs ) { box += nextblob->box; //merge boxes set_diacritic_box(box); - nextblob->joined = TRUE; + nextblob->joined = true; } diff --git a/src/ccstruct/blread.cpp b/src/ccstruct/blread.cpp index ffe417563e..febb1ea5c7 100644 --- a/src/ccstruct/blread.cpp +++ b/src/ccstruct/blread.cpp @@ -2,7 +2,6 @@ * File: blread.cpp (Formerly pdread.c) * Description: Friend function of BLOCK to read the uscan pd file. * Author: Ray Smith - * Created: Mon Mar 18 14:39:00 GMT 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +18,6 @@ #include "blread.h" #include // for fclose, fopen, FILE -#include "host.h" // for TRUE #include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only) #include "scanutils.h" // for tfscanf @@ -51,7 +49,7 @@ bool read_unlv_file( //print list of sides } else { while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) { //make rect block - block = new BLOCK (name.string (), TRUE, 0, 0, + block = new BLOCK (name.string (), true, 0, 0, (int16_t) x, (int16_t) (ysize - y - height), (int16_t) (x + width), (int16_t) (ysize - y)); //on end of list @@ -64,6 +62,6 @@ bool read_unlv_file( //print list of sides void FullPageBlock(int width, int height, BLOCK_LIST *blocks) { BLOCK_IT block_it(blocks); - auto* block = new BLOCK("", TRUE, 0, 0, 0, 0, width, height); + auto* block = new BLOCK("", true, 0, 0, 0, 0, width, height); block_it.add_to_end(block); } diff --git a/src/ccstruct/coutln.cpp b/src/ccstruct/coutln.cpp index a1dea5d06a..d10a470b5a 100644 --- a/src/ccstruct/coutln.cpp +++ b/src/ccstruct/coutln.cpp @@ -2,7 +2,6 @@ * File: coutln.cpp (Formerly coutline.c) * Description: Code for the C_OUTLINE class. * Author: Ray Smith - * Created: Mon Oct 07 16:01:57 BST 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -460,7 +459,7 @@ int32_t C_OUTLINE::count_transitions(int32_t threshold) { /** * @name C_OUTLINE::operator< * - * @return TRUE if the left operand is inside the right one. + * @return true if the left operand is inside the right one. * @param other other outline */ diff --git a/src/ccstruct/ocrblock.cpp b/src/ccstruct/ocrblock.cpp index f165af88df..1f1494c718 100644 --- a/src/ccstruct/ocrblock.cpp +++ b/src/ccstruct/ocrblock.cpp @@ -2,7 +2,6 @@ * File: ocrblock.cpp (Formerly block.c) * Description: BLOCK member functions and iterator functions. * Author: Ray Smith - * Created: Fri Mar 15 09:41:28 GMT 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +31,7 @@ ELISTIZE (BLOCK) * Constructor for a simple rectangular block. */ BLOCK::BLOCK(const char *name, ///< filename - BOOL8 prop, ///< proportional + bool prop, ///< proportional int16_t kern, ///< kerning int16_t space, ///< spacing int16_t xmin, ///< bottom left diff --git a/src/ccstruct/ocrblock.h b/src/ccstruct/ocrblock.h index bb82ddfc42..82c4aada82 100644 --- a/src/ccstruct/ocrblock.h +++ b/src/ccstruct/ocrblock.h @@ -2,7 +2,6 @@ * File: ocrblock.h (Formerly block.h) * Description: Page block class definition. * Author: Ray Smith - * Created: Thu Mar 14 17:32:01 GMT 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,7 +39,7 @@ class BLOCK:public ELIST_LINK pdblk.hand_poly = nullptr; } BLOCK(const char *name, ///< filename - BOOL8 prop, ///< proportional + bool prop, ///< proportional int16_t kern, ///< kerning int16_t space, ///< spacing int16_t xmin, ///< bottom left @@ -57,7 +56,7 @@ class BLOCK:public ELIST_LINK * @param space inter word size * @param ch_pitch pitch if fixed */ - void set_stats(BOOL8 prop, + void set_stats(bool prop, int16_t kern, int16_t space, int16_t ch_pitch) { @@ -75,7 +74,7 @@ class BLOCK:public ELIST_LINK font_class = font; } /// return proportional - BOOL8 prop() const { + bool prop() const { return proportional; } bool right_to_left() const { @@ -192,7 +191,7 @@ class BLOCK:public ELIST_LINK PDBLK pdblk; ///< Page Description Block private: - BOOL8 proportional; ///< proportional + bool proportional; ///< proportional bool right_to_left_; ///< major script is right to left. int8_t kerning; ///< inter blob gap int16_t spacing; ///< inter word gap diff --git a/src/ccstruct/ocrrow.cpp b/src/ccstruct/ocrrow.cpp index f6f8dbdb2c..57fa21b4d2 100644 --- a/src/ccstruct/ocrrow.cpp +++ b/src/ccstruct/ocrrow.cpp @@ -2,7 +2,6 @@ * File: ocrrow.cpp (Formerly row.c) * Description: Code for the ROW class. * Author: Ray Smith - * Created: Tue Oct 08 15:58:04 BST 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -124,15 +123,15 @@ void ROW::recalc_bounding_box() { //recalculate BB for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { word = it.data (); if (it.at_first ()) - word->set_flag (W_BOL, TRUE); + word->set_flag (W_BOL, true); else //not start of line - word->set_flag (W_BOL, FALSE); + word->set_flag (W_BOL, false); if (it.at_last ()) - word->set_flag (W_EOL, TRUE); + word->set_flag(W_EOL, true); else //not end of line - word->set_flag (W_EOL, FALSE); + word->set_flag(W_EOL, false); //extend BB as reqd bound_box += word->bounding_box (); } diff --git a/src/ccstruct/pageres.cpp b/src/ccstruct/pageres.cpp index 2267d7feee..30a6330c8e 100644 --- a/src/ccstruct/pageres.cpp +++ b/src/ccstruct/pageres.cpp @@ -29,7 +29,6 @@ #include "blobs.h" // for TWERD, TBLOB #include "boxword.h" // for BoxWord #include "errcode.h" // for ASSERT_HOST -#include "host.h" // for TRUE, FALSE #include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only) #include "ocrrow.h" // for ROW, ROW_IT #include "pdblock.h" // for PDBLK @@ -141,7 +140,7 @@ ROW_RES::ROW_RES(bool merge_similar_words, ROW *the_row) { if (add_next_word) { ASSERT_HOST(combo != nullptr); // We are adding this word to the combination. - word_res->part_of_combo = TRUE; + word_res->part_of_combo = true; combo->copy_on(word_res); } else if (merge_similar_words) { union_box = word_res->word->bounding_box(); @@ -179,7 +178,7 @@ ROW_RES::ROW_RES(bool merge_similar_words, ROW *the_row) { combo->combination = true; word_res_it.add_to_end(combo); } - word_res->part_of_combo = TRUE; + word_res->part_of_combo = true; } else { combo = nullptr; } @@ -1104,8 +1103,8 @@ void WERD_RES::InitNonPointers() { unlv_crunch_mode = CR_NONE; small_caps = false; odd_size = false; - italic = FALSE; - bold = FALSE; + italic = false; + bold = false; // The fontinfos and tesseract count as non-pointers as they point to // data owned elsewhere. fontinfo = nullptr; diff --git a/src/ccstruct/pageres.h b/src/ccstruct/pageres.h index 0c91ea4f8b..23c8c57998 100644 --- a/src/ccstruct/pageres.h +++ b/src/ccstruct/pageres.h @@ -2,7 +2,6 @@ * File: pageres.h (Formerly page_res.h) * Description: Results classes used by control.c * Author: Phil Cheatle - * Created: Tue Sep 22 08:42:49 BST 1992 * * (C) Copyright 1992, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -292,7 +291,7 @@ class WERD_RES : public ELIST_LINK { REJMAP reject_map; // best_choice rejects bool tess_failed; /* - If tess_failed is TRUE, one of the following tests failed when Tess + If tess_failed is true, one of the following tests failed when Tess returned: - The outword blob list was not the same length as the best_choice string; - The best_choice string contained ALL blanks; diff --git a/src/ccstruct/pdblock.cpp b/src/ccstruct/pdblock.cpp index 41ef61043e..96814e7011 100644 --- a/src/ccstruct/pdblock.cpp +++ b/src/ccstruct/pdblock.cpp @@ -2,7 +2,6 @@ * File: pdblock.cpp * Description: PDBLK member functions and iterator functions. * Author: Ray Smith - * Created: Fri Mar 15 09:41:28 GMT 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,6 +20,7 @@ #include #include // std::unique_ptr #include "allheaders.h" +#include "host.h" // for PRId32 // Include automatically generated configuration file if running autoconf. #ifdef HAVE_CONFIG_H @@ -83,7 +83,7 @@ void PDBLK::set_sides( //set vertex lists /********************************************************************** * PDBLK::contains * - * Return TRUE if the given point is within the block. + * Return true if the given point is within the block. **********************************************************************/ bool PDBLK::contains( //test containment @@ -354,7 +354,7 @@ int16_t BLOCK_LINE_IT::get_line( //get a line //get block box block->bounding_box (bleft, tright); if (y < bleft.y () || y >= tright.y ()) { - // block->print(stderr,FALSE); + // block->print(stderr,false); BADBLOCKLINE.error ("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y); } diff --git a/src/ccstruct/polyaprx.cpp b/src/ccstruct/polyaprx.cpp index b8115c8287..008c6a932a 100644 --- a/src/ccstruct/polyaprx.cpp +++ b/src/ccstruct/polyaprx.cpp @@ -2,7 +2,6 @@ * File: polyaprx.cpp (Formerly polygon.c) * Description: Code for polygonal approximation from old edgeprog. * Author: Ray Smith - * Created: Thu Nov 25 11:42:04 GMT 1993 * * (C) Copyright 1993, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +21,6 @@ #include "blobs.h" // for EDGEPT, TPOINT, VECTOR, TESSLINE #include "coutln.h" // for C_OUTLINE #include "errcode.h" // for ASSERT_HOST -#include "host.h" // for FALSE, TRUE #include "mod128.h" // for DIR128 #include "params.h" // for BoolParam, BOOL_VAR #include "points.h" // for ICOORD @@ -33,8 +31,8 @@ #define EXTERN #define FASTEDGELENGTH 256 -EXTERN BOOL_VAR(poly_debug, FALSE, "Debug old poly"); -EXTERN BOOL_VAR(poly_wide_objects_better, TRUE, +EXTERN BOOL_VAR(poly_debug, false, "Debug old poly"); +EXTERN BOOL_VAR(poly_wide_objects_better, true, "More accurate approx on wide things"); #define FIXED 4 /*OUTLINE point is fixed */ diff --git a/src/ccstruct/quspline.cpp b/src/ccstruct/quspline.cpp index be150cedea..4e47764dbc 100644 --- a/src/ccstruct/quspline.cpp +++ b/src/ccstruct/quspline.cpp @@ -265,7 +265,7 @@ void QSPLINE::move( // reposition spline /********************************************************************** * QSPLINE::overlap * - * Return TRUE if spline2 overlaps this by no more than fraction less + * Return true if spline2 overlaps this by no more than fraction less * than the bounds of this. **********************************************************************/ diff --git a/src/ccstruct/statistc.cpp b/src/ccstruct/statistc.cpp index 998653a468..61f0cff663 100644 --- a/src/ccstruct/statistc.cpp +++ b/src/ccstruct/statistc.cpp @@ -1,8 +1,7 @@ /********************************************************************** * File: statistc.cpp (Formerly stats.c) * Description: Simple statistical package for integer values. - * Author: Ray Smith - * Created: Mon Feb 04 16:56:05 GMT 1991 + * Author: Ray Smith * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -256,7 +255,7 @@ double STATS::median() const { //get median /********************************************************************** * STATS::local_min * - * Return TRUE if this point is a local min. + * Return true if this point is a local min. **********************************************************************/ bool STATS::local_min(int32_t x) const { if (buckets_ == nullptr) { diff --git a/src/ccstruct/stepblob.cpp b/src/ccstruct/stepblob.cpp index 8d2820efca..51d9ffdc1a 100644 --- a/src/ccstruct/stepblob.cpp +++ b/src/ccstruct/stepblob.cpp @@ -2,7 +2,6 @@ * File: stepblob.cpp (Formerly cblob.c) * Description: Code for C_BLOB class. * Author: Ray Smith - * Created: Tue Oct 08 10:41:13 BST 1991 * * (C) Copyright 1991, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +24,6 @@ #include "stepblob.h" #include "allheaders.h" // for pixCreate, pixGetDepth #include "genericvector.h" // for GenericVector -#include "host.h" // for TRUE, FALSE #include "points.h" // for operator+=, FCOORD, ICOORD class DENORM; @@ -147,7 +145,7 @@ static void reverse_outline_list(C_OUTLINE_LIST *list) { for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { C_OUTLINE* outline = it.data(); outline->reverse(); // reverse it - outline->set_flag(COUT_INVERSE, TRUE); + outline->set_flag(COUT_INVERSE, true); if (!outline->child()->empty()) reverse_outline_list(outline->child()); } @@ -230,9 +228,9 @@ void C_BLOB::CheckInverseFlagAndDirection() { if (outline->turn_direction() < 0) { outline->reverse(); reverse_outline_list(outline->child()); - outline->set_flag(COUT_INVERSE, TRUE); + outline->set_flag(COUT_INVERSE, true); } else { - outline->set_flag(COUT_INVERSE, FALSE); + outline->set_flag(COUT_INVERSE, false); } } }