From 875e98c581952478f3a3ccef9b2f2e3ed06c5346 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 27 Sep 2017 10:53:11 -0400 Subject: Remove FX_STRSIZE and replace with size_t BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair Commit-Queue: Ryan Harrison --- fxbarcode/oned/BC_OneDimWriter.cpp | 6 +++--- fxbarcode/oned/BC_OneDimWriter.h | 2 +- fxbarcode/oned/BC_OnedCodaBarWriter.cpp | 4 ++-- fxbarcode/oned/BC_OnedCode128Writer.cpp | 6 +++--- fxbarcode/oned/BC_OnedCode39Writer.cpp | 11 +++++------ fxbarcode/oned/BC_OnedEAN13Writer.cpp | 2 +- fxbarcode/oned/BC_OnedEAN8Writer.cpp | 6 +++--- fxbarcode/oned/BC_OnedEANChecksum.cpp | 4 ++-- fxbarcode/oned/BC_OnedUPCAWriter.cpp | 8 ++++---- 9 files changed, 24 insertions(+), 25 deletions(-) (limited to 'fxbarcode/oned') diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp index 5bcb3c38bc..dc0d48c5bd 100644 --- a/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/fxbarcode/oned/BC_OneDimWriter.cpp @@ -136,10 +136,10 @@ void CBC_OneDimWriter::CalcTextInfo(const ByteString& text, std::unique_ptr encoding = FX_CreateFontEncodingEx(cFont, FXFM_ENCODING_NONE); - FX_STRSIZE length = text.GetLength(); + size_t length = text.GetLength(); uint32_t* pCharCode = FX_Alloc(uint32_t, text.GetLength()); float charWidth = 0; - for (FX_STRSIZE j = 0; j < length; j++) { + for (size_t j = 0; j < length; j++) { pCharCode[j] = encoding->CharCodeFromUnicode(text[j]); int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]); int32_t glyp_value = cFont->GetGlyphWidth(glyp_code); @@ -162,7 +162,7 @@ void CBC_OneDimWriter::CalcTextInfo(const ByteString& text, charPos[0].m_ExtGID = charPos[0].m_GlyphIndex; #endif penX += (float)(charPos[0].m_FontCharWidth) * (float)fontSize / 1000.0f; - for (FX_STRSIZE i = 1; i < length; i++) { + for (size_t i = 1; i < length; i++) { charPos[i].m_Origin = CFX_PointF(penX + left, penY + top); charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); diff --git a/fxbarcode/oned/BC_OneDimWriter.h b/fxbarcode/oned/BC_OneDimWriter.h index 5c9ef09e4d..a597d860f6 100644 --- a/fxbarcode/oned/BC_OneDimWriter.h +++ b/fxbarcode/oned/BC_OneDimWriter.h @@ -91,7 +91,7 @@ class CBC_OneDimWriter : public CBC_Writer { int32_t m_iFontStyle; uint32_t m_fontColor; BC_TEXT_LOC m_locTextLoc; - FX_STRSIZE m_iContentLen; + size_t m_iContentLen; bool m_bLeftPadding; bool m_bRightPadding; std::vector m_output; diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index 4c5ad67194..791904de5b 100644 --- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -105,7 +105,7 @@ WideString CBC_OnedCodaBarWriter::FilterContents( const WideStringView& contents) { WideString filtercontents; wchar_t ch; - for (FX_STRSIZE index = 0; index < contents.GetLength(); index++) { + for (size_t index = 0; index < contents.GetLength(); index++) { ch = contents[index]; if (ch > 175) { index++; @@ -136,7 +136,7 @@ uint8_t* CBC_OnedCodaBarWriter::EncodeImpl(const ByteString& contents, uint8_t* result = FX_Alloc2D(uint8_t, m_iWideNarrRatio * 7, data.GetLength()); char ch; int32_t position = 0; - for (FX_STRSIZE index = 0; index < data.GetLength(); index++) { + for (size_t index = 0; index < data.GetLength(); index++) { ch = data[index]; if (((ch >= 'a') && (ch <= 'z'))) { ch = ch - 32; diff --git a/fxbarcode/oned/BC_OnedCode128Writer.cpp b/fxbarcode/oned/BC_OnedCode128Writer.cpp index 61ec77b020..50d3fb65a6 100644 --- a/fxbarcode/oned/BC_OnedCode128Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode128Writer.cpp @@ -96,7 +96,7 @@ bool CBC_OnedCode128Writer::CheckContentValidity( WideString CBC_OnedCode128Writer::FilterContents( const WideStringView& contents) { WideString filterChineseChar; - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { wchar_t ch = contents[i]; if (ch > 175) { i++; @@ -173,7 +173,7 @@ int32_t CBC_OnedCode128Writer::Encode128B(const ByteString& contents, int32_t checkWeight = 1; patterns->push_back(CODE_START_B); int32_t checkSum = CODE_START_B * checkWeight; - for (FX_STRSIZE position = 0; position < contents.GetLength(); position++) { + for (size_t position = 0; position < contents.GetLength(); position++) { int32_t patternIndex = contents[position] - ' '; patterns->push_back(patternIndex); checkSum += patternIndex * checkWeight++; @@ -187,7 +187,7 @@ int32_t CBC_OnedCode128Writer::Encode128C(const ByteString& contents, int32_t checkWeight = 1; patterns->push_back(CODE_START_C); int32_t checkSum = CODE_START_C * checkWeight; - FX_STRSIZE position = 0; + size_t position = 0; while (position < contents.GetLength()) { int32_t patternIndex; char ch = contents[position]; diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp index 2e02e01583..8adef14765 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -49,7 +49,7 @@ CBC_OnedCode39Writer::~CBC_OnedCode39Writer() {} bool CBC_OnedCode39Writer::CheckContentValidity( const WideStringView& contents) { - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { wchar_t ch = contents[i]; if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'-' || ch == L'.' || ch == L' ' || ch == L'*' || ch == L'$' || @@ -64,7 +64,7 @@ bool CBC_OnedCode39Writer::CheckContentValidity( WideString CBC_OnedCode39Writer::FilterContents( const WideStringView& contents) { WideString filtercontents; - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { wchar_t ch = contents[i]; if (ch == L'*' && (i == 0 || i == contents.GetLength() - 1)) { continue; @@ -87,7 +87,7 @@ WideString CBC_OnedCode39Writer::FilterContents( WideString CBC_OnedCode39Writer::RenderTextContents( const WideStringView& contents) { WideString renderContents; - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { wchar_t ch = contents[i]; if (ch == L'*' && (i == 0 || i == contents.GetLength() - 1)) { continue; @@ -138,8 +138,7 @@ void CBC_OnedCode39Writer::ToIntArray(int32_t a, int8_t* toReturn) { } char CBC_OnedCode39Writer::CalcCheckSum(const ByteString& contents) { - FX_STRSIZE length = contents.GetLength(); - if (length > 80) + if (contents.GetLength() > 80) return '*'; int32_t checksum = 0; @@ -176,7 +175,7 @@ uint8_t* CBC_OnedCode39Writer::EncodeImpl(const ByteString& contents, int32_t codeWidth = (wideStrideNum * m_iWideNarrRatio + narrStrideNum) * 2 + 1 + m_iContentLen; size_t len = strlen(ALPHABET_STRING); - for (FX_STRSIZE j = 0; j < m_iContentLen; j++) { + for (size_t j = 0; j < m_iContentLen; j++) { for (size_t i = 0; i < len; i++) { if (ALPHABET_STRING[i] != encodedContents[j]) continue; diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 6de7c2cb20..daf53a8b7b 100644 --- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -63,7 +63,7 @@ bool CBC_OnedEAN13Writer::CheckContentValidity(const WideStringView& contents) { WideString CBC_OnedEAN13Writer::FilterContents(const WideStringView& contents) { WideString filtercontents; wchar_t ch; - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { ch = contents[i]; if (ch > 175) { i++; diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp index f92a1627b6..865979c396 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -70,7 +70,7 @@ bool CBC_OnedEAN8Writer::CheckContentValidity(const WideStringView& contents) { WideString CBC_OnedEAN8Writer::FilterContents(const WideStringView& contents) { WideString filtercontents; wchar_t ch; - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { ch = contents[i]; if (ch > 175) { i++; @@ -145,10 +145,10 @@ bool CBC_OnedEAN8Writer::ShowChars(const WideStringView& contents, int32_t leftPosition = 3 * multiple; ByteString str = FX_UTF8Encode(contents); - FX_STRSIZE iLength = str.GetLength(); + size_t iLength = str.GetLength(); std::vector charpos(iLength); ByteString tempStr = str.Left(4); - FX_STRSIZE iLen = tempStr.GetLength(); + size_t iLen = tempStr.GetLength(); int32_t strWidth = 7 * multiple * 4; float blank = 0.0; diff --git a/fxbarcode/oned/BC_OnedEANChecksum.cpp b/fxbarcode/oned/BC_OnedEANChecksum.cpp index 64aa1c5f43..b290c62926 100644 --- a/fxbarcode/oned/BC_OnedEANChecksum.cpp +++ b/fxbarcode/oned/BC_OnedEANChecksum.cpp @@ -9,8 +9,8 @@ int32_t EANCalcChecksum(const ByteString& contents) { int32_t odd = 0; int32_t even = 0; - FX_STRSIZE parity = 1; - for (FX_STRSIZE i = contents.GetLength(); i > 0; i--) { + size_t parity = 1; + for (size_t i = contents.GetLength(); i > 0; i--) { if (parity % 2) odd += FXSYS_DecimalCharToInt(contents[i - 1]); else diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 51858452e9..025f851526 100644 --- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -43,7 +43,7 @@ void CBC_OnedUPCAWriter::Init() { CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {} bool CBC_OnedUPCAWriter::CheckContentValidity(const WideStringView& contents) { - for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) { + for (size_t i = 0; i < contents.GetLength(); ++i) { if (contents[i] < '0' || contents[i] > '9') return false; } @@ -53,7 +53,7 @@ bool CBC_OnedUPCAWriter::CheckContentValidity(const WideStringView& contents) { WideString CBC_OnedUPCAWriter::FilterContents(const WideStringView& contents) { WideString filtercontents; wchar_t ch; - for (FX_STRSIZE i = 0; i < contents.GetLength(); i++) { + for (size_t i = 0; i < contents.GetLength(); i++) { ch = contents[i]; if (ch > 175) { i++; @@ -69,8 +69,8 @@ WideString CBC_OnedUPCAWriter::FilterContents(const WideStringView& contents) { int32_t CBC_OnedUPCAWriter::CalcChecksum(const ByteString& contents) { int32_t odd = 0; int32_t even = 0; - FX_STRSIZE j = 1; - for (FX_STRSIZE i = contents.GetLength(); i > 0; i--) { + size_t j = 1; + for (size_t i = contents.GetLength(); i > 0; i--) { if (j % 2) { odd += FXSYS_DecimalCharToInt(contents[i - 1]); } else { -- cgit v1.2.3