diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-09-06 13:35:25 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-06 20:08:48 +0000 |
commit | 7840dd6925308c39f87d3a1d0ef9e8ddc197f696 (patch) | |
tree | 3e705415c21a8e2a076711c777b9d1b460acef4c /fxbarcode/oned/BC_OnedEAN8Writer.cpp | |
parent | 45061669500e6f4fe71972e0fb60065b02c255bf (diff) | |
download | pdfium-7840dd6925308c39f87d3a1d0ef9e8ddc197f696.tar.xz |
Unify checksum calculation of EAN-8 and EAN-13.
The algorithm is the same.
Change-Id: Ia5713f6b1602aafac546047b8d398048d6532686
Reviewed-on: https://pdfium-review.googlesource.com/13290
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fxbarcode/oned/BC_OnedEAN8Writer.cpp')
-rw-r--r-- | fxbarcode/oned/BC_OnedEAN8Writer.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp index c3becc1a43..d4d438fe04 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -32,6 +32,7 @@ #include "fxbarcode/BC_Writer.h" #include "fxbarcode/common/BC_CommonBitMatrix.h" #include "fxbarcode/oned/BC_OneDimWriter.h" +#include "fxbarcode/oned/BC_OnedEANChecksum.h" namespace { @@ -84,18 +85,7 @@ CFX_WideString CBC_OnedEAN8Writer::FilterContents( } int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) { - int32_t odd = 0; - int32_t even = 0; - FX_STRSIZE parity = 1; - for (FX_STRSIZE i = contents.GetLength(); i > 0; i--) { - if (i % 2) { - odd += FXSYS_DecimalCharToInt(contents[i - 1]); - } else { - even += FXSYS_DecimalCharToInt(contents[i - 1]); - } - parity++; - } - return (10 - (odd * 3 + even) % 10) % 10; + return EANCalcChecksum(contents); } uint8_t* CBC_OnedEAN8Writer::EncodeWithHint(const CFX_ByteString& contents, |