7#include "core/fxcrt/fx_extension.h"
12#include "core/fxcrt/fx_system.h"
13#include "core/fxcrt/utf16.h"
14#include "third_party/base/check.h"
18time_t DefaultTimeFunction() {
22struct tm* DefaultLocaltimeFunction(
const time_t* tp) {
26time_t (*g_time_func)() = DefaultTimeFunction;
27struct tm* (*g_localtime_func)(
const time_t*) = DefaultLocaltimeFunction;
31float FXSYS_wcstof(
const wchar_t* pwsStr, size_t nLength, size_t* pUsedLen) {
37 bool bNegtive =
false;
38 switch (pwsStr[nUsedLen]) {
48 while (nUsedLen < nLength) {
49 wchar_t wch = pwsStr[nUsedLen];
53 fValue = fValue * 10.0f + (wch - L'0');
57 if (nUsedLen < nLength && pwsStr[nUsedLen] == L'.') {
58 float fPrecise = 0.1f;
59 while (++nUsedLen < nLength) {
60 wchar_t wch = pwsStr[nUsedLen];
64 fValue += (wch - L'0') * fPrecise;
69 if (nUsedLen < nLength &&
70 (pwsStr[nUsedLen] ==
'e' || pwsStr[nUsedLen] ==
'E')) {
73 bool negative_exponent =
false;
74 if (nUsedLen < nLength &&
75 (pwsStr[nUsedLen] ==
'-' || pwsStr[nUsedLen] ==
'+')) {
76 negative_exponent = pwsStr[nUsedLen] ==
'-';
80 int32_t exp_value = 0;
81 while (nUsedLen < nLength) {
82 wchar_t wch = pwsStr[nUsedLen];
86 exp_value = exp_value * 10.0f + (wch - L'0');
88 if ((negative_exponent &&
89 -exp_value <
std::numeric_limits<
float>::min_exponent10) ||
90 (!negative_exponent &&
91 exp_value >
std::numeric_limits<
float>::max_exponent10)) {
100 for (size_t i = exp_value; i > 0; --i) {
102 if (negative_exponent)
111 *pUsedLen = nUsedLen;
113 return bNegtive ? -fValue : fValue;
116wchar_t*
FXSYS_wcsncpy(
wchar_t* dstStr,
const wchar_t* srcStr, size_t count) {
121 for (size_t i = 0; i < count; ++i)
122 if ((dstStr[i] = srcStr[i]) == L'\0')
132 while (count-- > 0) {
136 return wch1 > wch2 ? 1 : -1;
143 static const char kHex[] =
"0123456789ABCDEF";
144 buf[0] = kHex[n / 16];
145 buf[1] = kHex[n % 16];
154 DCHECK(unicode <= pdfium::kMaximumSupplementaryCodePoint);
155 DCHECK(!pdfium::IsHighSurrogate(unicode));
156 DCHECK(!pdfium::IsLowSurrogate(unicode));
158 if (unicode <= 0xFFFF) {
162 pdfium::SurrogatePair surrogate_pair
(unicode
);
169 g_time_func = func ? func : DefaultTimeFunction;
173 g_localtime_func = func ? func : DefaultLocaltimeFunction;
177 time_t ret_val = g_time_func();
184 return g_localtime_func(tp);
constexpr SurrogatePair(char32_t code_point)
constexpr char16_t high() const
constexpr char16_t low() const
time_t FXSYS_time(time_t *tloc)
void FXSYS_IntToTwoHexChars(uint8_t n, char *buf)
void FXSYS_SetTimeFunction(time_t(*func)())
bool FXSYS_IsDecimalDigit(wchar_t c)
size_t FXSYS_ToUTF16BE(uint32_t unicode, char *buf)
int32_t FXSYS_wcsnicmp(const wchar_t *s1, const wchar_t *s2, size_t count)
void FXSYS_IntToFourHexChars(uint16_t n, char *buf)
struct tm * FXSYS_localtime(const time_t *tp)
float FXSYS_wcstof(const wchar_t *pwsStr, size_t nLength, size_t *pUsedLen)
int32_t FXSYS_towlower(wchar_t c)
wchar_t * FXSYS_wcsncpy(wchar_t *dstStr, const wchar_t *srcStr, size_t count)
void FXSYS_SetLocaltimeFunction(struct tm *(*func)(const time_t *))