Skip to content

Commit 222f5b9

Browse files
committed
textord: Replace NULL by nullptr
Signed-off-by: Stefan Weil <[email protected]>
1 parent 6e2750c commit 222f5b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+997
-997
lines changed

textord/alignedblob.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ bool AlignedBlob::WithinTestRegion(int detail_level, int x, int y) {
161161
ScrollView* AlignedBlob::DisplayTabs(const char* window_name,
162162
ScrollView* tab_win) {
163163
#ifndef GRAPHICS_DISABLED
164-
if (tab_win == NULL)
164+
if (tab_win == nullptr)
165165
tab_win = MakeWindow(0, 50, window_name);
166166
// For every tab in the grid, display it.
167167
GridSearch<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT> gsearch(this);
168168
gsearch.StartFullSearch();
169169
BLOBNBOX* bbox;
170-
while ((bbox = gsearch.NextFullSearch()) != NULL) {
170+
while ((bbox = gsearch.NextFullSearch()) != nullptr) {
171171
const TBOX& box = bbox->bounding_box();
172172
int left_x = box.left();
173173
int right_x = box.right();
@@ -219,7 +219,7 @@ static bool AtLeast2LineCrossings(BLOBNBOX_CLIST* blobs) {
219219
// search parameters are determined by the AlignedBlobParams.
220220
// vertical_x and y are updated with an estimate of the real
221221
// vertical direction. (skew finding.)
222-
// Returns NULL if no decent vector can be found.
222+
// Returns nullptr if no decent vector can be found.
223223
TabVector* AlignedBlob::FindVerticalAlignment(AlignedBlobParams align_params,
224224
BLOBNBOX* bbox,
225225
int* vertical_x,
@@ -305,7 +305,7 @@ TabVector* AlignedBlob::FindVerticalAlignment(AlignedBlobParams align_params,
305305
pt_count, align_params.min_points, end_y - start_y,
306306
align_params.min_length, abs(end_x - start_x) * kMinTabGradient);
307307
}
308-
return NULL;
308+
return nullptr;
309309
}
310310

311311
// Find a set of blobs that are aligned in the given vertical
@@ -325,7 +325,7 @@ int AlignedBlob::AlignTabs(const AlignedBlobParams& params,
325325
box.print();
326326
}
327327
int x_start = params.right_tab ? box.right() : box.left();
328-
while (bbox != NULL) {
328+
while (bbox != nullptr) {
329329
// Add the blob to the list if the appropriate side is a tab candidate,
330330
// or if we are working on a ragged tab.
331331
TabType type = params.right_tab ? bbox->right_tab_type()
@@ -340,10 +340,10 @@ int AlignedBlob::AlignTabs(const AlignedBlobParams& params,
340340
}
341341
// Find the next blob that is aligned with the current one.
342342
// FindAlignedBlob guarantees that forward progress will be made in the
343-
// top_to_bottom direction, and therefore eventually it will return NULL,
344-
// making this while (bbox != NULL) loop safe.
343+
// top_to_bottom direction, and therefore eventually it will return nullptr,
344+
// making this while (bbox != nullptr) loop safe.
345345
bbox = FindAlignedBlob(params, top_to_bottom, bbox, x_start, end_y);
346-
if (bbox != NULL) {
346+
if (bbox != nullptr) {
347347
box = bbox->bounding_box();
348348
if (!params.ragged)
349349
x_start = params.right_tab ? box.right() : box.left();
@@ -359,8 +359,8 @@ int AlignedBlob::AlignTabs(const AlignedBlobParams& params,
359359
// Search vertically for a blob that is aligned with the input bbox.
360360
// The search parameters are determined by AlignedBlobParams.
361361
// top_to_bottom tells whether to search down or up.
362-
// The return value is NULL if nothing was found in the search box
363-
// or if a blob was found in the gutter. On a NULL return, end_y
362+
// The return value is nullptr if nothing was found in the search box
363+
// or if a blob was found in the gutter. On a nullptr return, end_y
364364
// is set to the edge of the search box or the leading edge of the
365365
// gutter blob if one was found.
366366
BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
@@ -412,13 +412,13 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
412412
xmin, xmax, start_y, p.max_v_gap, p.min_gutter);
413413
vsearch.StartVerticalSearch(xmin, xmax, start_y);
414414
// result stores the best real return value.
415-
BLOBNBOX* result = NULL;
415+
BLOBNBOX* result = nullptr;
416416
// The backup_result is not a tab candidate and can be used if no
417417
// real tab candidate result is found.
418-
BLOBNBOX* backup_result = NULL;
418+
BLOBNBOX* backup_result = nullptr;
419419
// neighbour is the blob that is currently being investigated.
420-
BLOBNBOX* neighbour = NULL;
421-
while ((neighbour = vsearch.NextVerticalSearch(top_to_bottom)) != NULL) {
420+
BLOBNBOX* neighbour = nullptr;
421+
while ((neighbour = vsearch.NextVerticalSearch(top_to_bottom)) != nullptr) {
422422
if (neighbour == bbox)
423423
continue;
424424
TBOX nbox = neighbour->bounding_box();
@@ -437,9 +437,9 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
437437
// more than one blob in a grid cell. See comment in AlignTabs.
438438
if ((n_y < start_y) != top_to_bottom || nbox.y_overlap(box))
439439
continue; // Only look in the required direction.
440-
if (result != NULL && result->bounding_box().y_gap(nbox) > gridsize())
440+
if (result != nullptr && result->bounding_box().y_gap(nbox) > gridsize())
441441
return result; // This result is clear.
442-
if (backup_result != NULL && p.ragged && result == NULL &&
442+
if (backup_result != nullptr && p.ragged && result == nullptr &&
443443
backup_result->bounding_box().y_gap(nbox) > gridsize())
444444
return backup_result; // This result is clear.
445445

@@ -466,7 +466,7 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
466466
*end_y = top_to_bottom ? nbox.top() : nbox.bottom();
467467
if (WithinTestRegion(2, x_start, start_y))
468468
tprintf("gutter\n");
469-
return NULL;
469+
return nullptr;
470470
}
471471
if (!p.right_tab &&
472472
n_left < x_at_n_y - p.l_align_tolerance &&
@@ -478,7 +478,7 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
478478
*end_y = top_to_bottom ? nbox.top() : nbox.bottom();
479479
if (WithinTestRegion(2, x_start, start_y))
480480
tprintf("gutter\n");
481-
return NULL;
481+
return nullptr;
482482
}
483483
if ((p.right_tab && neighbour->leader_on_right()) ||
484484
(!p.right_tab && neighbour->leader_on_left()))
@@ -494,7 +494,7 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
494494
TabType n_type = p.right_tab ? neighbour->right_tab_type()
495495
: neighbour->left_tab_type();
496496
if (n_type != TT_NONE && (p.ragged || n_type != TT_MAYBE_RAGGED)) {
497-
if (result == NULL) {
497+
if (result == nullptr) {
498498
result = neighbour;
499499
} else {
500500
// Keep the closest neighbour by Euclidean distance.
@@ -510,7 +510,7 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
510510
if (new_dist < old_dist)
511511
result = neighbour;
512512
}
513-
} else if (backup_result == NULL) {
513+
} else if (backup_result == nullptr) {
514514
if (WithinTestRegion(2, x_start, start_y))
515515
tprintf("Backup\n");
516516
backup_result = neighbour;
@@ -525,7 +525,7 @@ BLOBNBOX* AlignedBlob::FindAlignedBlob(const AlignedBlobParams& p,
525525
}
526526
}
527527
}
528-
return result != NULL ? result : backup_result;
528+
return result != nullptr ? result : backup_result;
529529
}
530530

531531
} // namespace tesseract.

textord/alignedblob.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class AlignedBlob : public BlobGrid {
9595
// search parameters are determined by the AlignedBlobParams.
9696
// vertical_x and y are updated with an estimate of the real
9797
// vertical direction. (skew finding.)
98-
// Returns NULL if no decent vector can be found.
98+
// Returns nullptr if no decent vector can be found.
9999
TabVector* FindVerticalAlignment(AlignedBlobParams align_params,
100100
BLOBNBOX* bbox,
101101
int* vertical_x, int* vertical_y);
@@ -112,8 +112,8 @@ class AlignedBlob : public BlobGrid {
112112
// Search vertically for a blob that is aligned with the input bbox.
113113
// The search parameters are determined by AlignedBlobParams.
114114
// top_to_bottom tells whether to search down or up.
115-
// The return value is NULL if nothing was found in the search box
116-
// or if a blob was found in the gutter. On a NULL return, end_y
115+
// The return value is nullptr if nothing was found in the search box
116+
// or if a blob was found in the gutter. On a nullptr return, end_y
117117
// is set to the edge of the search box or the leading edge of the
118118
// gutter blob if one was found.
119119
BLOBNBOX* FindAlignedBlob(const AlignedBlobParams& p,

textord/baselinedetect.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,10 @@ void BaselineBlock::RefineLineSpacing(const GenericVector<double>& positions) {
706706
double spacing_plus = line_spacing_ / (1.0 + 1.0 / index_range);
707707
// Try the hypotheses that there might be index_range +/- 1 line spaces.
708708
errors[1] = FitLineSpacingModel(positions, spacing_plus,
709-
&spacings[1], &offsets[1], NULL);
709+
&spacings[1], &offsets[1], nullptr);
710710
double spacing_minus = line_spacing_ / (1.0 - 1.0 / index_range);
711711
errors[2] = FitLineSpacingModel(positions, spacing_minus,
712-
&spacings[2], &offsets[2], NULL);
712+
&spacings[2], &offsets[2], nullptr);
713713
for (int i = 1; i <= 2; ++i) {
714714
if (errors[i] < errors[0]) {
715715
spacings[0] = spacings[i];
@@ -740,7 +740,7 @@ double BaselineBlock::FitLineSpacingModel(
740740
if (m_in == 0.0f || positions.size() < 2) {
741741
*m_out = m_in;
742742
*c_out = 0.0;
743-
if (index_delta != NULL) *index_delta = 0;
743+
if (index_delta != nullptr) *index_delta = 0;
744744
return 0.0;
745745
}
746746
GenericVector<double> offsets;
@@ -776,7 +776,7 @@ double BaselineBlock::FitLineSpacingModel(
776776
*c_out, llsq.c(*m_out));
777777
}
778778
// Index_delta is the number of hypothesized line gaps present.
779-
if (index_delta != NULL)
779+
if (index_delta != nullptr)
780780
*index_delta = max_index - min_index;
781781
// Use the regression model's intercept to compute the error, as it may be
782782
// a full line-spacing in disagreement with the median.
@@ -802,7 +802,7 @@ BaselineDetect::BaselineDetect(int debug_level, const FCOORD& page_skew,
802802
// block. Ideally no baselines should be required, but currently
803803
// make_words crashes if a baseline and xheight are not provided, so we
804804
// include non-text blocks here, but flag them for special treatment.
805-
bool non_text = pb != NULL && !pb->IsText();
805+
bool non_text = pb != nullptr && !pb->IsText();
806806
blocks_.push_back(new BaselineBlock(debug_level_, non_text, to_block));
807807
}
808808
}

textord/bbgrid.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@ void GridBase::ClipGridCoords(int* x, int* y) const {
6464
}
6565

6666
IntGrid::IntGrid() {
67-
grid_ = NULL;
67+
grid_ = nullptr;
6868
}
6969

7070
IntGrid::IntGrid(int gridsize, const ICOORD& bleft, const ICOORD& tright)
71-
: grid_(NULL) {
71+
: grid_(nullptr) {
7272
Init(gridsize, bleft, tright);
7373
}
7474

7575
IntGrid::~IntGrid() {
76-
if (grid_ != NULL)
76+
if (grid_ != nullptr)
7777
delete [] grid_;
7878
}
7979

8080
// (Re)Initialize the grid. The gridsize is the size in pixels of each cell,
8181
// and bleft, tright are the bounding box of everything to go in it.
8282
void IntGrid::Init(int gridsize, const ICOORD& bleft, const ICOORD& tright) {
8383
GridBase::Init(gridsize, bleft, tright);
84-
if (grid_ != NULL)
84+
if (grid_ != nullptr)
8585
delete [] grid_;
8686
grid_ = new int[gridbuckets_];
8787
Clear();
@@ -109,7 +109,7 @@ void IntGrid::Rotate(const FCOORD& rotation) {
109109
TBOX box(bleft(), tright());
110110
box.rotate(rotation);
111111
int* old_grid = grid_;
112-
grid_ = NULL;
112+
grid_ = nullptr;
113113
Init(gridsize(), box.botleft(), box.topright());
114114
// Iterate over the old grid, copying data to the rotated position in the new.
115115
int oldi = 0;
@@ -201,7 +201,7 @@ Pix* IntGrid::ThresholdToPix(int threshold) const {
201201
GridCellValue(x - 1, y) > 0 && GridCellValue(x + 1, y) > 0 &&
202202
GridCellValue(x, y - 1) > 0 && GridCellValue(x, y + 1) > 0) {
203203
pixRasterop(pix, x * cellsize, tright().y() - ((y + 1) * cellsize),
204-
cellsize, cellsize, PIX_SET, NULL, 0, 0);
204+
cellsize, cellsize, PIX_SET, nullptr, 0, 0);
205205
}
206206
}
207207
}

0 commit comments

Comments
 (0)