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

Unified Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp

Issue 21096006: pdfviewer: load files with missing xref (we need in order to help with testing, as most good pdfx i… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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
Index: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp
===================================================================
--- experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (revision 10419)
+++ experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (working copy)
@@ -83,9 +83,9 @@
#define TRACE_HEXSTRING(start,end)
#endif
-static const unsigned char* skipPdfWhiteSpaces(int level, const unsigned char* start, const unsigned char* end) {
+const unsigned char* skipPdfWhiteSpaces(int level, const unsigned char* start, const unsigned char* end) {
TRACE_INDENT(level, "White Space");
- while (start < end && isPdfWhiteSpace(*start)) {
+ while (start < end && (isPdfWhiteSpace(*start) || *start == kComment_PdfDelimiter)) {
TRACE_COMMENT(*start);
if (*start == kComment_PdfDelimiter) {
// skip the comment until end of line
@@ -103,7 +103,7 @@
}
// TODO(edisonn) '(' can be used, will it break the string a delimiter or space inside () ?
-static const unsigned char* endOfPdfToken(int level, const unsigned char* start, const unsigned char* end) {
+const unsigned char* endOfPdfToken(int level, const unsigned char* start, const unsigned char* end) {
//int opened brackets
//TODO(edisonn): what out for special chars, like \n, \032
TRACE_INDENT(level, "Token");
@@ -636,6 +636,21 @@
// TODO(edisonn): laod external streams
// TODO(edisonn): look at the last filter, to determione how to deal with possible issue
+
+ if (length >= 0) {
+ const unsigned char* endstream = start + length;
+
+ if (endstream[0] == kCR_PdfWhiteSpace && endstream[1] == kLF_PdfWhiteSpace) {
+ endstream += 2;
+ } else if (endstream[0] == kLF_PdfWhiteSpace) {
+ endstream += 1;
+ }
+
+ if (strncmp((const char*)endstream, "endstream", strlen("endstream")) != 0) {
+ length = -1;
+ }
+ }
+
if (length < 0) {
// scan the buffer, until we find first endstream
// TODO(edisonn): all buffers must have a 0 at the end now,
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.h ('k') | experimental/PdfViewer/pdfparser/native/SkPdfObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698