ccstruct: Replace BOOL8, TRUE, FALSE by bool, true, false and modernize code

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2019-03-31 17:48:24 +02:00
parent 92b9f9f8de
commit 46fa59aadc
13 changed files with 30 additions and 43 deletions

View File

@ -29,7 +29,7 @@
#include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE, C_OUTLINE_LIST #include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE, C_OUTLINE_LIST
#include "environ.h" // for l_uint32 #include "environ.h" // for l_uint32
#include "helpers.h" // for UpdateRange, IntCastRounded #include "helpers.h" // for UpdateRange, IntCastRounded
#include "host.h" // for NearlyEqual, TRUE #include "host.h" // for NearlyEqual
#include "points.h" // for operator+=, ICOORD::rotate #include "points.h" // for operator+=, ICOORD::rotate
struct Pix; struct Pix;
@ -94,7 +94,7 @@ void BLOBNBOX::merge( //merge blobs
) { ) {
box += nextblob->box; //merge boxes box += nextblob->box; //merge boxes
set_diacritic_box(box); set_diacritic_box(box);
nextblob->joined = TRUE; nextblob->joined = true;
} }

View File

@ -2,7 +2,6 @@
* File: blread.cpp (Formerly pdread.c) * File: blread.cpp (Formerly pdread.c)
* Description: Friend function of BLOCK to read the uscan pd file. * Description: Friend function of BLOCK to read the uscan pd file.
* Author: Ray Smith * Author: Ray Smith
* Created: Mon Mar 18 14:39:00 GMT 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -19,7 +18,6 @@
#include "blread.h" #include "blread.h"
#include <cstdio> // for fclose, fopen, FILE #include <cstdio> // for fclose, fopen, FILE
#include "host.h" // for TRUE
#include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only) #include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only)
#include "scanutils.h" // for tfscanf #include "scanutils.h" // for tfscanf
@ -51,7 +49,7 @@ bool read_unlv_file( //print list of sides
} else { } else {
while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) { while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
//make rect block //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, (int16_t) (ysize - y - height),
(int16_t) (x + width), (int16_t) (ysize - y)); (int16_t) (x + width), (int16_t) (ysize - y));
//on end of list //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) { void FullPageBlock(int width, int height, BLOCK_LIST *blocks) {
BLOCK_IT block_it(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); block_it.add_to_end(block);
} }

View File

@ -2,7 +2,6 @@
* File: coutln.cpp (Formerly coutline.c) * File: coutln.cpp (Formerly coutline.c)
* Description: Code for the C_OUTLINE class. * Description: Code for the C_OUTLINE class.
* Author: Ray Smith * Author: Ray Smith
* Created: Mon Oct 07 16:01:57 BST 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** 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< * @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 * @param other other outline
*/ */

View File

