@@ -39,7 +39,7 @@ const int kMinNewlineRatio = 5;
39
39
namespace tesseract {
40
40
41
41
BoxChar::BoxChar (const char * utf8_str, int len) : ch_(utf8_str, len) {
42
- box_ = NULL ;
42
+ box_ = nullptr ;
43
43
}
44
44
45
45
BoxChar::~BoxChar () { boxDestroy (&box_); }
@@ -53,7 +53,7 @@ void BoxChar::TranslateBoxes(int xshift, int yshift,
53
53
std::vector<BoxChar*>* boxes) {
54
54
for (int i = 0 ; i < boxes->size (); ++i) {
55
55
BOX* box = (*boxes)[i]->box_ ;
56
- if (box != NULL ) {
56
+ if (box != nullptr ) {
57
57
box->x += xshift;
58
58
box->y += yshift;
59
59
}
@@ -69,7 +69,7 @@ void BoxChar::PrepareToWrite(std::vector<BoxChar*>* boxes) {
69
69
InsertNewlines (rtl_rules, vertical_rules, boxes);
70
70
InsertSpaces (rtl_rules, vertical_rules, boxes);
71
71
for (int i = 0 ; i < boxes->size (); ++i) {
72
- if ((*boxes)[i]->box_ == NULL ) tprintf (" Null box at index %d\n " , i);
72
+ if ((*boxes)[i]->box_ == nullptr ) tprintf (" Null box at index %d\n " , i);
73
73
}
74
74
if (rtl_rules) {
75
75
ReorderRTLText (boxes);
@@ -84,14 +84,14 @@ void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
84
84
int max_shift = 0 ;
85
85
for (int i = 0 ; i < boxes->size (); ++i) {
86
86
Box* box = (*boxes)[i]->box_ ;
87
- if (box == NULL ) {
87
+ if (box == nullptr ) {
88
88
if (prev_i < 0 || prev_i < i - 1 || i + 1 == boxes->size ()) {
89
89
// Erase null boxes at the start of a line and after another null box.
90
90
do {
91
91
delete (*boxes)[i];
92
92
boxes->erase (boxes->begin () + i);
93
93
--i;
94
- } while (i >= 0 && i + 1 == boxes->size () && (*boxes)[i]->box_ == NULL );
94
+ } while (i >= 0 && i + 1 == boxes->size () && (*boxes)[i]->box_ == nullptr );
95
95
}
96
96
continue ;
97
97
}
@@ -139,18 +139,18 @@ void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
139
139
}
140
140
}
141
141
142
- // Converts NULL boxes to space characters, with appropriate bounding boxes.
142
+ // Converts nullptr boxes to space characters, with appropriate bounding boxes.
143
143
/* static */
144
144
void BoxChar::InsertSpaces (bool rtl_rules, bool vertical_rules,
145
145
std::vector<BoxChar*>* boxes) {
146
146
// After InsertNewlines, any remaining null boxes are not newlines, and are
147
147
// singletons, so add a box to each remaining null box.
148
148
for (int i = 1 ; i + 1 < boxes->size (); ++i) {
149
149
Box* box = (*boxes)[i]->box_ ;
150
- if (box == NULL ) {
150
+ if (box == nullptr ) {
151
151
Box* prev = (*boxes)[i - 1 ]->box_ ;
152
152
Box* next = (*boxes)[i + 1 ]->box_ ;
153
- ASSERT_HOST (prev != NULL && next != NULL );
153
+ ASSERT_HOST (prev != nullptr && next != nullptr );
154
154
int top = MIN (prev->y , next->y );
155
155
int bottom = MAX (prev->y + prev->h , next->y + next->h );
156
156
int left = prev->x + prev->w ;
@@ -170,14 +170,14 @@ void BoxChar::InsertSpaces(bool rtl_rules, bool vertical_rules,
170
170
j >= 0 && (*boxes)[j]->ch_ != " " && (*boxes)[j]->ch_ != " \t " ;
171
171
--j) {
172
172
prev = (*boxes)[j]->box_ ;
173
- ASSERT_HOST (prev != NULL );
173
+ ASSERT_HOST (prev != nullptr );
174
174
if (prev->x < right) {
175
175
right = prev->x ;
176
176
}
177
177
}
178
178
// Left becomes the max right of all next boxes forward to the first
179
179
// space or newline.
180
- for (int j = i + 2 ; j < boxes->size () && (*boxes)[j]->box_ != NULL &&
180
+ for (int j = i + 2 ; j < boxes->size () && (*boxes)[j]->box_ != nullptr &&
181
181
(*boxes)[j]->ch_ != " \t " ;
182
182
++j) {
183
183
next = (*boxes)[j]->box_ ;
@@ -244,7 +244,7 @@ bool BoxChar::ContainsMostlyRTL(const std::vector<BoxChar*>& boxes) {
244
244
bool BoxChar::MostlyVertical (const std::vector<BoxChar*>& boxes) {
245
245
inT64 total_dx = 0 , total_dy = 0 ;
246
246
for (int i = 1 ; i < boxes.size (); ++i) {
247
- if (boxes[i - 1 ]->box_ != NULL && boxes[i]->box_ != NULL &&
247
+ if (boxes[i - 1 ]->box_ != nullptr && boxes[i]->box_ != nullptr &&
248
248
boxes[i - 1 ]->page_ == boxes[i]->page_ ) {
249
249
int dx = boxes[i]->box_ ->x - boxes[i - 1 ]->box_ ->x ;
250
250
int dy = boxes[i]->box_ ->y - boxes[i - 1 ]->box_ ->y ;
@@ -303,7 +303,7 @@ string BoxChar::GetTesseractBoxStr(int height,
303
303
char buffer[kMaxLineLength ];
304
304
for (int i = 0 ; i < boxes.size (); ++i) {
305
305
const Box* box = boxes[i]->box_ ;
306
- if (box == NULL ) {
306
+ if (box == nullptr ) {
307
307
tprintf (" Error: Call PrepareToWrite before WriteTesseractBoxFile!!\n " );
308
308
return " " ;
309
309
}
0 commit comments