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

Side by Side Diff: xfa/fgas/crt/fgas_system.cpp

Issue 1992033002: fgas/ code cleanup. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 7 months 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 "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 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \
14 _FX_OS_ == _FX_WIN64_
15 #include <io.h>
16 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_Mini_
17 #include <sys/times.h>
18 #endif
19
20 namespace { 13 namespace {
21 14
22 inline FX_BOOL FX_isupper(int32_t ch) { 15 inline FX_BOOL FX_isupper(int32_t ch) {
23 return ch >= 'A' && ch <= 'Z'; 16 return ch >= 'A' && ch <= 'Z';
24 } 17 }
25 18
26 inline int32_t FX_tolower(int32_t ch) { 19 inline int32_t FX_tolower(int32_t ch) {
27 return FX_isupper(ch) ? (ch + 0x20) : ch; 20 return FX_isupper(ch) ? (ch + 0x20) : ch;
28 } 21 }
29 22
30 } // namespace 23 } // namespace
31 24
32 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) {
33 ASSERT(s1 != NULL && s2 != NULL && count > 0); 26 ASSERT(s1 != NULL && s2 != NULL && count > 0);
34 FX_WCHAR wch1 = 0; 27 FX_WCHAR wch1 = 0;
35 FX_WCHAR wch2 = 0; 28 FX_WCHAR wch2 = 0;
36 while (count-- > 0) { 29 while (count-- > 0) {
37 wch1 = (FX_WCHAR)FX_tolower(*s1++); 30 wch1 = (FX_WCHAR)FX_tolower(*s1++);
38 wch2 = (FX_WCHAR)FX_tolower(*s2++); 31 wch2 = (FX_WCHAR)FX_tolower(*s2++);
39 if (wch1 != wch2) { 32 if (wch1 != wch2) {
40 break; 33 break;
41 } 34 }
42 } 35 }
43 return wch1 - wch2; 36 return wch1 - wch2;
44 } 37 }
45 38
46 int32_t FX_filelength(FXSYS_FILE* file) {
47 ASSERT(file != NULL);
48 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
49 return _filelength(_fileno(file));
50 #else
51 int32_t iPos = FXSYS_ftell(file);
52 FXSYS_fseek(file, 0, FXSYS_SEEK_END);
53 int32_t iLen = FXSYS_ftell(file);
54 FXSYS_fseek(file, iPos, FXSYS_SEEK_SET);
55 return iLen;
56 #endif
57 }
58
59 FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size) {
60 ASSERT(file != NULL);
61 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
62 return _chsize(_fileno(file), size) == 0;
63 #elif _FX_OS_ == _FX_WIN32_MOBILE_
64 HANDLE hFile = _fileno(file);
65 uint32_t dwPos = ::SetFilePointer(hFile, 0, 0, FILE_CURRENT);
66 ::SetFilePointer(hFile, size, 0, FILE_BEGIN);
67 FX_BOOL bRet = ::SetEndOfFile(hFile);
68 ::SetFilePointer(hFile, (int32_t)dwPos, 0, FILE_BEGIN);
69 return bRet;
70 #else
71 return FALSE;
72 #endif
73 }
74
75 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) {
76 ASSERT(pwsStr != NULL); 40 ASSERT(pwsStr != NULL);
77 if (iLength < 0) { 41 if (iLength < 0) {
78 iLength = FXSYS_wcslen(pwsStr); 42 iLength = FXSYS_wcslen(pwsStr);
79 } 43 }
80 if (iLength == 0) { 44 if (iLength == 0) {
81 return 0.0f; 45 return 0.0f;
82 } 46 }
83 int32_t iUsedLen = 0; 47 int32_t iUsedLen = 0;
84 FX_BOOL bNegtive = FALSE; 48 FX_BOOL bNegtive = FALSE;
(...skipping 24 matching lines...) Expand all
109 } else { 73 } else {
110 break; 74 break;
111 } 75 }
112 } 76 }
113 } 77 }
114 if (pUsedLen) { 78 if (pUsedLen) {
115 *pUsedLen = iUsedLen; 79 *pUsedLen = iUsedLen;
116 } 80 }
117 return bNegtive ? -fValue : fValue; 81 return bNegtive ? -fValue : fValue;
118 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698