summaryrefslogtreecommitdiff
path: root/fxbarcode
AgeCommit message (Collapse)Author
2017-08-11Remove potential out of bounds call to GetAt()Ryan Harrison
Since m_pos is passed into GetAt() on the underlying string in getCurrentChar(), the value of it needs to confirmed to be valid after decrementing. Some types were changed to reflect the values being stored. BUG=chromium:752480 Change-Id: Ib6d6f52326defd31785e70a17049a08b64dbe069 Reviewed-on: https://pdfium-review.googlesource.com/10652 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-11Add checks of index operations on string classesRyan Harrison
Specifically the index parameter passed in to GetAt(), SetAt() and operator[] are now being tested to be in bounds. BUG=chromium:752480, pdfium:828 Change-Id: I9e94d58c98a8eaaaae53cd0e3ffe2123ea17d8c4 Reviewed-on: https://pdfium-review.googlesource.com/10651 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-02Rewrite how string Insert() methods handle out of bound indicesRyan Harrison
The existing behaviour was to clamp the provided index to the valid bounds. This would lead to programming errors being hidden, since inserting would still do something even if the index calculation was wrong. The behaviour of these methods has been changed to instead early return when this occurs, returning the old length value. The caller can check if the call to Insert actually did anything by comparing the returned value to the length before calling insert. All of the existing calls to Insert have been tested by running all of the tests with asserts in the Insert method to check the index is in bounds. Additionally the call sites have been manually inspected. The majority of them are of the form Insert(0, foo) and the rest tend to be in a loop advancing from 0 to length. Convenience methods InsertAtFront/InsertAtBack have been added to handle calling Insert when the intent is for the character to be added to the beginning or end of the string. Existing call sites to Insert that do this have been converted. This work was originally being performed to check if there would be any issues in these methods with making FX_STRSIZE unsigned. BUG=pdfium:828 Change-Id: I60cee5ad45338aa8ed46569de7bcc78a76db18f7 Reviewed-on: https://pdfium-review.googlesource.com/9870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-01Replace raw value for constant error value in string operationsRyan Harrison
Currently Find() and other methods that return a FX_STRSIZE return -1 to indicate error/failure. This means that there is a lot of magic numbers and magic checks floating around. The standard library for similar operations uses a npos constant. This CL implements FX_STRNPOS, and replaces usages of magic number checking. It also does some type cleanup along the way where it was obvious that FX_STRSIZE should be being used. Removing the magic numbers should make eventually changing FX_STRSIZE to be unsigned easier in the future. BUG=pdfium:828 Change-Id: I67e481e44cf2f75a1698afa8fbee4f375a74c490 Reviewed-on: https://pdfium-review.googlesource.com/9651 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-07-28Convert calls to Mid() to Left() or Right() if possibleRyan Harrison
The various string/byte classes support Mid(), Left(), and Right() for extracting substrings. Mid() can handle all possible cases, but Left() and Right() are useful for common cases and more explicit about what is going on. Calls like Mid(offset, length - offset) can be converted to Right(length - offset). Calls like Mid(0, length) can be converted to Left(length). If the substring being extracted does not extend all the way to one of the edges of the string, then Mid() still needs to be used. BUG=pdfium:828 Change-Id: I2ec46ad3d71aac0f7b513e103c69cbe8c854cf62 Reviewed-on: https://pdfium-review.googlesource.com/9510 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-06-23Cleaning up fx_string_testhelpers.Henrique Nakashima
This is unused except for being a pathway for indirect deps. Change-Id: I717290235ccbc59429ad24231033382958e2a086 Reviewed-on: https://pdfium-review.googlesource.com/6910 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-05-26Replace SymbolShapeHint with a boolean.Lei Zhang
Delete BC_SymbolShapeHint.h since there is nothing left in it. Change-Id: Ic991064cd396f224966e5f3e8537fc62b5a9908a Reviewed-on: https://pdfium-review.googlesource.com/5835 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-25Mass conversion of remaining class members (non-xfa)Tom Sepez
Change-Id: I8365ba80e3395d59a3cf35dbd9d9162e86e712e3 Reviewed-on: https://pdfium-review.googlesource.com/5970 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-25Mass conversion of all const-lifetime class membersTom Sepez
Sed + minimal conversions to compile, including moving some constructors into the .cpp file. Any that caused ASAN issues during the tests were omitted rather than trying to resolve the underlying issue. Change-Id: I00a421f33b253eb4071ffd9af3f2922c7443b335 Reviewed-on: https://pdfium-review.googlesource.com/5891 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-24Cleanup CBC_SymbolInfo::lookup().Lei Zhang
Remove unused variants and simplify the one remaining variant. Change-Id: I9b6e596b479f95319a3b69f5db2c4d1b2cff4ebf Reviewed-on: https://pdfium-review.googlesource.com/5834 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-23Remove useless CBC_SymbolShapeHint.Lei Zhang
Mark some methods as virtual/override in formerly CBC_SymbolShapeHint derived classes. Change-Id: Ia6d83e0b2c63c8fb440bc1d5beb258a796e1d42f Reviewed-on: https://pdfium-review.googlesource.com/5738 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-23Clean up CBC_SymbolInfo.chromium/3109Lei Zhang
- Remove rectangular ctor param. It can be derived from dimensions. - Make members private and add accessors. - Remove exceptions that cannot occur. Change-Id: Iec113205241562a0559e594fe257f5b9064ed97e Reviewed-on: https://pdfium-review.googlesource.com/5737 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-23Remove CBC_HighLevelEncoder::isSpecialB256().Lei Zhang
It just returns false. Also make more CBC_HighLevelEncoder members const. Change-Id: I0236e84db0d8b5e5fa1a99ebc4a809770a332471 Reviewed-on: https://pdfium-review.googlesource.com/5739 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-19Move CCodec_ModuleMgr ownership to CPDF_ModuleMgr.Lei Zhang
More straight forward than CFX_GEModule owning in and CPDF_ModuleMgr holding a pointer to it. Remove assumptions that the codec modules may return nullptr, and do IWYU. Change-Id: Iba7fc3c7ec223fd6d29a1ab74ed13d35689bc5d5 Reviewed-on: https://pdfium-review.googlesource.com/5654 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-11Rename render device classesDan Sinclair
This Cl renames the CFX_RenderDevice subclasses to make their usage clearer. Change-Id: Ie820b57df9a3743ce8c6893fb483b398a1f1bdbe Reviewed-on: https://pdfium-review.googlesource.com/5390 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-05Represent 1D barcodes with CFX_PathData internally.Lei Zhang
Change-Id: If90483a8fee2e3a5cd90e7fe4600ff98b2703e5d Reviewed-on: https://pdfium-review.googlesource.com/5010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-04Reduce 1D barcode DrawPath calls.Lei Zhang
Draw vertical 1D barcodes as segments of lines, instead of as individual pixels. Change-Id: Ic260118660994514ce9023aacf13b16adfc8d362 Reviewed-on: https://pdfium-review.googlesource.com/4595 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-02Pass explicit string size in EncodeToCodewords().Lei Zhang
The input wchar_t array is not NUL-terminated. BUG=chromium:716706 Change-Id: I0a89324fa46a56a39cc3331fcdd1c26b1550828b Reviewed-on: https://pdfium-review.googlesource.com/4631 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-02Remove more |new|s, part 8Tom Sepez
Change-Id: I0e3f4bd33e66fd48db8371a5cc2f8db964720d08 Reviewed-on: https://pdfium-review.googlesource.com/4731 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-02Remove more |new|s, part 7Tom Sepez
Remove some dead code along the way. Move some getters to headers and make const. Change-Id: I14280c247b0cfeff8ad7f606302bc8bba1960f1e Reviewed-on: https://pdfium-review.googlesource.com/4730 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-01Remove more |new|s, part 5Tom Sepez
Many of these are already unique_ptrs. Change-Id: I3695d4ff5a8f7483ad994ac7657897fd55069cd5 Reviewed-on: https://pdfium-review.googlesource.com/4690 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-28Clean up private methods in CBC_C40Encoder.Lei Zhang
Change-Id: I0c33ec81ef9fd3ff7c22f33f5647a923aecd3e77 Reviewed-on: https://pdfium-review.googlesource.com/4594 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-28Remove dead dimensions code in fxbarcode.chromium/3084Lei Zhang
Remove more exceptions. Change-Id: I3b8b8b9837b0010b1e0060ddd56e93c78f9f0fb5 Reviewed-on: https://pdfium-review.googlesource.com/4410 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-27Add barcode test skeletonTom Sepez
Individual tests need some more fleshing out. Fix spelling of "Destroy" while we're at it. Bug: pdfium:699 Change-Id: I05f1da8654bfdf92cb264adae16e1b3209587a31 Reviewed-on: https://pdfium-review.googlesource.com/4550 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-04-27Remove CBC_HighLevelEncoder::illegalCharacter().Lei Zhang
It always return a failure. Change-Id: Ib318bbdb99b3ea38fba8ceb5733c6dcb8f14bbbf Reviewed-on: https://pdfium-review.googlesource.com/4590 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-25Simplify CBC_OnedCode128Writer methods.chromium/3081Lei Zhang
Change-Id: I963fcf416f623efd89832f61914df115b443a52c Reviewed-on: https://pdfium-review.googlesource.com/4494 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-25Delete some CFX string ctors.Lei Zhang
Prevent implicit construction of CFX_WideString from non-wchar_t variables. Similarly prevent implicit construction of CFX_ByteString from non-char variables. Fix up CBC_OnedCodaBarWriter which tries to do the above, and simplify code there using pdfium::ContainsValue(). Same for CPDF_FileSpec. Change-Id: I3db7125a68ef3f64c2f235d38e974767cd083dc3 Reviewed-on: https://pdfium-review.googlesource.com/4478 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-25Test more OnedCode128WriterTest methods.Lei Zhang
Change-Id: Ifc6e98af8e9f8505edce8b04836fbe0d6ab5743d Reviewed-on: https://pdfium-review.googlesource.com/4476 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-24Add tests for BC_OnedCode128Writer encoding functions.Lei Zhang
Make encoding functions return pattern indices instead of pattern pointers for easier testing. Also remove some dead code. Change-Id: Ib80d84b2e6828bbc8920b931d77bbcd82427f01a Reviewed-on: https://pdfium-review.googlesource.com/4474 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-21Replace FXSYS_iswdigit with std::iswdigit.Lei Zhang
Replace other one-off implementations as well. Change-Id: I2878f3fae479c12b7de5234ee3a26477d602d14d Reviewed-on: https://pdfium-review.googlesource.com/4398 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-21Change more fxbarcode to use return values.Lei Zhang
Change-Id: Idcc05fb8c5a1448f552b4db5ae131ad82aef4d59 Reviewed-on: https://pdfium-review.googlesource.com/4258 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-18Use Byte/WideString iteratorsTom Sepez
Change-Id: I85c8423c177fd7ecd5da90ef89419efc0f9cf44b Reviewed-on: https://pdfium-review.googlesource.com/4262 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-04-17Remove dead barcode bitmap rendering code.Lei Zhang
Change-Id: Idb5ef2aed456e84e0781c374b211560ab7d4fa3d Reviewed-on: https://pdfium-review.googlesource.com/4257 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-06Clean up CBC_QRCoderVersion and friends.Lei Zhang
Change-Id: Iff738c99fb4fe38d35515c280057b489624d734f Reviewed-on: https://pdfium-review.googlesource.com/3752 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-06Change some fxbarcode to use return values.Lei Zhang
No caller cares about the exception values anyway. Remove the unused ones. Also use more std::unique_ptr to stop potential leaks. Change-Id: Ic5955fb0d879f55e1c6a005c0204df50246dab19 Reviewed-on: https://pdfium-review.googlesource.com/3715 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-04Clean up QRCoderBitVector.Lei Zhang
Use std::vector and return booleans results when possible. Change-Id: If3ce4559f137fb449fd1ab818750558a1b5f8df0 Reviewed-on: https://pdfium-review.googlesource.com/3561 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-04Clean up QRCoderEncoder and friends.Lei Zhang
Remove a bunch of unused code, including gotos. Fix some potential memory leaks. Change-Id: Ia2775e2ab176f4741b765e259a24a293a5717394 Reviewed-on: https://pdfium-review.googlesource.com/3560 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-04Finish splitting up fx_dib.hNicolas Pena
After this CL, fx_dib.h only has some definitions used in multiple places. Definitions that were of restricted usage were moved out to the corresponding place. Includes in fx_dib were reduced, thus revealing other needed includes. Change-Id: I3607da0af81c491256d64c0aa085225631efbdcc Reviewed-on: https://pdfium-review.googlesource.com/3594 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-03Drop FXSYS_ from mem methodsDan Sinclair
This Cl drops the FXSYS_ from mem methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I9d5ae905997dbaaec5aa0b2ae4c07358ed9c6236 Reviewed-on: https://pdfium-review.googlesource.com/3613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-03Drop FXSYS_ from math methodsDan Sinclair
This Cl drops the FXSYS_ from math methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I85c9ff841fd9095b1434f67319847ba0cd9df7ac Reviewed-on: https://pdfium-review.googlesource.com/3598 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-03Move most CBC_QRCoderEncoder code into an anonymous namespace.Lei Zhang
Change-Id: I327a3f94cf6f00366d7a78ed9f973d00f702f397 Reviewed-on: https://pdfium-review.googlesource.com/3559 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-03-31Fix QR code generation.Lei Zhang
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 <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-30Add some calls to MakeUniqueDan Sinclair
This CL replaces some new's with pdfium::MakeUnique. Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb Reviewed-on: https://pdfium-review.googlesource.com/3430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-29Move xfa/fxbarcode fxbarcode/Dan Sinclair
Nothing in fxbarcode/ depends on XFA code. This CL moves xfa/fxbarcode to be fxbarcode/ and creates a static_library for fxbarcode which is depend on by the xfa library. Change-Id: I0b708737b07efb94b769a5238d92af92bc62880d Reviewed-on: https://pdfium-review.googlesource.com/3291 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>