OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPdfNativeTokenizer.h" | 8 #include "SkPdfNativeTokenizer.h" |
9 #include "SkPdfNativeObject.h" | 9 #include "SkPdfNativeObject.h" |
10 #include "SkPdfConfig.h" | 10 #include "SkPdfConfig.h" |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 804 |
805 return start; | 805 return start; |
806 } | 806 } |
807 | 807 |
808 const unsigned char* nextObject(int level, const unsigned char* start, const uns
igned char* end, SkPdfNativeObject* token, SkPdfAllocator* allocator, SkPdfNativ
eDoc* doc GET_TRACK_STREAM) { | 808 const unsigned char* nextObject(int level, const unsigned char* start, const uns
igned char* end, SkPdfNativeObject* token, SkPdfAllocator* allocator, SkPdfNativ
eDoc* doc GET_TRACK_STREAM) { |
809 const unsigned char* current; | 809 const unsigned char* current; |
810 | 810 |
811 // skip white spaces | 811 // skip white spaces |
812 start = skipPdfWhiteSpaces(level, start, end); | 812 start = skipPdfWhiteSpaces(level, start, end); |
813 | 813 |
| 814 if (start >= end) { |
| 815 return end; |
| 816 } |
| 817 |
814 current = endOfPdfToken(level, start, end); | 818 current = endOfPdfToken(level, start, end); |
815 | 819 |
816 // no token, len would be 0 | 820 // no token, len would be 0 |
817 if (current == start) { | 821 if (current == start || current == end) { |
818 return NULL; | 822 return end; |
819 } | 823 } |
820 | 824 |
821 int tokenLen = current - start; | 825 int tokenLen = current - start; |
822 | 826 |
823 if (tokenLen == 1) { | 827 if (tokenLen == 1) { |
824 // start array | 828 // start array |
825 switch (*start) { | 829 switch (*start) { |
826 case kOpenedSquareBracket_PdfDelimiter: | 830 case kOpenedSquareBracket_PdfDelimiter: |
827 //*start = '\0'; | 831 //*start = '\0'; |
828 return readArray(level + 1, current, end, token, allocator, doc
PUT_TRACK_STREAM_ARGS); | 832 return readArray(level + 1, current, end, token, allocator, doc
PUT_TRACK_STREAM_ARGS); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 SkPdfNativeObject* obj = fAllocator->allocObject(); | 1105 SkPdfNativeObject* obj = fAllocator->allocObject(); |
1102 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress
edStreamEnd, obj, fAllocator, fDoc PUT_TRACK_STREAM_ARGS_EXPL2(fStreamId, fUncom
pressedStreamStart)); | 1106 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress
edStreamEnd, obj, fAllocator, fDoc PUT_TRACK_STREAM_ARGS_EXPL2(fStreamId, fUncom
pressedStreamStart)); |
1103 // TODO(edisonn): perf maybe we should not expand abreviation like t
his | 1107 // TODO(edisonn): perf maybe we should not expand abreviation like t
his |
1104 inlineImage->set(inlineImageKeyAbbreviationExpand(key), | 1108 inlineImage->set(inlineImageKeyAbbreviationExpand(key), |
1105 inlineImageValueAbbreviationExpand(obj)); | 1109 inlineImageValueAbbreviationExpand(obj)); |
1106 } | 1110 } |
1107 } | 1111 } |
1108 // TODO(edisonn): report end of data with inline image without an EI | 1112 // TODO(edisonn): report end of data with inline image without an EI |
1109 return inlineImage; | 1113 return inlineImage; |
1110 } | 1114 } |
OLD | NEW |