| OLD | NEW |
| 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 <stddef.h> // For offsetof(). | 7 #include <stddef.h> // For offsetof(). |
| 8 #include <cctype> |
| 8 | 9 |
| 9 #include "../../include/fxcrt/fx_basic.h" | 10 #include "../../include/fxcrt/fx_basic.h" |
| 10 #include "../../../third_party/base/numerics/safe_math.h" | 11 #include "../../../third_party/base/numerics/safe_math.h" |
| 11 | 12 |
| 12 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) { | 13 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) { |
| 13 if (i == 0) { | 14 if (i == 0) { |
| 14 buf[0] = '0'; | 15 buf[0] = '0'; |
| 15 return 1; | 16 return 1; |
| 16 } | 17 } |
| 17 char buf1[32]; | 18 char buf1[32]; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } else if (*lpsz == '*') { | 487 } else if (*lpsz == '*') { |
| 487 nWidth = va_arg(argList, int); | 488 nWidth = va_arg(argList, int); |
| 488 } else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' || *lpsz == ' ') | 489 } else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' || *lpsz == ' ') |
| 489 ; | 490 ; |
| 490 else { | 491 else { |
| 491 break; | 492 break; |
| 492 } | 493 } |
| 493 } | 494 } |
| 494 if (nWidth == 0) { | 495 if (nWidth == 0) { |
| 495 nWidth = FXSYS_atoi(lpsz); | 496 nWidth = FXSYS_atoi(lpsz); |
| 496 for (; (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++) | 497 while (std::isdigit(*lpsz)) |
| 497 ; | 498 lpsz++; |
| 498 } | 499 } |
| 499 if (nWidth < 0 || nWidth > 128 * 1024) { | 500 if (nWidth < 0 || nWidth > 128 * 1024) { |
| 500 lpszFormat = "Bad width"; | 501 lpszFormat = "Bad width"; |
| 501 nMaxLen = 10; | 502 nMaxLen = 10; |
| 502 break; | 503 break; |
| 503 } | 504 } |
| 504 int nPrecision = 0; | 505 int nPrecision = 0; |
| 505 if (*lpsz == '.') { | 506 if (*lpsz == '.') { |
| 506 lpsz++; | 507 lpsz++; |
| 507 if (*lpsz == '*') { | 508 if (*lpsz == '*') { |
| 508 nPrecision = va_arg(argList, int); | 509 nPrecision = va_arg(argList, int); |
| 509 lpsz++; | 510 lpsz++; |
| 510 } else { | 511 } else { |
| 511 nPrecision = FXSYS_atoi(lpsz); | 512 nPrecision = FXSYS_atoi(lpsz); |
| 512 for (; (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++) | 513 while (std::isdigit(*lpsz)) |
| 513 ; | 514 lpsz++; |
| 514 } | 515 } |
| 515 } | 516 } |
| 516 if (nPrecision < 0 || nPrecision > 128 * 1024) { | 517 if (nPrecision < 0 || nPrecision > 128 * 1024) { |
| 517 lpszFormat = "Bad precision"; | 518 lpszFormat = "Bad precision"; |
| 518 nMaxLen = 14; | 519 nMaxLen = 14; |
| 519 break; | 520 break; |
| 520 } | 521 } |
| 521 int nModifier = 0; | 522 int nModifier = 0; |
| 522 if (FXSYS_strncmp(lpsz, "I64", 3) == 0) { | 523 if (FXSYS_strncmp(lpsz, "I64", 3) == 0) { |
| 523 lpsz += 3; | 524 lpsz += 3; |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 fraction %= scale; | 1087 fraction %= scale; |
| 1087 scale /= 10; | 1088 scale /= 10; |
| 1088 } | 1089 } |
| 1089 return buf_size; | 1090 return buf_size; |
| 1090 } | 1091 } |
| 1091 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { | 1092 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { |
| 1092 FX_CHAR buf[32]; | 1093 FX_CHAR buf[32]; |
| 1093 FX_STRSIZE len = FX_ftoa(d, buf); | 1094 FX_STRSIZE len = FX_ftoa(d, buf); |
| 1094 return CFX_ByteString(buf, len); | 1095 return CFX_ByteString(buf, len); |
| 1095 } | 1096 } |
| OLD | NEW |