Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1847333004: Remove _FXBSTR* and calls to FX_BSTRC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index bf691f41d2f2053404d6ef5d4e0f90f88c37c3c3..75897efce1ef42e9aeedcb2086ee7a791f6c5408 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -41,42 +41,42 @@ const char kPathOperatorCubicBezier3 = 'y';
const char kPathOperatorClosePath = 'h';
const char kPathOperatorRectangle[] = "re";
-struct _FX_BSTR {
+struct SimpleString {
const FX_CHAR* m_Ptr;
- int m_Size;
+ size_t m_Size;
};
-#define _FX_BSTRC(str) \
- { str, sizeof(str) - 1 }
+#define MakeSimpleString(str) \
+ { str, strlen(str) }
struct PDF_AbbrPairs {
Tom Sepez 2016/04/01 21:45:53 nit: singular (e.g AbbrPair).
dsinclair 2016/04/02 00:13:33 Done.
- _FX_BSTR full_name;
- _FX_BSTR abbr;
+ SimpleString full_name;
Tom Sepez 2016/04/01 21:45:53 Actually, its hard to justify this being anything
dsinclair 2016/04/02 00:13:33 Done.
+ SimpleString abbr;
};
const PDF_AbbrPairs PDF_InlineKeyAbbr[] = {
- {_FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC")},
- {_FX_BSTRC("ColorSpace"), _FX_BSTRC("CS")},
- {_FX_BSTRC("Decode"), _FX_BSTRC("D")},
- {_FX_BSTRC("DecodeParms"), _FX_BSTRC("DP")},
- {_FX_BSTRC("Filter"), _FX_BSTRC("F")},
- {_FX_BSTRC("Height"), _FX_BSTRC("H")},
- {_FX_BSTRC("ImageMask"), _FX_BSTRC("IM")},
- {_FX_BSTRC("Interpolate"), _FX_BSTRC("I")},
- {_FX_BSTRC("Width"), _FX_BSTRC("W")},
+ {MakeSimpleString("BitsPerComponent"), MakeSimpleString("BPC")},
Tom Sepez 2016/04/01 16:43:03 This theoretically generates static initializers s
dsinclair 2016/04/01 20:18:34 Ah, I failed to understand the comment in pdfium:1
+ {MakeSimpleString("ColorSpace"), MakeSimpleString("CS")},
+ {MakeSimpleString("Decode"), MakeSimpleString("D")},
+ {MakeSimpleString("DecodeParms"), MakeSimpleString("DP")},
+ {MakeSimpleString("Filter"), MakeSimpleString("F")},
+ {MakeSimpleString("Height"), MakeSimpleString("H")},
+ {MakeSimpleString("ImageMask"), MakeSimpleString("IM")},
+ {MakeSimpleString("Interpolate"), MakeSimpleString("I")},
+ {MakeSimpleString("Width"), MakeSimpleString("W")},
};
const PDF_AbbrPairs PDF_InlineValueAbbr[] = {
- {_FX_BSTRC("DeviceGray"), _FX_BSTRC("G")},
- {_FX_BSTRC("DeviceRGB"), _FX_BSTRC("RGB")},
- {_FX_BSTRC("DeviceCMYK"), _FX_BSTRC("CMYK")},
- {_FX_BSTRC("Indexed"), _FX_BSTRC("I")},
- {_FX_BSTRC("ASCIIHexDecode"), _FX_BSTRC("AHx")},
- {_FX_BSTRC("ASCII85Decode"), _FX_BSTRC("A85")},
- {_FX_BSTRC("LZWDecode"), _FX_BSTRC("LZW")},
- {_FX_BSTRC("FlateDecode"), _FX_BSTRC("Fl")},
- {_FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL")},
- {_FX_BSTRC("CCITTFaxDecode"), _FX_BSTRC("CCF")},
- {_FX_BSTRC("DCTDecode"), _FX_BSTRC("DCT")},
+ {MakeSimpleString("DeviceGray"), MakeSimpleString("G")},
+ {MakeSimpleString("DeviceRGB"), MakeSimpleString("RGB")},
+ {MakeSimpleString("DeviceCMYK"), MakeSimpleString("CMYK")},
+ {MakeSimpleString("Indexed"), MakeSimpleString("I")},
+ {MakeSimpleString("ASCIIHexDecode"), MakeSimpleString("AHx")},
+ {MakeSimpleString("ASCII85Decode"), MakeSimpleString("A85")},
+ {MakeSimpleString("LZWDecode"), MakeSimpleString("LZW")},
+ {MakeSimpleString("FlateDecode"), MakeSimpleString("Fl")},
+ {MakeSimpleString("RunLengthDecode"), MakeSimpleString("RL")},
+ {MakeSimpleString("CCITTFaxDecode"), MakeSimpleString("CCF")},
+ {MakeSimpleString("DCTDecode"), MakeSimpleString("DCT")},
};
struct AbbrReplacementOp {
@@ -102,7 +102,8 @@ CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPairs* table,
size_t count,
const CFX_ByteStringC& abbr) {
for (size_t i = 0; i < count; ++i) {
Tom Sepez 2016/04/01 16:43:03 std::find using cfx_ByteStringC's == operator shou
dsinclair 2016/04/02 00:13:33 Acknowledged.
- if (abbr.GetLength() != table[i].abbr.m_Size)
+ if (abbr.GetLength() < 0 ||
+ static_cast<size_t>(abbr.GetLength()) != table[i].abbr.m_Size)
continue;
if (memcmp(abbr.GetPtr(), table[i].abbr.m_Ptr, abbr.GetLength()))
continue;
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698