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

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp

Issue 18293014: pdfviewer: fix warnings on mac (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #include "SkNativeParsedPDF.h" 1 #include "SkNativeParsedPDF.h"
2 #include "SkPdfNativeTokenizer.h" 2 #include "SkPdfNativeTokenizer.h"
3 #include "SkPdfBasics.h" 3 #include "SkPdfBasics.h"
4 #include "SkPdfParser.h" 4 #include "SkPdfParser.h"
5 #include "SkPdfObject.h" 5 #include "SkPdfObject.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
11 11
12 #include "SkPdfFileTrailerDictionary_autogen.h" 12 #include "SkPdfFileTrailerDictionary_autogen.h"
13 #include "SkPdfCatalogDictionary_autogen.h" 13 #include "SkPdfCatalogDictionary_autogen.h"
14 #include "SkPdfPageObjectDictionary_autogen.h" 14 #include "SkPdfPageObjectDictionary_autogen.h"
15 #include "SkPdfPageTreeNodeDictionary_autogen.h" 15 #include "SkPdfPageTreeNodeDictionary_autogen.h"
16 #include "SkPdfMapper_autogen.h" 16 #include "SkPdfMapper_autogen.h"
17 17
18 18
19 19
20 long getFileSize(const char* filename) 20 static long getFileSize(const char* filename)
21 { 21 {
22 struct stat stat_buf; 22 struct stat stat_buf;
23 int rc = stat(filename, &stat_buf); 23 int rc = stat(filename, &stat_buf);
24 return rc == 0 ? stat_buf.st_size : -1; 24 return rc == 0 ? (long)stat_buf.st_size : -1;
25 } 25 }
26 26
27 unsigned char* lineHome(unsigned char* start, unsigned char* current) { 27 static unsigned char* lineHome(unsigned char* start, unsigned char* current) {
28 while (current > start && !isPdfEOL(*(current - 1))) { 28 while (current > start && !isPdfEOL(*(current - 1))) {
29 current--; 29 current--;
30 } 30 }
31 return current; 31 return current;
32 } 32 }
33 33
34 unsigned char* previousLineHome(unsigned char* start, unsigned char* current) { 34 static unsigned char* previousLineHome(unsigned char* start, unsigned char* curr ent) {
35 if (current > start && isPdfEOL(*(current - 1))) { 35 if (current > start && isPdfEOL(*(current - 1))) {
36 current--; 36 current--;
37 } 37 }
38 38
39 // allows CR+LF, LF+CR but not two CR+CR or LF+LF 39 // allows CR+LF, LF+CR but not two CR+CR or LF+LF
40 if (current > start && isPdfEOL(*(current - 1)) && *current != *(current - 1 )) { 40 if (current > start && isPdfEOL(*(current - 1)) && *current != *(current - 1 )) {
41 current--; 41 current--;
42 } 42 }
43 43
44 while (current > start && !isPdfEOL(*(current - 1))) { 44 while (current > start && !isPdfEOL(*(current - 1))) {
45 current--; 45 current--;
46 } 46 }
47 47
48 return current; 48 return current;
49 } 49 }
50 50
51 unsigned char* ignoreLine(unsigned char* current, unsigned char* end) { 51 static unsigned char* ignoreLine(unsigned char* current, unsigned char* end) {
52 while (current < end && !isPdfEOL(*current)) { 52 while (current < end && !isPdfEOL(*current)) {
53 current++; 53 current++;
54 } 54 }
55 current++; 55 current++;
56 if (current < end && isPdfEOL(*current) && *current != *(current - 1)) { 56 if (current < end && isPdfEOL(*current) && *current != *(current - 1)) {
57 current++; 57 current++;
58 } 58 }
59 return current; 59 return current;
60 } 60 }
61 61
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 SkPdfObject token; 116 SkPdfObject token;
117 while (current < trailerEnd) { 117 while (current < trailerEnd) {
118 token.reset(); 118 token.reset();
119 unsigned char* previous = current; 119 unsigned char* previous = current;
120 current = nextObject(current, trailerEnd, &token, NULL); 120 current = nextObject(current, trailerEnd, &token, NULL);
121 if (!token.isInteger()) { 121 if (!token.isInteger()) {
122 return previous; 122 return previous;
123 } 123 }
124 124
125 int startId = token.intValue(); 125 int startId = (int)token.intValue();
126 token.reset(); 126 token.reset();
127 current = nextObject(current, trailerEnd, &token, NULL); 127 current = nextObject(current, trailerEnd, &token, NULL);
128 128
129 if (!token.isInteger()) { 129 if (!token.isInteger()) {
130 // TODO(edisonn): report/warning 130 // TODO(edisonn): report/warning
131 return current; 131 return current;
132 } 132 }
133 133
134 int entries = token.intValue(); 134 int entries = (int)token.intValue();
135 135
136 for (int i = 0; i < entries; i++) { 136 for (int i = 0; i < entries; i++) {
137 token.reset(); 137 token.reset();
138 current = nextObject(current, trailerEnd, &token, NULL); 138 current = nextObject(current, trailerEnd, &token, NULL);
139 if (!token.isInteger()) { 139 if (!token.isInteger()) {
140 // TODO(edisonn): report/warning 140 // TODO(edisonn): report/warning
141 return current; 141 return current;
142 } 142 }
143 int offset = token.intValue(); 143 int offset = (int)token.intValue();
144 144
145 token.reset(); 145 token.reset();
146 current = nextObject(current, trailerEnd, &token, NULL); 146 current = nextObject(current, trailerEnd, &token, NULL);
147 if (!token.isInteger()) { 147 if (!token.isInteger()) {
148 // TODO(edisonn): report/warning 148 // TODO(edisonn): report/warning
149 return current; 149 return current;
150 } 150 }
151 int generation = token.intValue(); 151 int generation = (int)token.intValue();
152 152
153 token.reset(); 153 token.reset();
154 current = nextObject(current, trailerEnd, &token, NULL); 154 current = nextObject(current, trailerEnd, &token, NULL);
155 if (!token.isKeyword() || token.len() != 1 || (*token.c_str() != 'f' && *token.c_str() != 'n')) { 155 if (!token.isKeyword() || token.len() != 1 || (*token.c_str() != 'f' && *token.c_str() != 'n')) {
156 // TODO(edisonn): report/warning 156 // TODO(edisonn): report/warning
157 return current; 157 return current;
158 } 158 }
159 159
160 addCrossSectionInfo(startId + i, generation, offset, *token.c_str() == 'f'); 160 addCrossSectionInfo(startId + i, generation, offset, *token.c_str() == 'f');
161 } 161 }
(...skipping 12 matching lines...) Expand all
174 if (storeCatalog) { 174 if (storeCatalog) {
175 const SkPdfObject* ref = trailer->Root(NULL); 175 const SkPdfObject* ref = trailer->Root(NULL);
176 if (ref == NULL || !ref->isReference()) { 176 if (ref == NULL || !ref->isReference()) {
177 // TODO(edisonn): oops, we have to fix the corrup pdf file 177 // TODO(edisonn): oops, we have to fix the corrup pdf file
178 return -1; 178 return -1;
179 } 179 }
180 fRootCatalogRef = ref; 180 fRootCatalogRef = ref;
181 } 181 }
182 182
183 if (trailer->has_Prev()) { 183 if (trailer->has_Prev()) {
184 return trailer->Prev(NULL); 184 return (long)trailer->Prev(NULL);
185 } 185 }
186 186
187 return -1; 187 return -1;
188 } 188 }
189 189
190 void SkNativeParsedPDF::addCrossSectionInfo(int id, int generation, int offset, bool isFreed) { 190 void SkNativeParsedPDF::addCrossSectionInfo(int id, int generation, int offset, bool isFreed) {
191 // TODO(edisonn): security here 191 // TODO(edisonn): security here
192 while (fObjects.count() < id + 1) { 192 while (fObjects.count() < id + 1) {
193 reset(fObjects.append()); 193 reset(fObjects.append());
194 } 194 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } else { 460 } else {
461 fObjects[id].fResolvedReference = resolveReference(fObjects[id]. fObj); 461 fObjects[id].fResolvedReference = resolveReference(fObjects[id]. fObj);
462 } 462 }
463 } 463 }
464 464
465 return fObjects[id].fResolvedReference; 465 return fObjects[id].fResolvedReference;
466 } 466 }
467 // TODO(edisonn): fix the mess with const, probably we need to remove it pre tty much everywhere 467 // TODO(edisonn): fix the mess with const, probably we need to remove it pre tty much everywhere
468 return (SkPdfObject*)ref; 468 return (SkPdfObject*)ref;
469 } 469 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfParser.cpp ('k') | experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698