OLD | NEW |
1 | 1 |
2 #include "SkPdfNativeTokenizer.h" | 2 #include "SkPdfNativeTokenizer.h" |
3 #include "SkPdfObject.h" | 3 #include "SkPdfObject.h" |
4 #include "SkPdfConfig.h" | 4 #include "SkPdfConfig.h" |
5 | 5 |
6 #include "SkPdfStreamCommonDictionary_autogen.h" | 6 #include "SkPdfStreamCommonDictionary_autogen.h" |
7 | 7 |
8 unsigned char* skipPdfWhiteSpaces(unsigned char* start, unsigned char* end) { | 8 unsigned char* skipPdfWhiteSpaces(unsigned char* start, unsigned char* end) { |
9 while (start < end && isPdfWhiteSpace(*start)) { | 9 while (start < end && isPdfWhiteSpace(*start)) { |
10 if (*start == kComment_PdfDelimiter) { | 10 if (*start == kComment_PdfDelimiter) { |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 SkPdfNativeTokenizer::SkPdfNativeTokenizer(unsigned char* buffer, int len, const
SkPdfMapper* mapper, SkPdfAllocator* allocator) : fMapper(mapper), fAllocator(a
llocator), fEmpty(false), fHasPutBack(false) { | 693 SkPdfNativeTokenizer::SkPdfNativeTokenizer(unsigned char* buffer, int len, const
SkPdfMapper* mapper, SkPdfAllocator* allocator) : fMapper(mapper), fAllocator(a
llocator), fEmpty(false), fHasPutBack(false) { |
694 fUncompressedStreamStart = fUncompressedStream = (unsigned char*)fAllocator-
>alloc(len); | 694 fUncompressedStreamStart = fUncompressedStream = (unsigned char*)fAllocator-
>alloc(len); |
695 fUncompressedStreamEnd = fUncompressedStream + len; | 695 fUncompressedStreamEnd = fUncompressedStream + len; |
696 memcpy(fUncompressedStream, buffer, len); | 696 memcpy(fUncompressedStream, buffer, len); |
697 } | 697 } |
698 | 698 |
699 SkPdfNativeTokenizer::~SkPdfNativeTokenizer() { | 699 SkPdfNativeTokenizer::~SkPdfNativeTokenizer() { |
700 // free the unparsed stream, we don't need it. | 700 // free the unparsed stream, we don't need it. |
701 // the parsed one is locked as it contains the strings and keywords referenc
ed in objects | 701 // the parsed one is locked as it contains the strings and keywords referenc
ed in objects |
702 if (fUncompressedStream) { | 702 if (fUncompressedStream) { |
703 realloc(fUncompressedStreamStart, fUncompressedStream - fUncompressedStr
eamStart); | 703 void* dummy = realloc(fUncompressedStreamStart, fUncompressedStream - fU
ncompressedStreamStart); |
| 704 SkASSERT(dummy == fUncompressedStreamStart); |
| 705 fUncompressedStreamStart = (unsigned char*)dummy; // suporess compiler
warning |
704 } else { | 706 } else { |
705 SkASSERT(false); | 707 SkASSERT(false); |
706 } | 708 } |
707 } | 709 } |
708 | 710 |
709 bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) { | 711 bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) { |
710 token->fKeyword = NULL; | 712 token->fKeyword = NULL; |
711 token->fObject = NULL; | 713 token->fObject = NULL; |
712 | 714 |
713 fUncompressedStream = skipPdfWhiteSpaces(fUncompressedStream, fUncompressedS
treamEnd); | 715 fUncompressedStream = skipPdfWhiteSpaces(fUncompressedStream, fUncompressedS
treamEnd); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 765 |
764 if (fEmpty) { | 766 if (fEmpty) { |
765 #ifdef PDF_TRACE | 767 #ifdef PDF_TRACE |
766 printf("EMPTY TOKENIZER\n"); | 768 printf("EMPTY TOKENIZER\n"); |
767 #endif | 769 #endif |
768 return false; | 770 return false; |
769 } | 771 } |
770 | 772 |
771 return readTokenCore(token); | 773 return readTokenCore(token); |
772 } | 774 } |
OLD | NEW |