From 72c6b181862ada8adf485ab8015120df32d9f600 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 3 Apr 2017 13:39:26 -0400 Subject: Minor cleanups Cleanup some unused methods, add some missing #ifdef comments. Bug: pdfium:694 Change-Id: I019a03f7a55d1d4a23300ff822ae30dde4406c3d Reviewed-on: https://pdfium-review.googlesource.com/3596 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/fx_ext.h | 8 +++++++- core/fxcrt/fx_system.h | 38 ++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h index e605d04077..2eafe6c7b9 100644 --- a/core/fxcrt/fx_ext.h +++ b/core/fxcrt/fx_ext.h @@ -16,7 +16,6 @@ #define FX_INVALID_OFFSET static_cast(-1) float FXSYS_tan(float a); -float FXSYS_logb(float b, float x); float FXSYS_strtof(const char* pcsStr, int32_t iLength = -1, int32_t* pUsedLen = nullptr); @@ -30,24 +29,31 @@ int32_t FXSYS_strnicmp(const char* s1, const char* s2, size_t count); inline bool FXSYS_islower(int32_t ch) { return ch >= 'a' && ch <= 'z'; } + inline bool FXSYS_isupper(int32_t ch) { return ch >= 'A' && ch <= 'Z'; } + inline int32_t FXSYS_tolower(int32_t ch) { return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20); } + inline int32_t FXSYS_toupper(int32_t ch) { return ch < 'a' || ch > 'z' ? ch : (ch - 0x20); } + inline bool FXSYS_iswalpha(wchar_t wch) { return (wch >= L'A' && wch <= L'Z') || (wch >= L'a' && wch <= L'z'); } + inline bool FXSYS_iswdigit(wchar_t wch) { return wch >= L'0' && wch <= L'9'; } + inline bool FXSYS_iswalnum(wchar_t wch) { return FXSYS_iswalpha(wch) || FXSYS_iswdigit(wch); } + inline bool FXSYS_iswspace(wchar_t c) { return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09); } diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h index 89042daf71..38191539dc 100644 --- a/core/fxcrt/fx_system.h +++ b/core/fxcrt/fx_system.h @@ -56,12 +56,12 @@ #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #include #include -#endif +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ #include #include -#endif +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ #ifdef __cplusplus extern "C" { @@ -92,14 +92,14 @@ typedef int FX_STRSIZE; #define ASSERT assert #else #define ASSERT(a) -#endif -#endif +#endif // NDEBUG +#endif // ASSERT #if defined(__clang__) || defined(__GNUC__) #define PDFIUM_IMMEDIATE_CRASH() __builtin_trap() #else #define PDFIUM_IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0)) -#endif +#endif // defined(__clang__) || defined(__GNUC__) // M_PI not universally present on all platforms. #define FX_PI 3.1415926535897932384626433832795f @@ -117,7 +117,7 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); #else #define FXSYS_snprintf (void)snprintf #define FXSYS_vsnprintf (void)vsnprintf -#endif +#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE @@ -143,7 +143,7 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m)) #else #define FXSYS_wfopen _wfopen -#endif +#endif // _NATIVE_WCHAR_T_DEFINED #else FXSYS_FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode); #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ @@ -185,7 +185,7 @@ extern "C" { #else #define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr)) #define FXSYS_wcslen(ptr) ((FX_STRSIZE)wcslen(ptr)) -#endif +#endif // __cplusplus #define FXSYS_wcscmp wcscmp #define FXSYS_wcsstr wcsstr @@ -206,6 +206,10 @@ extern "C" { #define FXSYS_strlwr _strlwr #define FXSYS_strupr _strupr #define FXSYS_stricmp _stricmp +#define FXSYS_pow(a, b) (float)powf(a, b) +#define FXSYS_GetFullPathName GetFullPathName +#define FXSYS_GetModuleFileName GetModuleFileName + #ifdef _NATIVE_WCHAR_T_DEFINED #define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2)) #define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) \ @@ -220,9 +224,7 @@ extern "C" { #define FXSYS_MultiByteToWideChar MultiByteToWideChar #define FXSYS_wcslwr _wcslwr #define FXSYS_wcsupr _wcsupr -#endif -#define FXSYS_GetFullPathName GetFullPathName -#define FXSYS_GetModuleFileName GetModuleFileName +#endif // _NATIVE_WCHAR_T_DEFINED #else int FXSYS_GetACP(); char* FXSYS_itoa(int value, char* str, int radix); @@ -251,13 +253,9 @@ int FXSYS_stricmp(const char*, const char*); int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2); wchar_t* FXSYS_wcslwr(wchar_t* str); wchar_t* FXSYS_wcsupr(wchar_t* str); +#define FXSYS_pow(a, b) (float)pow(a, b) #endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -#define FXSYS_pow(a, b) (float)powf(a, b) -#else -#define FXSYS_pow(a, b) (float)pow(a, b) -#endif #define FXSYS_sqrt(a) (float)sqrt(a) #define FXSYS_fabs(a) (float)fabs(a) #define FXSYS_atan2(a, b) (float)atan2(a, b) @@ -276,10 +274,6 @@ wchar_t* FXSYS_wcsupr(wchar_t* str); #define FXDWORD_GET_MSBFIRST(p) \ ((static_cast(p[0]) << 24) | (static_cast(p[1]) << 16) | \ (static_cast(p[2]) << 8) | (static_cast(p[3]))) -#define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8)) -#define FXSYS_LOBYTE(word) ((uint8_t)(word)) -#define FXSYS_HIWORD(dword) ((uint16_t)((dword) >> 16)) -#define FXSYS_LOWORD(dword) ((uint16_t)(dword)) int32_t FXSYS_atoi(const char* str); uint32_t FXSYS_atoui(const char* str); int32_t FXSYS_wtoi(const wchar_t* str); @@ -289,8 +283,8 @@ const char* FXSYS_i64toa(int64_t value, char* str, int radix); int FXSYS_round(float f); #define FXSYS_sqrt2(a, b) (float)FXSYS_sqrt((a) * (a) + (b) * (b)) #ifdef __cplusplus -}; -#endif +}; // extern C +#endif // __cplusplus // To print a size_t value in a portable way: // size_t size; -- cgit v1.2.3