Skip to content

Commit 32e9d7c

Browse files
committed
training: Fix some compiler warnings (signed/unsigned)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent e4b862d commit 32e9d7c

6 files changed

+12
-12
lines changed

src/training/validate_grapheme.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace tesseract {
66

77
bool ValidateGrapheme::ConsumeGraphemeIfValid() {
8-
int num_codes = codes_.size();
8+
const unsigned num_codes = codes_.size();
99
char32 prev_prev_ch = ' ';
1010
char32 prev_ch = ' ';
1111
CharClass prev_cc = CharClass::kWhitespace;

src/training/validate_indic.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Validator::CharClass ValidateIndic::UnicodeToCharClass(char32 ch) const {
9595
// representation to make it consistent by adding a ZWNJ if missing from a
9696
// non-linking virama. Returns false with an invalid sequence.
9797
bool ValidateIndic::ConsumeViramaIfValid(IndicPair joiner, bool post_matra) {
98-
int num_codes = codes_.size();
98+
const unsigned num_codes = codes_.size();
9999
if (joiner.first == CharClass::kOther) {
100100
CodeOnlyToOutput();
101101
if (codes_used_ < num_codes &&
@@ -167,7 +167,7 @@ bool ValidateIndic::ConsumeViramaIfValid(IndicPair joiner, bool post_matra) {
167167
// Helper consumes/copies a series of consonants separated by viramas while
168168
// valid, but not any vowel or other modifiers.
169169
bool ValidateIndic::ConsumeConsonantHeadIfValid() {
170-
const int num_codes = codes_.size();
170+
const unsigned num_codes = codes_.size();
171171
// Consonant aksara
172172
do {
173173
CodeOnlyToOutput();

src/training/validate_javanese.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool ValidateJavanese::ConsumeGraphemeIfValid() {
7171
// representation to make it consistent by adding a ZWNJ if missing from a
7272
// non-linking virama. Returns false with an invalid sequence.
7373
bool ValidateJavanese::ConsumeViramaIfValid(IndicPair joiner, bool post_matra) {
74-
int num_codes = codes_.size();
74+
const unsigned num_codes = codes_.size();
7575
if (joiner.first == CharClass::kOther) {
7676
CodeOnlyToOutput();
7777
if (codes_used_ < num_codes &&
@@ -143,7 +143,7 @@ bool ValidateJavanese::ConsumeViramaIfValid(IndicPair joiner, bool post_matra) {
143143
// Helper consumes/copies a series of consonants separated by viramas while
144144
// valid, but not any vowel or other modifiers.
145145
bool ValidateJavanese::ConsumeConsonantHeadIfValid() {
146-
const int num_codes = codes_.size();
146+
const unsigned num_codes = codes_.size();
147147
// Consonant aksara
148148
do {
149149
CodeOnlyToOutput();
@@ -252,8 +252,8 @@ bool ValidateJavanese::ConsumeVowelIfValid() {
252252
// What we have consumed so far is a valid vowel cluster.
253253
return true;
254254
}
255-
256-
255+
256+
257257
Validator::CharClass ValidateJavanese::UnicodeToCharClass(char32 ch) const {
258258
if (ch == kZeroWidthNonJoiner) return CharClass::kZeroWidthNonJoiner;
259259
if (ch == kZeroWidthJoiner) return CharClass::kZeroWidthJoiner;

src/training/validate_khmer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace tesseract {
1818
// HC and the {Z|z}M The unicode chapter on Khmer only mentions the joiners in
1919
// the BNF syntax, so who knows what they do.
2020
bool ValidateKhmer::ConsumeGraphemeIfValid() {
21-
int num_codes = codes_.size();
21+
const unsigned num_codes = codes_.size();
2222
if (codes_used_ == num_codes) return false;
2323
if (codes_[codes_used_].first == CharClass::kOther) {
2424
UseMultiCode(1);

src/training/validate_myanmar.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace tesseract {
1111
// Taken directly from the unicode table 16-3.
1212
// See http://www.unicode.org/versions/Unicode9.0.0/ch16.pdf
1313
bool ValidateMyanmar::ConsumeGraphemeIfValid() {
14-
int num_codes = codes_.size();
14+
const unsigned num_codes = codes_.size();
1515
if (codes_used_ == num_codes) return true;
1616
// Other.
1717
if (IsMyanmarOther(codes_[codes_used_].second)) {
@@ -61,7 +61,7 @@ Validator::CharClass ValidateMyanmar::UnicodeToCharClass(char32 ch) const {
6161
// Returns true if the end of input is reached.
6262
bool ValidateMyanmar::ConsumeSubscriptIfPresent() {
6363
// Subscript consonant. It appears there can be only one.
64-
int num_codes = codes_.size();
64+
const unsigned num_codes = codes_.size();
6565
if (codes_used_ + 1 < num_codes &&
6666
codes_[codes_used_].second == kMyanmarVirama) {
6767
if (IsMyanmarLetter(codes_[codes_used_ + 1].second)) {

src/training/validator.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ class Validator {
235235
// Copied validated unicodes from codes_ that are OK to output.
236236
std::vector<char32> output_;
237237
// The number of elements of codes_ that have been processed so far.
238-
int codes_used_;
238+
unsigned codes_used_;
239239
// The number of elements of output_ that have already been added to parts_.
240-
int output_used_;
240+
unsigned output_used_;
241241
// Log error messages for reasons why text is invalid.
242242
bool report_errors_;
243243
};

0 commit comments

Comments
 (0)