Skip to content

Commit 46fa59a

Browse files
committed
ccstruct: Replace BOOL8, TRUE, FALSE by bool, true, false and modernize code
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 92b9f9f commit 46fa59a

13 files changed

+30
-43
lines changed

src/ccstruct/blobbox.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE, C_OUTLINE_LIST
3030
#include "environ.h" // for l_uint32
3131
#include "helpers.h" // for UpdateRange, IntCastRounded
32-
#include "host.h" // for NearlyEqual, TRUE
32+
#include "host.h" // for NearlyEqual
3333
#include "points.h" // for operator+=, ICOORD::rotate
3434

3535
struct Pix;
@@ -94,7 +94,7 @@ void BLOBNBOX::merge( //merge blobs
9494
) {
9595
box += nextblob->box; //merge boxes
9696
set_diacritic_box(box);
97-
nextblob->joined = TRUE;
97+
nextblob->joined = true;
9898
}
9999

100100

src/ccstruct/blread.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: blread.cpp (Formerly pdread.c)
33
* Description: Friend function of BLOCK to read the uscan pd file.
44
* Author: Ray Smith
5-
* Created: Mon Mar 18 14:39:00 GMT 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +18,6 @@
1918

2019
#include "blread.h"
2120
#include <cstdio> // for fclose, fopen, FILE
22-
#include "host.h" // for TRUE
2321
#include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only)
2422
#include "scanutils.h" // for tfscanf
2523

