| 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 | 13 // static |
| 13 CFX_WideString::StringData* CFX_WideString::StringData::Create(int nLen) { | 14 CFX_WideString::StringData* CFX_WideString::StringData::Create(int nLen) { |
| 14 // TODO(palmer): |nLen| should really be declared as |size_t|, or | 15 // TODO(palmer): |nLen| should really be declared as |size_t|, or |
| 15 // at least unsigned. | 16 // at least unsigned. |
| 16 if (nLen == 0 || nLen < 0) { | 17 if (nLen == 0 || nLen < 0) { |
| 17 return NULL; | 18 return NULL; |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 } else if (*lpsz == '*') { | 759 } else if (*lpsz == '*') { |
| 759 nWidth = va_arg(argList, int); | 760 nWidth = va_arg(argList, int); |
| 760 } else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' || *lpsz == ' ') | 761 } else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' || *lpsz == ' ') |
| 761 ; | 762 ; |
| 762 else { | 763 else { |
| 763 break; | 764 break; |
| 764 } | 765 } |
| 765 } | 766 } |
| 766 if (nWidth == 0) { | 767 if (nWidth == 0) { |
| 767 nWidth = FXSYS_wtoi(lpsz); | 768 nWidth = FXSYS_wtoi(lpsz); |
| 768 for (; *lpsz != 0 && (*lpsz) <= '9' && (*lpsz) >= '0'; lpsz++) | 769 for (; *lpsz != 0 && std::isdigit(*lpsz); lpsz++) |
| 769 ; | 770 ; |
| 770 } | 771 } |
| 771 if (nWidth < 0 || nWidth > 128 * 1024) { | 772 if (nWidth < 0 || nWidth > 128 * 1024) { |
| 772 lpszFormat = L"Bad width"; | 773 lpszFormat = L"Bad width"; |
| 773 nMaxLen = 10; | 774 nMaxLen = 10; |
| 774 break; | 775 break; |
| 775 } | 776 } |
| 776 int nPrecision = 0; | 777 int nPrecision = 0; |
| 777 if (*lpsz == '.') { | 778 if (*lpsz == '.') { |
| 778 lpsz++; | 779 lpsz++; |
| 779 if (*lpsz == '*') { | 780 if (*lpsz == '*') { |
| 780 nPrecision = va_arg(argList, int); | 781 nPrecision = va_arg(argList, int); |
| 781 lpsz++; | 782 lpsz++; |
| 782 } else { | 783 } else { |
| 783 nPrecision = FXSYS_wtoi(lpsz); | 784 nPrecision = FXSYS_wtoi(lpsz); |
| 784 for (; *lpsz != 0 && (*lpsz) >= '0' && (*lpsz) <= '9'; lpsz++) | 785 for (; *lpsz != 0 && std::isdigit(*lpsz); lpsz++) |
| 785 ; | 786 ; |
| 786 } | 787 } |
| 787 } | 788 } |
| 788 if (nPrecision < 0 || nPrecision > 128 * 1024) { | 789 if (nPrecision < 0 || nPrecision > 128 * 1024) { |
| 789 lpszFormat = L"Bad precision"; | 790 lpszFormat = L"Bad precision"; |
| 790 nMaxLen = 14; | 791 nMaxLen = 14; |
| 791 break; | 792 break; |
| 792 } | 793 } |
| 793 int nModifier = 0; | 794 int nModifier = 0; |
| 794 if (*lpsz == L'I' && *(lpsz + 1) == L'6' && *(lpsz + 2) == L'4') { | 795 if (*lpsz == L'I' && *(lpsz + 1) == L'6' && *(lpsz + 2) == L'4') { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 return (CFX_CharMap*)&g_DefaultJISMapper; | 1058 return (CFX_CharMap*)&g_DefaultJISMapper; |
| 1058 case 936: | 1059 case 936: |
| 1059 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1060 return (CFX_CharMap*)&g_DefaultGBKMapper; |
| 1060 case 949: | 1061 case 949: |
| 1061 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1062 return (CFX_CharMap*)&g_DefaultUHCMapper; |
| 1062 case 950: | 1063 case 950: |
| 1063 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1064 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
| 1064 } | 1065 } |
| 1065 return NULL; | 1066 return NULL; |
| 1066 } | 1067 } |
| OLD | NEW |