summaryrefslogtreecommitdiff
path: root/fxbarcode
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-15 10:37:59 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-15 15:03:10 +0000
commit8a1758bf11c2d741e0cddc761b1dd2cdf564db93 (patch)
tree82cbafc46f574a05ae0c1d1d3d7f9ebde6cb932d /fxbarcode
parent171cb27a720036c48ae3a6176084e880742af0a9 (diff)
downloadpdfium-8a1758bf11c2d741e0cddc761b1dd2cdf564db93.tar.xz
Remove GetAt from string classes
This method duplicates the behaviour of the const [] operator and doesn't offer any additional safety. Folding them into one implementation. SetAt is retained, since implementing the non-const [] operator to replace SetAt has potential performance concerns. Specifically many non-obvious cases of reading an element using [] will cause a realloc & copy. BUG=pdfium:860 Change-Id: I3ef5e5e5a15376f040256b646eb0d90636e24b67 Reviewed-on: https://pdfium-review.googlesource.com/10870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode')
-rw-r--r--fxbarcode/datamatrix/BC_ASCIIEncoder.cpp4
-rw-r--r--fxbarcode/datamatrix/BC_Base256Encoder.cpp14
-rw-r--r--fxbarcode/datamatrix/BC_C40Encoder.cpp6
-rw-r--r--fxbarcode/datamatrix/BC_DefaultPlacement.cpp2
-rw-r--r--fxbarcode/datamatrix/BC_EdifactEncoder.cpp8
-rw-r--r--fxbarcode/datamatrix/BC_EncoderContext.cpp8
-rw-r--r--fxbarcode/datamatrix/BC_ErrorCorrection.cpp6
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp8
-rw-r--r--fxbarcode/oned/BC_OnedCodaBarWriter.cpp4
-rw-r--r--fxbarcode/oned/BC_OnedCode39Writer.cpp6
-rw-r--r--fxbarcode/oned/BC_OnedEAN13Writer.cpp2
-rw-r--r--fxbarcode/oned/BC_OnedEAN8Writer.cpp2
-rw-r--r--fxbarcode/oned/BC_OnedUPCAWriter.cpp4
-rw-r--r--fxbarcode/pdf417/BC_PDF417.cpp2
-rw-r--r--fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp2
-rw-r--r--fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp32
-rw-r--r--fxbarcode/qrcode/BC_QRCoderEncoder.cpp14
17 files changed, 63 insertions, 61 deletions
diff --git a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
index de57d81b71..e6b7a2b35b 100644
--- a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
@@ -37,8 +37,8 @@ void CBC_ASCIIEncoder::Encode(CBC_EncoderContext& context, int32_t& e) {
int32_t n = CBC_HighLevelEncoder::determineConsecutiveDigitCount(
context.m_msg, context.m_pos);
if (n >= 2) {
- wchar_t code = encodeASCIIDigits(context.m_msg.GetAt(context.m_pos),
- context.m_msg.GetAt(context.m_pos + 1), e);
+ wchar_t code = encodeASCIIDigits(context.m_msg[context.m_pos],
+ context.m_msg[context.m_pos + 1], e);
if (e != BCExceptionNO) {
return;
}
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
index edcd411114..0cbd3fdb10 100644
--- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp
@@ -35,7 +35,7 @@ int32_t CBC_Base256Encoder::getEncodingMode() {
}
void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) {
CFX_WideString buffer;
- buffer += (wchar_t)'\0';
+ buffer += L'\0';
while (context.hasMoreCharacters()) {
wchar_t c = context.getCurrentChar();
buffer += c;
@@ -50,7 +50,7 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) {
int32_t dataCount = buffer.GetLength() - 1;
char buf[128];
FXSYS_itoa(dataCount, buf, 10);
- buffer.SetAt(0, wchar_t(*buf) - '0');
+ buffer.SetAt(0, static_cast<wchar_t>(*buf) - '0');
int32_t lengthFieldSize = 1;
int32_t currentSize =
context.getCodewordCount() + dataCount + lengthFieldSize;
@@ -61,10 +61,10 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) {
bool mustPad = (context.m_symbolInfo->dataCapacity() - currentSize) > 0;
if (context.hasMoreCharacters() || mustPad) {
if (dataCount <= 249) {
- buffer.SetAt(0, (wchar_t)dataCount);
+ buffer.SetAt(0, static_cast<wchar_t>(dataCount));
} else if (dataCount > 249 && dataCount <= 1555) {
- buffer.SetAt(0, (wchar_t)((dataCount / 250) + 249));
- buffer.Insert(1, (wchar_t)(dataCount % 250));
+ buffer.SetAt(0, static_cast<wchar_t>((dataCount / 250) + 249));
+ buffer.Insert(1, static_cast<wchar_t>(dataCount % 250));
} else {
e = BCExceptionIllegalStateMessageLengthInvalid;
return;
@@ -79,8 +79,8 @@ wchar_t CBC_Base256Encoder::randomize255State(wchar_t ch,
int32_t pseudoRandom = ((149 * codewordPosition) % 255) + 1;
int32_t tempVariable = ch + pseudoRandom;
if (tempVariable <= 255) {
- return (wchar_t)tempVariable;
+ return static_cast<wchar_t>(tempVariable);
} else {
- return (wchar_t)(tempVariable - 256);
+ return static_cast<wchar_t>(tempVariable - 256);
}
}
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp
index 8edd9eccfe..8a55c922ed 100644
--- a/fxbarcode/datamatrix/BC_C40Encoder.cpp
+++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp
@@ -32,9 +32,9 @@
namespace {
CFX_WideString EncodeToCodewords(const CFX_WideString& sb, int32_t startPos) {
- wchar_t c1 = sb.GetAt(startPos);
- wchar_t c2 = sb.GetAt(startPos + 1);
- wchar_t c3 = sb.GetAt(startPos + 2);
+ wchar_t c1 = sb[startPos];
+ wchar_t c2 = sb[startPos + 1];
+ wchar_t c3 = sb[startPos + 2];
int32_t v = (1600 * c1) + (40 * c2) + c3 + 1;
wchar_t cw[2];
cw[0] = static_cast<wchar_t>(v / 256);
diff --git a/fxbarcode/datamatrix/BC_DefaultPlacement.cpp b/fxbarcode/datamatrix/BC_DefaultPlacement.cpp
index 405b4f72a1..934d79503c 100644
--- a/fxbarcode/datamatrix/BC_DefaultPlacement.cpp
+++ b/fxbarcode/datamatrix/BC_DefaultPlacement.cpp
@@ -107,7 +107,7 @@ void CBC_DefaultPlacement::module(int32_t row,
col += m_numcols;
row += 4 - ((m_numcols + 4) % 8);
}
- int32_t v = m_codewords.GetAt(pos);
+ int32_t v = m_codewords[pos];
v &= 1 << (8 - bit);
setBit(col, row, v != 0);
}
diff --git a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
index c7d6b317c1..7407efb47e 100644
--- a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp
@@ -38,10 +38,10 @@ CFX_WideString EncodeToCodewords(const CFX_WideString& sb, int32_t startPos) {
if (len == 0)
return CFX_WideString();
- wchar_t c1 = sb.GetAt(startPos);
- wchar_t c2 = len >= 2 ? sb.GetAt(startPos + 1) : 0;
- wchar_t c3 = len >= 3 ? sb.GetAt(startPos + 2) : 0;
- wchar_t c4 = len >= 4 ? sb.GetAt(startPos + 3) : 0;
+ wchar_t c1 = sb[startPos];
+ wchar_t c2 = len >= 2 ? sb[startPos + 1] : 0;
+ wchar_t c3 = len >= 3 ? sb[startPos + 2] : 0;
+ wchar_t c4 = len >= 4 ? sb[startPos + 3] : 0;
int32_t v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4;
constexpr int32_t kBuflen = 3;
wchar_t cw[kBuflen];
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp
index 404c07d980..eaf3768f49 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.cpp
+++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp
@@ -36,8 +36,8 @@ CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString& msg,
CFX_WideString sb;
FX_STRSIZE c = dststr.GetLength();
for (FX_STRSIZE i = 0; i < c; i++) {
- wchar_t ch = static_cast<wchar_t>(dststr.GetAt(i) & 0xff);
- if (ch == '?' && dststr.GetAt(i) != '?') {
+ wchar_t ch = static_cast<wchar_t>(dststr[i] & 0xff);
+ if (ch == '?' && dststr[i] != '?') {
e = BCExceptionCharactersOutsideISO88591Encoding;
}
sb += ch;
@@ -60,10 +60,10 @@ void CBC_EncoderContext::setSkipAtEnd(int32_t count) {
m_skipAtEnd = count;
}
wchar_t CBC_EncoderContext::getCurrentChar() {
- return m_msg.GetAt(m_pos);
+ return m_msg[m_pos];
}
wchar_t CBC_EncoderContext::getCurrent() {
- return m_msg.GetAt(m_pos);
+ return m_msg[m_pos];
}
void CBC_EncoderContext::writeCodewords(const CFX_WideString& codewords) {
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 4071602303..2e84df5c59 100644
--- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -150,7 +150,7 @@ CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords,
for (int32_t block = 0; block < blockCount; block++) {
CFX_WideString temp;
for (int32_t d = block; d < symbolInfo->dataCapacity(); d += blockCount) {
- temp += (wchar_t)codewords.GetAt(d);
+ temp += (wchar_t)codewords[d];
}
CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e);
if (e != BCExceptionNO)
@@ -158,7 +158,7 @@ CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords,
int32_t pos = 0;
for (int32_t l = block; l < errorSizes[block] * blockCount;
l += blockCount) {
- sb.SetAt(symbolInfo->dataCapacity() + l, ecc.GetAt(pos++));
+ sb.SetAt(symbolInfo->dataCapacity() + l, ecc[pos++]);
}
}
}
@@ -186,7 +186,7 @@ CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords,
uint16_t* ecc = FX_Alloc(uint16_t, numECWords);
memset(ecc, 0, numECWords * sizeof(uint16_t));
for (int32_t l = start; l < start + len; l++) {
- uint16_t m = ecc[numECWords - 1] ^ codewords.GetAt(l);
+ uint16_t m = ecc[numECWords - 1] ^ codewords[l];
for (int32_t k = numECWords - 1; k > 0; k--) {
if (m != 0 && FACTORS[table][k] != 0) {
ecc[k] = (uint16_t)(ecc[k - 1] ^
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 6034173ee4..8b8b413c9b 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -174,7 +174,7 @@ int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg,
}
return C40_ENCODATION;
}
- wchar_t c = msg.GetAt(startpos + charsProcessed);
+ wchar_t c = msg[startpos + charsProcessed];
charsProcessed++;
if (isDigit(c)) {
charCounts[ASCII_ENCODATION] += 0.5;
@@ -253,7 +253,7 @@ int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg,
if (intCharCounts[C40_ENCODATION] == intCharCounts[X12_ENCODATION]) {
int32_t p = startpos + charsProcessed + 1;
while (p < msg.GetLength()) {
- wchar_t tc = msg.GetAt(p);
+ wchar_t tc = msg[p];
if (isX12TermSep(tc)) {
return X12_ENCODATION;
}
@@ -280,12 +280,12 @@ int32_t CBC_HighLevelEncoder::determineConsecutiveDigitCount(CFX_WideString msg,
int32_t len = msg.GetLength();
int32_t idx = startpos;
if (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
while (isDigit(ch) && idx < len) {
count++;
idx++;
if (idx < len) {
- ch = msg.GetAt(idx);
+ ch = msg[idx];
}
}
}
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
index 14ffcdfc35..ecaeb8d656 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -106,7 +106,7 @@ CFX_WideString CBC_OnedCodaBarWriter::FilterContents(
CFX_WideString filtercontents;
wchar_t ch;
for (int32_t index = 0; index < contents.GetLength(); index++) {
- ch = contents.GetAt(index);
+ ch = contents[index];
if (ch > 175) {
index++;
continue;
@@ -137,7 +137,7 @@ uint8_t* CBC_OnedCodaBarWriter::EncodeImpl(const CFX_ByteString& contents,
char ch;
int32_t position = 0;
for (int32_t index = 0; index < data.GetLength(); index++) {
- ch = data.GetAt(index);
+ ch = data[index];
if (((ch >= 'a') && (ch <= 'z'))) {
ch = ch - 32;
}
diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp
index b9d594a028..cd87231fdf 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer.cpp
+++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp
@@ -50,7 +50,7 @@ CBC_OnedCode39Writer::~CBC_OnedCode39Writer() {}
bool CBC_OnedCode39Writer::CheckContentValidity(
const CFX_WideStringC& contents) {
for (int32_t i = 0; i < contents.GetLength(); i++) {
- wchar_t ch = contents.GetAt(i);
+ wchar_t ch = contents[i];
if ((ch >= (wchar_t)'0' && ch <= (wchar_t)'9') ||
(ch >= (wchar_t)'A' && ch <= (wchar_t)'Z') || ch == (wchar_t)'-' ||
ch == (wchar_t)'.' || ch == (wchar_t)' ' || ch == (wchar_t)'*' ||
@@ -67,7 +67,7 @@ CFX_WideString CBC_OnedCode39Writer::FilterContents(
const CFX_WideStringC& contents) {
CFX_WideString filtercontents;
for (int32_t i = 0; i < contents.GetLength(); i++) {
- wchar_t ch = contents.GetAt(i);
+ wchar_t ch = contents[i];
if (ch == (wchar_t)'*' && (i == 0 || i == contents.GetLength() - 1)) {
continue;
}
@@ -92,7 +92,7 @@ CFX_WideString CBC_OnedCode39Writer::RenderTextContents(
const CFX_WideStringC& contents) {
CFX_WideString renderContents;
for (int32_t i = 0; i < contents.GetLength(); i++) {
- wchar_t ch = contents.GetAt(i);
+ wchar_t ch = contents[i];
if (ch == (wchar_t)'*' && (i == 0 || i == contents.GetLength() - 1)) {
continue;
}
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 6f1d957a01..85f545c602 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -64,7 +64,7 @@ CFX_WideString CBC_OnedEAN13Writer::FilterContents(
CFX_WideString filtercontents;
wchar_t ch;
for (int32_t i = 0; i < contents.GetLength(); i++) {
- ch = contents.GetAt(i);
+ ch = contents[i];
if (ch > 175) {
i++;
continue;
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 9a85f814a7..ae10fe52ef 100644
--- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -70,7 +70,7 @@ CFX_WideString CBC_OnedEAN8Writer::FilterContents(
CFX_WideString filtercontents;
wchar_t ch;
for (int32_t i = 0; i < contents.GetLength(); i++) {
- ch = contents.GetAt(i);
+ ch = contents[i];
if (ch > 175) {
i++;
continue;
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 13514eb53f..fff4184221 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -43,7 +43,7 @@ CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {}
bool CBC_OnedUPCAWriter::CheckContentValidity(const CFX_WideStringC& contents) {
for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) {
- if (contents.GetAt(i) < '0' || contents.GetAt(i) > '9')
+ if (contents[i] < '0' || contents[i] > '9')
return false;
}
return true;
@@ -54,7 +54,7 @@ CFX_WideString CBC_OnedUPCAWriter::FilterContents(
CFX_WideString filtercontents;
wchar_t ch;
for (int32_t i = 0; i < contents.GetLength(); i++) {
- ch = contents.GetAt(i);
+ ch = contents[i];
if (ch > 175) {
i++;
continue;
diff --git a/fxbarcode/pdf417/BC_PDF417.cpp b/fxbarcode/pdf417/BC_PDF417.cpp
index 9844798b24..3f492f9c10 100644
--- a/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/fxbarcode/pdf417/BC_PDF417.cpp
@@ -523,7 +523,7 @@ void CBC_PDF417::encodeLowLevel(CFX_WideString fullCodewords,
int32_t pattern = CODEWORD_TABLE[cluster][left];
encodeChar(pattern, 17, logic->getCurrentRow());
for (int32_t x = 0; x < c; x++) {
- pattern = CODEWORD_TABLE[cluster][fullCodewords.GetAt(idx)];
+ pattern = CODEWORD_TABLE[cluster][fullCodewords[idx]];
encodeChar(pattern, 17, logic->getCurrentRow());
idx++;
}
diff --git a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
index 6f1d7946eb..1d8258e720 100644
--- a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
+++ b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
@@ -145,7 +145,7 @@ bool CBC_PDF417ErrorCorrection::generateErrorCorrection(
std::vector<wchar_t> ech(k);
int32_t sld = dataCodewords.GetLength();
for (int32_t i = 0; i < sld; i++) {
- int32_t t1 = (dataCodewords.GetAt(i) + ech[k - 1]) % 929;
+ int32_t t1 = (dataCodewords[i] + ech[k - 1]) % 929;
int32_t t2;
int32_t t3;
for (int32_t j = k - 1; j >= 1; j--) {
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index f65cfe46ae..c531716e4f 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -64,8 +64,8 @@ CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel(
CFX_WideString msg;
int32_t len = bytes.GetLength();
for (int32_t i = 0; i < len; i++) {
- wchar_t ch = (wchar_t)(bytes.GetAt(i) & 0xff);
- if (ch == '?' && bytes.GetAt(i) != '?') {
+ wchar_t ch = (wchar_t)(bytes[i] & 0xff);
+ if (ch == '?' && bytes[i] != '?') {
e = BCExceptionCharactersOutsideISO88591Encoding;
return CFX_WideString();
}
@@ -154,7 +154,7 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
int32_t submode = initialSubmode;
int32_t idx = 0;
while (true) {
- wchar_t ch = msg.GetAt(startpos + idx);
+ wchar_t ch = msg[startpos + idx];
switch (submode) {
case SUBMODE_ALPHA:
if (isAlphaUpper(ch)) {
@@ -216,7 +216,7 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
continue;
} else {
if (startpos + idx + 1 < count) {
- wchar_t next = msg.GetAt(startpos + idx + 1);
+ wchar_t next = msg[startpos + idx + 1];
if (isPunctuation(next)) {
submode = SUBMODE_PUNCTUATION;
tmp += (wchar_t)25;
@@ -247,10 +247,10 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
for (int32_t i = 0; i < len; i++) {
bool odd = (i % 2) != 0;
if (odd) {
- h = (wchar_t)((h * 30) + tmp.GetAt(i));
+ h = (wchar_t)((h * 30) + tmp[i]);
sb += h;
} else {
- h = tmp.GetAt(i);
+ h = tmp[i];
}
}
if ((len % 2) != 0) {
@@ -313,7 +313,7 @@ void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg,
bigint = bigint / num900;
} while (!bigint.isZero());
for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) {
- sb += tmp.GetAt(i);
+ sb += tmp[i];
}
idx += len;
}
@@ -343,12 +343,12 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount(
int32_t len = msg.GetLength();
int32_t idx = startpos;
if (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
while (isDigit(ch) && idx < len) {
count++;
idx++;
if (idx < len) {
- ch = msg.GetAt(idx);
+ ch = msg[idx];
}
}
}
@@ -360,13 +360,13 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(
int32_t len = msg.GetLength();
int32_t idx = startpos;
while (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
int32_t numericCount = 0;
while (numericCount < 13 && isDigit(ch) && idx < len) {
numericCount++;
idx++;
if (idx < len) {
- ch = msg.GetAt(idx);
+ ch = msg[idx];
}
}
if (numericCount >= 13) {
@@ -375,7 +375,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(
if (numericCount > 0) {
continue;
}
- ch = msg.GetAt(idx);
+ ch = msg[idx];
if (!isText(ch)) {
break;
}
@@ -391,7 +391,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
int32_t len = msg.GetLength();
int32_t idx = startpos;
while (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
int32_t numericCount = 0;
while (numericCount < 13 && isDigit(ch)) {
numericCount++;
@@ -399,7 +399,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
if (i >= len) {
break;
}
- ch = msg.GetAt(i);
+ ch = msg[i];
}
if (numericCount >= 13) {
return idx - startpos;
@@ -411,12 +411,12 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
if (i >= len) {
break;
}
- ch = msg.GetAt(i);
+ ch = msg[i];
}
if (textCount >= 5) {
return idx - startpos;
}
- ch = msg.GetAt(idx);
+ ch = msg[idx];
if ((*bytes)[idx] == 63 && ch != '?') {
e = BCExceptionNonEncodableCharacterDetected;
return -1;
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index cad70b81c5..f779ed4b95 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -426,9 +426,10 @@ void MergeString(std::vector<ModeStringPair>* result,
void SplitString(const CFX_ByteString& content,
std::vector<ModeStringPair>* result) {
int32_t index = 0;
- while (index < content.GetLength() &&
- ((content[index] >= 0xA1 && content[index] <= 0xAA) ||
- (content[index] >= 0xB0 && content[index] <= 0xFA))) {
+ while (index < content.GetLength()) {
+ uint8_t c = static_cast<uint8_t>(content[index]);
+ if (!((c >= 0xA1 && c <= 0xAA) || (c >= 0xB0 && c <= 0xFA)))
+ break;
index += 2;
}
if (index)
@@ -438,9 +439,10 @@ void SplitString(const CFX_ByteString& content,
int32_t flag = index;
while (GetAlphaNumericCode(content[index]) == -1 &&
- index < content.GetLength() &&
- !((content[index] >= 0xA1 && content[index] <= 0xAA) ||
- (content[index] >= 0xB0 && content[index] <= 0xFA))) {
+ index < content.GetLength()) {
+ uint8_t c = static_cast<uint8_t>(content[index]);
+ if (((c >= 0xA1 && c <= 0xAA) || (c >= 0xB0 && c <= 0xFA)))
+ break;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
bool high = !!IsDBCSLeadByte(content[index]);
#else