Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ccstruct: Replace BOOL8, TRUE, FALSE by bool, true, false and moderni…
…ze code

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 31, 2019
1 parent 92b9f9f commit 46fa59a
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/ccstruct/blobbox.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -94,7 +94,7 @@ void BLOBNBOX::merge( //merge blobs
) {
box += nextblob->box; //merge boxes
set_diacritic_box(box);
nextblob->joined = TRUE;
nextblob->joined = true;
}


Expand Down
6 changes: 2 additions & 4 deletions src/ccstruct/blread.cpp
Expand Up @@ -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");
Expand All @@ -19,7 +18,6 @@

#include "blread.h"
#include <cstdio> // 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

Expand Down Expand Up @@ -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
Expand All @@ -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);
}
3 changes: 1 addition & 2 deletions src/ccstruct/coutln.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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
*/

Expand Down
3 changes: 1 addition & 2 deletions src/ccstruct/ocrblock.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/ccstruct/ocrblock.h
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/ccstruct/ocrrow.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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 ();
}
Expand Down
9 changes: 4 additions & 5 deletions src/ccstruct/pageres.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/ccstruct/pageres.h
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/ccstruct/pdblock.cpp
Expand Up @@ -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");
Expand All @@ -21,6 +20,7 @@
#include <cstdlib>
#include <memory> // std::unique_ptr
#include "allheaders.h"
#include "host.h" // for PRId32

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 2 additions & 4 deletions src/ccstruct/polyaprx.cpp
Expand Up @@ -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");
Expand All @@ -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
Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/ccstruct/quspline.cpp
Expand Up @@ -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.
**********************************************************************/

Expand Down
5 changes: 2 additions & 3 deletions 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");
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 3 additions & 5 deletions src/ccstruct/stepblob.cpp
Expand Up @@ -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");
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 46fa59a

Please sign in to comment.