@@ -45,16 +45,16 @@ AmbigSpec::AmbigSpec() {
45
45
46
46
ELISTIZE (AmbigSpec)
47
47
48
- // Initializes the ambigs by adding a NULL pointer to each table.
48
+ // Initializes the ambigs by adding a nullptr pointer to each table.
49
49
void UnicharAmbigs::InitUnicharAmbigs (const UNICHARSET& unicharset,
50
50
bool use_ambigs_for_adaption) {
51
51
for (int i = 0 ; i < unicharset.size (); ++i) {
52
- replace_ambigs_.push_back (NULL );
53
- dang_ambigs_.push_back (NULL );
54
- one_to_one_definite_ambigs_.push_back (NULL );
52
+ replace_ambigs_.push_back (nullptr );
53
+ dang_ambigs_.push_back (nullptr );
54
+ one_to_one_definite_ambigs_.push_back (nullptr );
55
55
if (use_ambigs_for_adaption) {
56
- ambigs_for_adaption_.push_back (NULL );
57
- reverse_ambigs_for_adaption_.push_back (NULL );
56
+ ambigs_for_adaption_.push_back (nullptr );
57
+ reverse_ambigs_for_adaption_.push_back (nullptr );
58
58
}
59
59
}
60
60
}
@@ -89,15 +89,15 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET& encoder_set,
89
89
90
90
// Determine the version of the ambigs file.
91
91
int version = 0 ;
92
- ASSERT_HOST (ambig_file->FGets (buffer, kBufferSize ) != NULL &&
92
+ ASSERT_HOST (ambig_file->FGets (buffer, kBufferSize ) != nullptr &&
93
93
strlen (buffer) > 0 );
94
94
if (*buffer == ' v' ) {
95
- version = static_cast <int >(strtol (buffer+1 , NULL , 10 ));
95
+ version = static_cast <int >(strtol (buffer+1 , nullptr , 10 ));
96
96
++line_num;
97
97
} else {
98
98
ambig_file->Rewind ();
99
99
}
100
- while (ambig_file->FGets (buffer, kBufferSize ) != NULL ) {
100
+ while (ambig_file->FGets (buffer, kBufferSize ) != nullptr ) {
101
101
chomp_string (buffer);
102
102
if (debug_level > 2 ) tprintf (" read line %s\n " , buffer);
103
103
++line_num;
@@ -117,7 +117,7 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET& encoder_set,
117
117
// Update one_to_one_definite_ambigs_.
118
118
if (test_ambig_part_size == 1 &&
119
119
replacement_ambig_part_size == 1 && type == DEFINITE_AMBIG) {
120
- if (one_to_one_definite_ambigs_[test_unichar_ids[0 ]] == NULL ) {
120
+ if (one_to_one_definite_ambigs_[test_unichar_ids[0 ]] == nullptr ) {
121
121
one_to_one_definite_ambigs_[test_unichar_ids[0 ]] = new UnicharIdVector ();
122
122
}
123
123
one_to_one_definite_ambigs_[test_unichar_ids[0 ]]->push_back (
@@ -129,9 +129,9 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET& encoder_set,
129
129
// Silently ignore invalid strings, as before, so it is safe to use a
130
130
// universal ambigs file.
131
131
if (unicharset->encode_string (replacement_string, true , &encoding,
132
- NULL , NULL )) {
132
+ nullptr , nullptr )) {
133
133
for (i = 0 ; i < test_ambig_part_size; ++i) {
134
- if (ambigs_for_adaption_[test_unichar_ids[i]] == NULL ) {
134
+ if (ambigs_for_adaption_[test_unichar_ids[i]] == nullptr ) {
135
135
ambigs_for_adaption_[test_unichar_ids[i]] = new UnicharIdVector ();
136
136
}
137
137
adaption_ambigs_entry = ambigs_for_adaption_[test_unichar_ids[i]];
@@ -160,10 +160,10 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET& encoder_set,
160
160
if (use_ambigs_for_adaption) {
161
161
for (i = 0 ; i < ambigs_for_adaption_.size (); ++i) {
162
162
adaption_ambigs_entry = ambigs_for_adaption_[i];
163
- if (adaption_ambigs_entry == NULL ) continue ;
163
+ if (adaption_ambigs_entry == nullptr ) continue ;
164
164
for (j = 0 ; j < adaption_ambigs_entry->size (); ++j) {
165
165
UNICHAR_ID ambig_id = (*adaption_ambigs_entry)[j];
166
- if (reverse_ambigs_for_adaption_[ambig_id] == NULL ) {
166
+ if (reverse_ambigs_for_adaption_[ambig_id] == nullptr ) {
167
167
reverse_ambigs_for_adaption_[ambig_id] = new UnicharIdVector ();
168
168
}
169
169
reverse_ambigs_for_adaption_[ambig_id]->push_back (i);
@@ -178,7 +178,7 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET& encoder_set,
178
178
(tbl == 0 ) ? replace_ambigs_ : dang_ambigs_;
179
179
for (i = 0 ; i < print_table.size (); ++i) {
180
180
AmbigSpec_LIST *lst = print_table[i];
181
- if (lst == NULL ) continue ;
181
+ if (lst == nullptr ) continue ;
182
182
if (!lst->empty ()) {
183
183
tprintf (" %s Ambiguities for %s:\n " ,
184
184
(tbl == 0 ) ? " Replaceable" : " Dangerous" ,
@@ -200,7 +200,7 @@ void UnicharAmbigs::LoadUnicharAmbigs(const UNICHARSET& encoder_set,
200
200
ambigs_for_adaption_ : reverse_ambigs_for_adaption_;
201
201
for (i = 0 ; i < vec.size (); ++i) {
202
202
adaption_ambigs_entry = vec[i];
203
- if (adaption_ambigs_entry != NULL ) {
203
+ if (adaption_ambigs_entry != nullptr ) {
204
204
tprintf (" %sAmbigs for adaption for %s:\n " ,
205
205
(vec_id == 0 ) ? " " : " Reverse " ,
206
206
unicharset->debug_str (i).string ());
@@ -231,8 +231,8 @@ bool UnicharAmbigs::ParseAmbiguityLine(
231
231
}
232
232
// Encode wrong-string.
233
233
GenericVector<UNICHAR_ID> unichars;
234
- if (!unicharset.encode_string (fields[0 ].string (), true , &unichars, NULL ,
235
- NULL )) {
234
+ if (!unicharset.encode_string (fields[0 ].string (), true , &unichars, nullptr ,
235
+ nullptr )) {
236
236
return false ;
237
237
}
238
238
*test_ambig_part_size = unichars.size ();
@@ -246,8 +246,8 @@ bool UnicharAmbigs::ParseAmbiguityLine(
246
246
test_unichar_ids[i] = unichars[i];
247
247
test_unichar_ids[unichars.size ()] = INVALID_UNICHAR_ID;
248
248
// Encode replacement-string to check validity.
249
- if (!unicharset.encode_string (fields[1 ].string (), true , &unichars, NULL ,
250
- NULL )) {
249
+ if (!unicharset.encode_string (fields[1 ].string (), true , &unichars, nullptr ,
250
+ nullptr )) {
251
251
return false ;
252
252
}
253
253
*replacement_ambig_part_size = unichars.size ();
@@ -278,7 +278,7 @@ bool UnicharAmbigs::ParseAmbiguityLine(
278
278
return false ;
279
279
}
280
280
for (i = 0 ; i < *test_ambig_part_size; ++i) {
281
- if (!(token = strtok_r (NULL , kAmbigDelimiters , &next_token))) break ;
281
+ if (!(token = strtok_r (nullptr , kAmbigDelimiters , &next_token))) break ;
282
282
if (!unicharset.contains_unichar (token)) {
283
283
if (debug_level) tprintf (kIllegalUnicharMsg , token);
284
284
break ;
@@ -288,7 +288,7 @@ bool UnicharAmbigs::ParseAmbiguityLine(
288
288
test_unichar_ids[i] = INVALID_UNICHAR_ID;
289
289
290
290
if (i != *test_ambig_part_size ||
291
- !(token = strtok_r (NULL , kAmbigDelimiters , &next_token)) ||
291
+ !(token = strtok_r (nullptr , kAmbigDelimiters , &next_token)) ||
292
292
!sscanf (token, " %d" , replacement_ambig_part_size) ||
293
293
*replacement_ambig_part_size <= 0 ) {
294
294
if (debug_level) tprintf (kIllegalMsg , line_num);
@@ -301,7 +301,7 @@ bool UnicharAmbigs::ParseAmbiguityLine(
301
301
}
302
302
replacement_string[0 ] = ' \0 ' ;
303
303
for (i = 0 ; i < *replacement_ambig_part_size; ++i) {
304
- if (!(token = strtok_r (NULL , kAmbigDelimiters , &next_token))) break ;
304
+ if (!(token = strtok_r (nullptr , kAmbigDelimiters , &next_token))) break ;
305
305
strcat (replacement_string, token);
306
306
if (!unicharset.contains_unichar (token)) {
307
307
if (debug_level) tprintf (kIllegalUnicharMsg , token);
@@ -322,7 +322,7 @@ bool UnicharAmbigs::ParseAmbiguityLine(
322
322
// Note that if m > 1, an ngram will be inserted into the
323
323
// modified word, not the individual unigrams. Tesseract
324
324
// has limited support for ngram unichar (e.g. dawg permuter).
325
- if (!(token = strtok_r (NULL , kAmbigDelimiters , &next_token)) ||
325
+ if (!(token = strtok_r (nullptr , kAmbigDelimiters , &next_token)) ||
326
326
!sscanf (token, " %d" , type)) {
327
327
if (debug_level) tprintf (kIllegalMsg , line_num);
328
328
return false ;
@@ -381,7 +381,7 @@ bool UnicharAmbigs::InsertIntoTable(
381
381
382
382
// Add AmbigSpec for this ambiguity to the corresponding AmbigSpec_LIST.
383
383
// Keep AmbigSpec_LISTs sorted by AmbigSpec.wrong_ngram.
384
- if (table[test_unichar_ids[0 ]] == NULL ) {
384
+ if (table[test_unichar_ids[0 ]] == nullptr ) {
385
385
table[test_unichar_ids[0 ]] = new AmbigSpec_LIST ();
386
386
}
387
387
if (table[test_unichar_ids[0 ]]->add_sorted (
0 commit comments