From c0cf369e0bd58ce5ae910d0b8636f6f23eca1490 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 30 Mar 2017 23:34:45 -0700 Subject: Fix QR code generation. Roll DEPS for testing corpus to 2c5a026 to verify. This regressed in commit c8017b2. BUG=pdfium:692 Change-Id: Ic09ed53db8b3cc81abb2bdea863b8cf32f614197 Reviewed-on: https://pdfium-review.googlesource.com/3510 Commit-Queue: Tom Sepez Reviewed-by: Tom Sepez --- fxbarcode/qrcode/BC_QRCoderEncoder.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'fxbarcode/qrcode') diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index 29dc69996b..ae9a8ebd14 100644 --- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -487,8 +487,9 @@ catchException: qrCode->GetVersion(), qrCode->GetMaskPattern(), matrix.get(), e); if (e != BCExceptionNO) - return qrCode->SetMatrix(std::move(matrix)); + return; + qrCode->SetMatrix(std::move(matrix)); if (!qrCode->IsValid()) e = BCExceptionInvalidQRCode; } @@ -523,7 +524,8 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content, return; headerAndDataBits.AppendBitVector(&dataBits, e); if (e != BCExceptionNO) - return TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); + return; + TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e); if (e != BCExceptionNO) return; CBC_QRCoderBitVector finalBits; @@ -547,8 +549,9 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content, qrCode->GetVersion(), qrCode->GetMaskPattern(), matrix.get(), e); if (e != BCExceptionNO) - return qrCode->SetMatrix(std::move(matrix)); + return; + qrCode->SetMatrix(std::move(matrix)); if (!qrCode->IsValid()) e = BCExceptionInvalidQRCode; } @@ -629,9 +632,9 @@ int32_t CBC_QRCoderEncoder::CalculateMaskPenalty(CBC_CommonByteMatrix* matrix) { CBC_QRCoderMode* CBC_QRCoderEncoder::ChooseMode(const CFX_ByteString& content, CFX_ByteString encoding) { - if (encoding.Compare("SHIFT_JIS") == 0) { + if (encoding.Compare("SHIFT_JIS") == 0) return CBC_QRCoderMode::sKANJI; - } + bool hasNumeric = false; bool hasAlphaNumeric = false; for (int32_t i = 0; i < content.GetLength(); i++) { @@ -643,11 +646,10 @@ CBC_QRCoderMode* CBC_QRCoderEncoder::ChooseMode(const CFX_ByteString& content, return CBC_QRCoderMode::sBYTE; } } - if (hasAlphaNumeric) { + if (hasAlphaNumeric) return CBC_QRCoderMode::sALPHANUMERIC; - } else if (hasNumeric) { + if (hasNumeric) return CBC_QRCoderMode::sNUMERIC; - } return CBC_QRCoderMode::sBYTE; } -- cgit v1.2.3