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

Side by Side Diff: fpdfsdk/src/fsdk_baseannot.cpp

Issue 1405253007: Revert "Revert "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix mac build Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fsdk_baseannot.h" 9 #include "../include/fsdk_baseannot.h"
10 10
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( 215 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
216 const CFX_ByteString& dtStr) { 216 const CFX_ByteString& dtStr) {
217 int strLength = dtStr.GetLength(); 217 int strLength = dtStr.GetLength();
218 if (strLength > 0) { 218 if (strLength > 0) {
219 int i = 0; 219 int i = 0;
220 int j, k; 220 int j, k;
221 FX_CHAR ch; 221 FX_CHAR ch;
222 while (i < strLength) { 222 while (i < strLength) {
223 ch = dtStr[i]; 223 ch = dtStr[i];
224 if (ch >= '0' && ch <= '9') 224 if (std::isdigit(ch))
225 break; 225 break;
226 i++; 226 i++;
227 } 227 }
228 if (i >= strLength) 228 if (i >= strLength)
229 return *this; 229 return *this;
230 230
231 j = 0; 231 j = 0;
232 k = 0; 232 k = 0;
233 while (i < strLength && j < 4) { 233 while (i < strLength && j < 4) {
234 ch = dtStr[i]; 234 ch = dtStr[i];
235 k = k * 10 + ch - '0'; 235 k = k * 10 + ch - '0';
236 j++; 236 j++;
237 if (ch < '0' || ch > '9') 237 if (!std::isdigit(ch))
238 break; 238 break;
239 i++; 239 i++;
240 } 240 }
241 dt.year = (int16_t)k; 241 dt.year = (int16_t)k;
242 if (i >= strLength || j < 4) 242 if (i >= strLength || j < 4)
243 return *this; 243 return *this;
244 244
245 j = 0; 245 j = 0;
246 k = 0; 246 k = 0;
247 while (i < strLength && j < 2) { 247 while (i < strLength && j < 2) {
248 ch = dtStr[i]; 248 ch = dtStr[i];
249 k = k * 10 + ch - '0'; 249 k = k * 10 + ch - '0';
250 j++; 250 j++;
251 if (ch < '0' || ch > '9') 251 if (!std::isdigit(ch))
252 break; 252 break;
253 i++; 253 i++;
254 } 254 }
255 dt.month = (uint8_t)k; 255 dt.month = (uint8_t)k;
256 if (i >= strLength || j < 2) 256 if (i >= strLength || j < 2)
257 return *this; 257 return *this;
258 258
259 j = 0; 259 j = 0;
260 k = 0; 260 k = 0;
261 while (i < strLength && j < 2) { 261 while (i < strLength && j < 2) {
262 ch = dtStr[i]; 262 ch = dtStr[i];
263 k = k * 10 + ch - '0'; 263 k = k * 10 + ch - '0';
264 j++; 264 j++;
265 if (ch < '0' || ch > '9') 265 if (!std::isdigit(ch))
266 break; 266 break;
267 i++; 267 i++;
268 } 268 }
269 dt.day = (uint8_t)k; 269 dt.day = (uint8_t)k;
270 if (i >= strLength || j < 2) 270 if (i >= strLength || j < 2)
271 return *this; 271 return *this;
272 272
273 j = 0; 273 j = 0;
274 k = 0; 274 k = 0;
275 while (i < strLength && j < 2) { 275 while (i < strLength && j < 2) {
276 ch = dtStr[i]; 276 ch = dtStr[i];
277 k = k * 10 + ch - '0'; 277 k = k * 10 + ch - '0';
278 j++; 278 j++;
279 if (ch < '0' || ch > '9') 279 if (!std::isdigit(ch))
280 break; 280 break;
281 i++; 281 i++;
282 } 282 }
283 dt.hour = (uint8_t)k; 283 dt.hour = (uint8_t)k;
284 if (i >= strLength || j < 2) 284 if (i >= strLength || j < 2)
285 return *this; 285 return *this;
286 286
287 j = 0; 287 j = 0;
288 k = 0; 288 k = 0;
289 while (i < strLength && j < 2) { 289 while (i < strLength && j < 2) {
290 ch = dtStr[i]; 290 ch = dtStr[i];
291 k = k * 10 + ch - '0'; 291 k = k * 10 + ch - '0';
292 j++; 292 j++;
293 if (ch < '0' || ch > '9') 293 if (!std::isdigit(ch))
294 break; 294 break;
295 i++; 295 i++;
296 } 296 }
297 dt.minute = (uint8_t)k; 297 dt.minute = (uint8_t)k;
298 if (i >= strLength || j < 2) 298 if (i >= strLength || j < 2)
299 return *this; 299 return *this;
300 300
301 j = 0; 301 j = 0;
302 k = 0; 302 k = 0;
303 while (i < strLength && j < 2) { 303 while (i < strLength && j < 2) {
304 ch = dtStr[i]; 304 ch = dtStr[i];
305 k = k * 10 + ch - '0'; 305 k = k * 10 + ch - '0';
306 j++; 306 j++;
307 if (ch < '0' || ch > '9') 307 if (!std::isdigit(ch))
308 break; 308 break;
309 i++; 309 i++;
310 } 310 }
311 dt.second = (uint8_t)k; 311 dt.second = (uint8_t)k;
312 if (i >= strLength || j < 2) 312 if (i >= strLength || j < 2)
313 return *this; 313 return *this;
314 314
315 ch = dtStr[i++]; 315 ch = dtStr[i++];
316 if (ch != '-' && ch != '+') 316 if (ch != '-' && ch != '+')
317 return *this; 317 return *this;
318 if (ch == '-') 318 if (ch == '-')
319 dt.tzHour = -1; 319 dt.tzHour = -1;
320 else 320 else
321 dt.tzHour = 1; 321 dt.tzHour = 1;
322 j = 0; 322 j = 0;
323 k = 0; 323 k = 0;
324 while (i < strLength && j < 2) { 324 while (i < strLength && j < 2) {
325 ch = dtStr[i]; 325 ch = dtStr[i];
326 k = k * 10 + ch - '0'; 326 k = k * 10 + ch - '0';
327 j++; 327 j++;
328 if (ch < '0' || ch > '9') 328 if (!std::isdigit(ch))
329 break; 329 break;
330 i++; 330 i++;
331 } 331 }
332 dt.tzHour *= (FX_CHAR)k; 332 dt.tzHour *= (FX_CHAR)k;
333 if (i >= strLength || j < 2) 333 if (i >= strLength || j < 2)
334 return *this; 334 return *this;
335 335
336 ch = dtStr[i++]; 336 ch = dtStr[i++];
337 if (ch != '\'') 337 if (ch != '\'')
338 return *this; 338 return *this;
339 j = 0; 339 j = 0;
340 k = 0; 340 k = 0;
341 while (i < strLength && j < 2) { 341 while (i < strLength && j < 2) {
342 ch = dtStr[i]; 342 ch = dtStr[i];
343 k = k * 10 + ch - '0'; 343 k = k * 10 + ch - '0';
344 j++; 344 j++;
345 if (ch < '0' || ch > '9') 345 if (!std::isdigit(ch))
346 break; 346 break;
347 i++; 347 i++;
348 } 348 }
349 dt.tzMinute = (uint8_t)k; 349 dt.tzMinute = (uint8_t)k;
350 if (i >= strLength || j < 2) 350 if (i >= strLength || j < 2)
351 return *this; 351 return *this;
352 } 352 }
353 353
354 return *this; 354 return *this;
355 } 355 }
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 CPDF_Annot::Normal, NULL); 997 CPDF_Annot::Normal, NULL);
998 998
999 return; 999 return;
1000 } 1000 }
1001 1001
1002 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { 1002 CPDF_Page* CPDFSDK_Annot::GetPDFPage() {
1003 if (m_pPageView) 1003 if (m_pPageView)
1004 return m_pPageView->GetPDFPage(); 1004 return m_pPageView->GetPDFPage();
1005 return NULL; 1005 return NULL;
1006 } 1006 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698