@ -2,7 +2,6 @@
* File: ocrblock.cpp (Formerly block.c) * File: ocrblock.cpp (Formerly block.c)
* Description: BLOCK member functions and iterator functions. * Description: BLOCK member functions and iterator functions.
* Author: Ray Smith * Author: Ray Smith
* Created: Fri Mar 15 09:41:28 GMT 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -32,7 +31,7 @@ ELISTIZE (BLOCK)
* Constructor for a simple rectangular block. * Constructor for a simple rectangular block.
*/ */
BLOCK::BLOCK(const char *name, ///< filename BLOCK::BLOCK(const char *name, ///< filename
BOOL8 prop, ///< proportional bool prop, ///< proportional
int16_t kern, ///< kerning int16_t kern, ///< kerning
int16_t space, ///< spacing int16_t space, ///< spacing
int16_t xmin, ///< bottom left int16_t xmin, ///< bottom left

View File

@ -2,7 +2,6 @@
* File: ocrblock.h (Formerly block.h) * File: ocrblock.h (Formerly block.h)
* Description: Page block class definition. * Description: Page block class definition.
* Author: Ray Smith * Author: Ray Smith
* Created: Thu Mar 14 17:32:01 GMT 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -40,7 +39,7 @@ class BLOCK:public ELIST_LINK
pdblk.hand_poly = nullptr; pdblk.hand_poly = nullptr;
} }
BLOCK(const char *name, ///< filename BLOCK(const char *name, ///< filename
BOOL8 prop, ///< proportional bool prop, ///< proportional
int16_t kern, ///< kerning int16_t kern, ///< kerning
int16_t space, ///< spacing int16_t space, ///< spacing
int16_t xmin, ///< bottom left int16_t xmin, ///< bottom left
@ -57,7 +56,7 @@ class BLOCK:public ELIST_LINK
* @param space inter word size * @param space inter word size
* @param ch_pitch pitch if fixed * @param ch_pitch pitch if fixed
*/ */
void set_stats(BOOL8 prop, void set_stats(bool prop,
int16_t kern, int16_t kern,
int16_t space, int16_t space,
int16_t ch_pitch) { int16_t ch_pitch) {
@ -75,7 +74,7 @@ class BLOCK:public ELIST_LINK
font_class = font; font_class = font;
} }
/// return proportional /// return proportional
BOOL8 prop() const { bool prop() const {
return proportional; return proportional;
} }
bool right_to_left() const { bool right_to_left() const {
@ -192,7 +191,7 @@ class BLOCK:public ELIST_LINK
PDBLK pdblk; ///< Page Description Block PDBLK pdblk; ///< Page Description Block
private: private:
BOOL8 proportional; ///< proportional bool proportional; ///< proportional
bool right_to_left_; ///< major script is right to left. bool right_to_left_; ///< major script is right to left.
int8_t kerning; ///< inter blob gap int8_t kerning; ///< inter blob gap
int16_t spacing; ///< inter word gap int16_t spacing; ///< inter word gap

View File

@ -2,7 +2,6 @@
* File: ocrrow.cpp (Formerly row.c) * File: ocrrow.cpp (Formerly row.c)
* Description: Code for the ROW class. * Description: Code for the ROW class.
* Author: Ray Smith * Author: Ray Smith
* Created: Tue Oct 08 15:58:04 BST 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** 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 ()) { for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
word = it.data (); word = it.data ();
if (it.at_first ()) if (it.at_first ())
word->set_flag (W_BOL, TRUE); word->set_flag (W_BOL, true);
else else
//not start of line //not start of line
word->set_flag (W_BOL, FALSE); word->set_flag (W_BOL, false);
if (it.at_last ()) if (it.at_last ())
word->set_flag (W_EOL, TRUE); word->set_flag(W_EOL, true);
else else
//not end of line //not end of line
word->set_flag (W_EOL, FALSE); word->set_flag(W_EOL, false);
//extend BB as reqd //extend BB as reqd
bound_box += word->bounding_box (); bound_box += word->bounding_box ();
} }

View File

@ -29,7 +29,6 @@
#include "blobs.h" // for TWERD, TBLOB #include "blobs.h" // for TWERD, TBLOB
#include "boxword.h" // for BoxWord #include "boxword.h" // for BoxWord
#include "errcode.h" // for ASSERT_HOST #include "errcode.h" // for ASSERT_HOST
#include "host.h" // for TRUE, FALSE
#include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only) #include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only)
#include "ocrrow.h" // for ROW, ROW_IT #include "ocrrow.h" // for ROW, ROW_IT
#include "pdblock.h" // for PDBLK #include "pdblock.h" // for PDBLK
@ -141,7 +140,7 @@ ROW_RES::ROW_RES(bool merge_similar_words, ROW *the_row) {
if (add_next_word) { if (add_next_word) {
ASSERT_HOST(combo != nullptr); ASSERT_HOST(combo != nullptr);
// We are adding this word to the combination. // 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); combo->copy_on(word_res);
} else if (merge_similar_words) { } else if (merge_similar_words) {
union_box = word_res->word->bounding_box(); 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; combo->combination = true;
word_res_it.add_to_end(combo); word_res_it.add_to_end(combo);
} }
word_res->part_of_combo = TRUE; word_res->part_of_combo = true;
} else { } else {
combo = nullptr; combo = nullptr;
} }
@ -1104,8 +1103,8 @@ void WERD_RES::InitNonPointers() {
unlv_crunch_mode = CR_NONE; unlv_crunch_mode = CR_NONE;
small_caps = false; small_caps = false;
odd_size = false; odd_size = false;
italic = FALSE; italic = false;
bold = FALSE; bold = false;
// The fontinfos and tesseract count as non-pointers as they point to // The fontinfos and tesseract count as non-pointers as they point to
// data owned elsewhere. // data owned elsewhere.
fontinfo = nullptr; fontinfo = nullptr;

View File

@ -2,7 +2,6 @@
* File: pageres.h (Formerly page_res.h) * File: pageres.h (Formerly page_res.h)
* Description: Results classes used by control.c * Description: Results classes used by control.c
* Author: Phil Cheatle * Author: Phil Cheatle
* Created: Tue Sep 22 08:42:49 BST 1992
* *
* (C) Copyright 1992, Hewlett-Packard Ltd. * (C) Copyright 1992, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** 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 REJMAP reject_map; // best_choice rejects
bool tess_failed; 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: returned:
- The outword blob list was not the same length as the best_choice string; - The outword blob list was not the same length as the best_choice string;
- The best_choice string contained ALL blanks; - The best_choice string contained ALL blanks;

View File

@ -2,7 +2,6 @@
* File: pdblock.cpp * File: pdblock.cpp
* Description: PDBLK member functions and iterator functions. * Description: PDBLK member functions and iterator functions.
* Author: Ray Smith * Author: Ray Smith
* Created: Fri Mar 15 09:41:28 GMT 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -21,6 +20,7 @@
#include <cstdlib> #include <cstdlib>
#include <memory> // std::unique_ptr #include <memory> // std::unique_ptr
#include "allheaders.h" #include "allheaders.h"
#include "host.h" // for PRId32
// Include automatically generated configuration file if running autoconf. // Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -83,7 +83,7 @@ void PDBLK::set_sides( //set vertex lists
/********************************************************************** /**********************************************************************
* PDBLK::contains * 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 bool PDBLK::contains( //test containment
@ -354,7 +354,7 @@ int16_t BLOCK_LINE_IT::get_line( //get a line
//get block box //get block box
block->bounding_box (bleft, tright); block->bounding_box (bleft, tright);
if (y < bleft.y () || y >= tright.y ()) { 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); BADBLOCKLINE.error ("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y);
} }

View File

@ -2,7 +2,6 @@
* File: polyaprx.cpp (Formerly polygon.c) * File: polyaprx.cpp (Formerly polygon.c)
* Description: Code for polygonal approximation from old edgeprog. * Description: Code for polygonal approximation from old edgeprog.
* Author: Ray Smith * Author: Ray Smith
* Created: Thu Nov 25 11:42:04 GMT 1993
* *
* (C) Copyright 1993, Hewlett-Packard Ltd. * (C) Copyright 1993, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -22,7 +21,6 @@
#include "blobs.h" // for EDGEPT, TPOINT, VECTOR, TESSLINE #include "blobs.h" // for EDGEPT, TPOINT, VECTOR, TESSLINE
#include "coutln.h" // for C_OUTLINE #include "coutln.h" // for C_OUTLINE
#include "errcode.h" // for ASSERT_HOST #include "errcode.h" // for ASSERT_HOST
#include "host.h" // for FALSE, TRUE
#include "mod128.h" // for DIR128 #include "mod128.h" // for DIR128
#include "params.h" // for BoolParam, BOOL_VAR #include "params.h" // for BoolParam, BOOL_VAR
#include "points.h" // for ICOORD #include "points.h" // for ICOORD
@ -33,8 +31,8 @@
#define EXTERN #define EXTERN
#define FASTEDGELENGTH 256 #define FASTEDGELENGTH 256
EXTERN BOOL_VAR(poly_debug, FALSE, "Debug old poly"); EXTERN BOOL_VAR(poly_debug, false, "Debug old poly");
EXTERN BOOL_VAR(poly_wide_objects_better, TRUE, EXTERN BOOL_VAR(poly_wide_objects_better, true,
"More accurate approx on wide things"); "More accurate approx on wide things");
#define FIXED 4 /*OUTLINE point is fixed */ #define FIXED 4 /*OUTLINE point is fixed */

View File

@ -265,7 +265,7 @@ void QSPLINE::move( // reposition spline
/********************************************************************** /**********************************************************************
* QSPLINE::overlap * 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. * than the bounds of this.
**********************************************************************/ **********************************************************************/

View File

@ -1,8 +1,7 @@
/********************************************************************** /**********************************************************************
* File: statistc.cpp (Formerly stats.c) * File: statistc.cpp (Formerly stats.c)
* Description: Simple statistical package for integer values. * Description: Simple statistical package for integer values.
* Author: Ray Smith * Author: Ray Smith
* Created: Mon Feb 04 16:56:05 GMT 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -256,7 +255,7 @@ double STATS::median() const { //get median
/********************************************************************** /**********************************************************************
* STATS::local_min * 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 { bool STATS::local_min(int32_t x) const {
if (buckets_ == nullptr) { if (buckets_ == nullptr) {

View File

@ -2,7 +2,6 @@
* File: stepblob.cpp (Formerly cblob.c) * File: stepblob.cpp (Formerly cblob.c)
* Description: Code for C_BLOB class. * Description: Code for C_BLOB class.
* Author: Ray Smith * Author: Ray Smith
* Created: Tue Oct 08 10:41:13 BST 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -25,7 +24,6 @@
#include "stepblob.h" #include "stepblob.h"
#include "allheaders.h" // for pixCreate, pixGetDepth #include "allheaders.h" // for pixCreate, pixGetDepth
#include "genericvector.h" // for GenericVector #include "genericvector.h" // for GenericVector
#include "host.h" // for TRUE, FALSE
#include "points.h" // for operator+=, FCOORD, ICOORD #include "points.h" // for operator+=, FCOORD, ICOORD
class DENORM; 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()) { for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
C_OUTLINE* outline = it.data(); C_OUTLINE* outline = it.data();
outline->reverse(); // reverse it outline->reverse(); // reverse it
outline->set_flag(COUT_INVERSE, TRUE); outline->set_flag(COUT_INVERSE, true);
if (!outline->child()->empty()) if (!outline->child()->empty())
reverse_outline_list(outline->child()); reverse_outline_list(outline->child());
} }
@ -230,9 +228,9 @@ void C_BLOB::CheckInverseFlagAndDirection() {
if (outline->turn_direction() < 0) { if (outline->turn_direction() < 0) {
outline->reverse(); outline->reverse();
reverse_outline_list(outline->child()); reverse_outline_list(outline->child());
outline->set_flag(COUT_INVERSE, TRUE); outline->set_flag(COUT_INVERSE, true);
} else { } else {
outline->set_flag(COUT_INVERSE, FALSE); outline->set_flag(COUT_INVERSE, false);
} }
} }
} }