@@ -51,7 +49,7 @@ bool read_unlv_file( //print list of sides
5149
} else {
5250
while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
5351
//make rect block
54-
block = new BLOCK (name.string (), TRUE, 0, 0,
52+
block = new BLOCK (name.string (), true, 0, 0,
5553
(int16_t) x, (int16_t) (ysize - y - height),
5654
(int16_t) (x + width), (int16_t) (ysize - y));
5755
//on end of list
@@ -64,6 +62,6 @@ bool read_unlv_file( //print list of sides
6462

6563
void FullPageBlock(int width, int height, BLOCK_LIST *blocks) {
6664
BLOCK_IT block_it(blocks);
67-
auto* block = new BLOCK("", TRUE, 0, 0, 0, 0, width, height);
65+
auto* block = new BLOCK("", true, 0, 0, 0, 0, width, height);
6866
block_it.add_to_end(block);
6967
}

src/ccstruct/coutln.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: coutln.cpp (Formerly coutline.c)
33
* Description: Code for the C_OUTLINE class.
44
* Author: Ray Smith
5-
* Created: Mon Oct 07 16:01:57 BST 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -460,7 +459,7 @@ int32_t C_OUTLINE::count_transitions(int32_t threshold) {
460459
/**
461460
* @name C_OUTLINE::operator<
462461
*
463-
* @return TRUE if the left operand is inside the right one.
462+
* @return true if the left operand is inside the right one.
464463
* @param other other outline
465464
*/
466465

src/ccstruct/ocrblock.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: ocrblock.cpp (Formerly block.c)
33
* Description: BLOCK member functions and iterator functions.
44
* Author: Ray Smith
5-
* Created: Fri Mar 15 09:41:28 GMT 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,7 +31,7 @@ ELISTIZE (BLOCK)
3231
* Constructor for a simple rectangular block.
3332
*/
3433
BLOCK::BLOCK(const char *name, ///< filename
35-
BOOL8 prop, ///< proportional
34+
bool prop, ///< proportional
3635
int16_t kern, ///< kerning
3736
int16_t space, ///< spacing
3837
int16_t xmin, ///< bottom left

src/ccstruct/ocrblock.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: ocrblock.h (Formerly block.h)
33
* Description: Page block class definition.
44
* Author: Ray Smith
5-
* Created: Thu Mar 14 17:32:01 GMT 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,7 +39,7 @@ class BLOCK:public ELIST_LINK
4039
pdblk.hand_poly = nullptr;
4140
}
4241
BLOCK(const char *name, ///< filename
43-
BOOL8 prop, ///< proportional
42+
bool prop, ///< proportional
4443
int16_t kern, ///< kerning
4544
int16_t space, ///< spacing
4645
int16_t xmin, ///< bottom left
@@ -57,7 +56,7 @@ class BLOCK:public ELIST_LINK
5756
* @param space inter word size
5857
* @param ch_pitch pitch if fixed
5958
*/
60-
void set_stats(BOOL8 prop,
59+
void set_stats(bool prop,
6160
int16_t kern,
6261
int16_t space,
6362
int16_t ch_pitch) {
@@ -75,7 +74,7 @@ class BLOCK:public ELIST_LINK
7574
font_class = font;
7675
}
7776
/// return proportional
78-
BOOL8 prop() const {
77+
bool prop() const {
7978
return proportional;
8079
}
8180
bool right_to_left() const {
@@ -192,7 +191,7 @@ class BLOCK:public ELIST_LINK
192191
PDBLK pdblk; ///< Page Description Block
193192

194193
private:
195-
BOOL8 proportional; ///< proportional
194+
bool proportional; ///< proportional
196195
bool right_to_left_; ///< major script is right to left.
197196
int8_t kerning; ///< inter blob gap
198197
int16_t spacing; ///< inter word gap

src/ccstruct/ocrrow.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: ocrrow.cpp (Formerly row.c)
33
* Description: Code for the ROW class.
44
* Author: Ray Smith
5-
* Created: Tue Oct 08 15:58:04 BST 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -124,15 +123,15 @@ void ROW::recalc_bounding_box() { //recalculate BB
124123
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
125124
word = it.data ();
126125
if (it.at_first ())
127-
word->set_flag (W_BOL, TRUE);
126+
word->set_flag (W_BOL, true);
128127
else
129128
//not start of line
130-
word->set_flag (W_BOL, FALSE);
129+
word->set_flag (W_BOL, false);
131130
if (it.at_last ())
132-
word->set_flag (W_EOL, TRUE);
131+
word->set_flag(W_EOL, true);
133132
else
134133
//not end of line
135-
word->set_flag (W_EOL, FALSE);
134+
word->set_flag(W_EOL, false);
136135
//extend BB as reqd
137136
bound_box += word->bounding_box ();
138137
}

src/ccstruct/pageres.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "blobs.h" // for TWERD, TBLOB
3030
#include "boxword.h" // for BoxWord
3131
#include "errcode.h" // for ASSERT_HOST
32-
#include "host.h" // for TRUE, FALSE
3332
#include "ocrblock.h" // for BLOCK_IT, BLOCK, BLOCK_LIST (ptr only)
3433
#include "ocrrow.h" // for ROW, ROW_IT
3534
#include "pdblock.h" // for PDBLK
@@ -141,7 +140,7 @@ ROW_RES::ROW_RES(bool merge_similar_words, ROW *the_row) {
141140
if (add_next_word) {
142141
ASSERT_HOST(combo != nullptr);
143142
// We are adding this word to the combination.
144-
word_res->part_of_combo = TRUE;
143+
word_res->part_of_combo = true;
145144
combo->copy_on(word_res);
146145
} else if (merge_similar_words) {
147146
union_box = word_res->word->bounding_box();
@@ -179,7 +178,7 @@ ROW_RES::ROW_RES(bool merge_similar_words, ROW *the_row) {
179178
combo->combination = true;
180179
word_res_it.add_to_end(combo);
181180
}
182-
word_res->part_of_combo = TRUE;
181+
word_res->part_of_combo = true;
183182
} else {
184183
combo = nullptr;
185184
}
@@ -1104,8 +1103,8 @@ void WERD_RES::InitNonPointers() {
11041103
unlv_crunch_mode = CR_NONE;
11051104
small_caps = false;
11061105
odd_size = false;
1107-
italic = FALSE;
1108-
bold = FALSE;
1106+
italic = false;
1107+
bold = false;
11091108
// The fontinfos and tesseract count as non-pointers as they point to
11101109
// data owned elsewhere.
11111110
fontinfo = nullptr;

src/ccstruct/pageres.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: pageres.h (Formerly page_res.h)
33
* Description: Results classes used by control.c
44
* Author: Phil Cheatle
5-
* Created: Tue Sep 22 08:42:49 BST 1992
65
*
76
* (C) Copyright 1992, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -292,7 +291,7 @@ class WERD_RES : public ELIST_LINK {
292291
REJMAP reject_map; // best_choice rejects
293292
bool tess_failed;
294293
/*
295-
If tess_failed is TRUE, one of the following tests failed when Tess
294+
If tess_failed is true, one of the following tests failed when Tess
296295
returned:
297296
- The outword blob list was not the same length as the best_choice string;
298297
- The best_choice string contained ALL blanks;

src/ccstruct/pdblock.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: pdblock.cpp
33
* Description: PDBLK member functions and iterator functions.
44
* Author: Ray Smith
5-
* Created: Fri Mar 15 09:41:28 GMT 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +20,7 @@
2120
#include <cstdlib>
2221
#include <memory> // std::unique_ptr
2322
#include "allheaders.h"
23+
#include "host.h" // for PRId32
2424

2525
// Include automatically generated configuration file if running autoconf.
2626
#ifdef HAVE_CONFIG_H
@@ -83,7 +83,7 @@ void PDBLK::set_sides( //set vertex lists
8383
/**********************************************************************
8484
* PDBLK::contains
8585
*
86-
* Return TRUE if the given point is within the block.
86+
* Return true if the given point is within the block.
8787
**********************************************************************/
8888

8989
bool PDBLK::contains( //test containment
@@ -354,7 +354,7 @@ int16_t BLOCK_LINE_IT::get_line( //get a line
354354
//get block box
355355
block->bounding_box (bleft, tright);
356356
if (y < bleft.y () || y >= tright.y ()) {
357-
// block->print(stderr,FALSE);
357+
// block->print(stderr,false);
358358
BADBLOCKLINE.error ("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y);
359359
}
360360

src/ccstruct/polyaprx.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: polyaprx.cpp (Formerly polygon.c)
33
* Description: Code for polygonal approximation from old edgeprog.
44
* Author: Ray Smith
5-
* Created: Thu Nov 25 11:42:04 GMT 1993
65
*
76
* (C) Copyright 1993, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +21,6 @@
2221
#include "blobs.h" // for EDGEPT, TPOINT, VECTOR, TESSLINE
2322
#include "coutln.h" // for C_OUTLINE
2423
#include "errcode.h" // for ASSERT_HOST
25-
#include "host.h" // for FALSE, TRUE
2624
#include "mod128.h" // for DIR128
2725
#include "params.h" // for BoolParam, BOOL_VAR
2826
#include "points.h" // for ICOORD
@@ -33,8 +31,8 @@
3331
#define EXTERN
3432
#define FASTEDGELENGTH 256
3533

36-
EXTERN BOOL_VAR(poly_debug, FALSE, "Debug old poly");
37-
EXTERN BOOL_VAR(poly_wide_objects_better, TRUE,
34+
EXTERN BOOL_VAR(poly_debug, false, "Debug old poly");
35+
EXTERN BOOL_VAR(poly_wide_objects_better, true,
3836
"More accurate approx on wide things");
3937

4038
#define FIXED 4 /*OUTLINE point is fixed */

src/ccstruct/quspline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void QSPLINE::move( // reposition spline
265265
/**********************************************************************
266266
* QSPLINE::overlap
267267
*
268-
* Return TRUE if spline2 overlaps this by no more than fraction less
268+
* Return true if spline2 overlaps this by no more than fraction less
269269
* than the bounds of this.
270270
**********************************************************************/
271271

src/ccstruct/statistc.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/**********************************************************************
22
* File: statistc.cpp (Formerly stats.c)
33
* Description: Simple statistical package for integer values.
4-
* Author: Ray Smith
5-
* Created: Mon Feb 04 16:56:05 GMT 1991
4+
* Author: Ray Smith
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -256,7 +255,7 @@ double STATS::median() const { //get median
256255
/**********************************************************************
257256
* STATS::local_min
258257
*
259-
* Return TRUE if this point is a local min.
258+
* Return true if this point is a local min.
260259
**********************************************************************/
261260
bool STATS::local_min(int32_t x) const {
262261
if (buckets_ == nullptr) {

src/ccstruct/stepblob.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: stepblob.cpp (Formerly cblob.c)
33
* Description: Code for C_BLOB class.
44
* Author: Ray Smith
5-
* Created: Tue Oct 08 10:41:13 BST 1991
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +24,6 @@
2524
#include "stepblob.h"
2625
#include "allheaders.h" // for pixCreate, pixGetDepth
2726
#include "genericvector.h" // for GenericVector
28-
#include "host.h" // for TRUE, FALSE
2927
#include "points.h" // for operator+=, FCOORD, ICOORD
3028

3129
class DENORM;
@@ -147,7 +145,7 @@ static void reverse_outline_list(C_OUTLINE_LIST *list) {
147145
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
148146
C_OUTLINE* outline = it.data();
149147
outline->reverse(); // reverse it
150-
outline->set_flag(COUT_INVERSE, TRUE);
148+
outline->set_flag(COUT_INVERSE, true);
151149
if (!outline->child()->empty())
152150
reverse_outline_list(outline->child());
153151
}
@@ -230,9 +228,9 @@ void C_BLOB::CheckInverseFlagAndDirection() {
230228
if (outline->turn_direction() < 0) {
231229
outline->reverse();
232230
reverse_outline_list(outline->child());
233-
outline->set_flag(COUT_INVERSE, TRUE);
231+
outline->set_flag(COUT_INVERSE, true);
234232
} else {
235-
outline->set_flag(COUT_INVERSE, FALSE);
233+
outline->set_flag(COUT_INVERSE, false);
236234
}
237235
}
238236
}

0 commit comments

Comments
 (0)