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 "xfa/fgas/crt/fgas_system.h" | 7 #include "xfa/fgas/crt/fgas_system.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 inline FX_BOOL FX_isupper(int32_t ch) { | 15 inline FX_BOOL FX_isupper(int32_t ch) { |
16 return ch >= 'A' && ch <= 'Z'; | 16 return ch >= 'A' && ch <= 'Z'; |
17 } | 17 } |
18 | 18 |
19 inline int32_t FX_tolower(int32_t ch) { | 19 inline int32_t FX_tolower(int32_t ch) { |
20 return FX_isupper(ch) ? (ch + 0x20) : ch; | 20 return FX_isupper(ch) ? (ch + 0x20) : ch; |
21 } | 21 } |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { | 25 int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { |
26 ASSERT(s1 != NULL && s2 != NULL && count > 0); | 26 ASSERT(s1 && s2 && count > 0); |
27 FX_WCHAR wch1 = 0; | 27 FX_WCHAR wch1 = 0; |
28 FX_WCHAR wch2 = 0; | 28 FX_WCHAR wch2 = 0; |
29 while (count-- > 0) { | 29 while (count-- > 0) { |
30 wch1 = (FX_WCHAR)FX_tolower(*s1++); | 30 wch1 = (FX_WCHAR)FX_tolower(*s1++); |
31 wch2 = (FX_WCHAR)FX_tolower(*s2++); | 31 wch2 = (FX_WCHAR)FX_tolower(*s2++); |
32 if (wch1 != wch2) { | 32 if (wch1 != wch2) { |
33 break; | 33 break; |
34 } | 34 } |
35 } | 35 } |
36 return wch1 - wch2; | 36 return wch1 - wch2; |
37 } | 37 } |
38 | 38 |
39 FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) { | 39 FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) { |
40 ASSERT(pwsStr != NULL); | 40 ASSERT(pwsStr); |
41 if (iLength < 0) { | 41 if (iLength < 0) { |
42 iLength = FXSYS_wcslen(pwsStr); | 42 iLength = FXSYS_wcslen(pwsStr); |
43 } | 43 } |
44 if (iLength == 0) { | 44 if (iLength == 0) { |
45 return 0.0f; | 45 return 0.0f; |
46 } | 46 } |
47 int32_t iUsedLen = 0; | 47 int32_t iUsedLen = 0; |
48 FX_BOOL bNegtive = FALSE; | 48 FX_BOOL bNegtive = FALSE; |
49 switch (pwsStr[iUsedLen]) { | 49 switch (pwsStr[iUsedLen]) { |
50 case '-': | 50 case '-': |
(...skipping 22 matching lines...) Expand all Loading... |
73 } else { | 73 } else { |
74 break; | 74 break; |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 if (pUsedLen) { | 78 if (pUsedLen) { |
79 *pUsedLen = iUsedLen; | 79 *pUsedLen = iUsedLen; |
80 } | 80 } |
81 return bNegtive ? -fValue : fValue; | 81 return bNegtive ? -fValue : fValue; |
82 } | 82 } |
OLD | NEW |