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

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: Leftover comments from original CL. 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 "../../core/include/fxcrt/fx_ext.h"
7 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 9 #include "../include/fsdk_mgr.h"
9 #include "../include/fsdk_baseannot.h" 10 #include "../include/fsdk_baseannot.h"
10 11
11 //--------------------------------------------------------------------------- 12 //---------------------------------------------------------------------------
12 // CPDFSDK_DateTime 13 // CPDFSDK_DateTime
13 //--------------------------------------------------------------------------- 14 //---------------------------------------------------------------------------
14 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { 15 int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) {
15 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); 16 return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
16 } 17 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 215
215 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString( 216 CPDFSDK_DateTime& CPDFSDK_DateTime::FromPDFDateTimeString(
216 const CFX_ByteString& dtStr) { 217 const CFX_ByteString& dtStr) {
217 int strLength = dtStr.GetLength(); 218 int strLength = dtStr.GetLength();
218 if (strLength > 0) { 219 if (strLength > 0) {
219 int i = 0; 220 int i = 0;
220 int j, k; 221 int j, k;
221 FX_CHAR ch; 222 FX_CHAR ch;
222 while (i < strLength) { 223 while (i < strLength) {
223 ch = dtStr[i]; 224 ch = dtStr[i];
224 if (ch >= '0' && ch <= '9') 225 if (std::isdigit(ch))
225 break; 226 break;
226 i++; 227 i++;
227 } 228 }
228 if (i >= strLength) 229 if (i >= strLength)
229 return *this; 230 return *this;
230 231
231 j = 0; 232 j = 0;
232 k = 0; 233 k = 0;
233 while (i < strLength && j < 4) { 234 while (i < strLength && j < 4) {
234 ch = dtStr[i]; 235 ch = dtStr[i];
235 k = k * 10 + ch - '0'; 236 k = k * 10 + FXSYS_toDecimalDigit(ch);
236 j++; 237 j++;
237 if (ch < '0' || ch > '9') 238 if (!std::isdigit(ch))
238 break; 239 break;
239 i++; 240 i++;
240 } 241 }
241 dt.year = (int16_t)k; 242 dt.year = (int16_t)k;
242 if (i >= strLength || j < 4) 243 if (i >= strLength || j < 4)
243 return *this; 244 return *this;
244 245
245 j = 0; 246 j = 0;
246 k = 0; 247 k = 0;
247 while (i < strLength && j < 2) { 248 while (i < strLength && j < 2) {
248 ch = dtStr[i]; 249 ch = dtStr[i];
249 k = k * 10 + ch - '0'; 250 k = k * 10 + FXSYS_toDecimalDigit(ch);
250 j++; 251 j++;
251 if (ch < '0' || ch > '9') 252 if (!std::isdigit(ch))
252 break; 253 break;
253 i++; 254 i++;
254 } 255 }
255 dt.month = (uint8_t)k; 256 dt.month = (uint8_t)k;
256 if (i >= strLength || j < 2) 257 if (i >= strLength || j < 2)
257 return *this; 258 return *this;
258 259
259 j = 0; 260 j = 0;
260 k = 0; 261 k = 0;
261 while (i < strLength && j < 2) { 262 while (i < strLength && j < 2) {
262 ch = dtStr[i]; 263 ch = dtStr[i];
263 k = k * 10 + ch - '0'; 264 k = k * 10 + FXSYS_toDecimalDigit(ch);
264 j++; 265 j++;
265 if (ch < '0' || ch > '9') 266 if (!std::isdigit(ch))
266 break; 267 break;
267 i++; 268 i++;
268 } 269 }
269 dt.day = (uint8_t)k; 270 dt.day = (uint8_t)k;
270 if (i >= strLength || j < 2) 271 if (i >= strLength || j < 2)
271 return *this; 272 return *this;
272 273
273 j = 0; 274 j = 0;
274 k = 0; 275 k = 0;
275 while (i < strLength && j < 2) { 276 while (i < strLength && j < 2) {
276 ch = dtStr[i]; 277 ch = dtStr[i];
277 k = k * 10 + ch - '0'; 278 k = k * 10 + FXSYS_toDecimalDigit(ch);
278 j++; 279 j++;
279 if (ch < '0' || ch > '9') 280 if (!std::isdigit(ch))
280 break; 281 break;
281 i++; 282 i++;
282 } 283 }
283 dt.hour = (uint8_t)k; 284 dt.hour = (uint8_t)k;
284 if (i >= strLength || j < 2) 285 if (i >= strLength || j < 2)
285 return *this; 286 return *this;
286 287
287 j = 0; 288 j = 0;
288 k = 0; 289 k = 0;
289 while (i < strLength && j < 2) { 290 while (i < strLength && j < 2) {
290 ch = dtStr[i]; 291 ch = dtStr[i];
291 k = k * 10 + ch - '0'; 292 k = k * 10 + FXSYS_toDecimalDigit(ch);
292 j++; 293 j++;
293 if (ch < '0' || ch > '9') 294 if (!std::isdigit(ch))
294 break; 295 break;
295 i++; 296 i++;
296 } 297 }
297 dt.minute = (uint8_t)k; 298 dt.minute = (uint8_t)k;
298 if (i >= strLength || j < 2) 299 if (i >= strLength || j < 2)
299 return *this; 300 return *this;
300 301
301 j = 0; 302 j = 0;
302 k = 0; 303 k = 0;
303 while (i < strLength && j < 2) { 304 while (i < strLength && j < 2) {
304 ch = dtStr[i]; 305 ch = dtStr[i];
305 k = k * 10 + ch - '0'; 306 k = k * 10 + FXSYS_toDecimalDigit(ch);
306 j++; 307 j++;
307 if (ch < '0' || ch > '9') 308 if (!std::isdigit(ch))
308 break; 309 break;
309 i++; 310 i++;
310 } 311 }
311 dt.second = (uint8_t)k; 312 dt.second = (uint8_t)k;
312 if (i >= strLength || j < 2) 313 if (i >= strLength || j < 2)
313 return *this; 314 return *this;
314 315
315 ch = dtStr[i++]; 316 ch = dtStr[i++];
316 if (ch != '-' && ch != '+') 317 if (ch != '-' && ch != '+')
317 return *this; 318 return *this;
318 if (ch == '-') 319 if (ch == '-')
319 dt.tzHour = -1; 320 dt.tzHour = -1;
320 else 321 else
321 dt.tzHour = 1; 322 dt.tzHour = 1;
322 j = 0; 323 j = 0;
323 k = 0; 324 k = 0;
324 while (i < strLength && j < 2) { 325 while (i < strLength && j < 2) {
325 ch = dtStr[i]; 326 ch = dtStr[i];
326 k = k * 10 + ch - '0'; 327 k = k * 10 + FXSYS_toDecimalDigit(ch);
327 j++; 328 j++;
328 if (ch < '0' || ch > '9') 329 if (!std::isdigit(ch))
329 break; 330 break;
330 i++; 331 i++;
331 } 332 }
332 dt.tzHour *= (FX_CHAR)k; 333 dt.tzHour *= (FX_CHAR)k;
333 if (i >= strLength || j < 2) 334 if (i >= strLength || j < 2)
334 return *this; 335 return *this;
335 336
336 ch = dtStr[i++]; 337 ch = dtStr[i++];
337 if (ch != '\'') 338 if (ch != '\'')
338 return *this; 339 return *this;
339 j = 0; 340 j = 0;
340 k = 0; 341 k = 0;
341 while (i < strLength && j < 2) { 342 while (i < strLength && j < 2) {
342 ch = dtStr[i]; 343 ch = dtStr[i];
343 k = k * 10 + ch - '0'; 344 k = k * 10 + FXSYS_toDecimalDigit(ch);
344 j++; 345 j++;
345 if (ch < '0' || ch > '9') 346 if (!std::isdigit(ch))
346 break; 347 break;
347 i++; 348 i++;
348 } 349 }
349 dt.tzMinute = (uint8_t)k; 350 dt.tzMinute = (uint8_t)k;
350 if (i >= strLength || j < 2) 351 if (i >= strLength || j < 2)
351 return *this; 352 return *this;
352 } 353 }
353 354
354 return *this; 355 return *this;
355 } 356 }
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 CPDF_Annot::Normal, NULL); 998 CPDF_Annot::Normal, NULL);
998 999
999 return; 1000 return;
1000 } 1001 }
1001 1002
1002 CPDF_Page* CPDFSDK_Annot::GetPDFPage() { 1003 CPDF_Page* CPDFSDK_Annot::GetPDFPage() {
1003 if (m_pPageView) 1004 if (m_pPageView)
1004 return m_pPageView->GetPDFPage(); 1005 return m_pPageView->GetPDFPage();
1005 return NULL; 1006 return NULL;
1006 } 1007 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698