Cleanup fx_basic_* files

Remove dead code, move code to namespaces where possible, cleanup some
single use items.

Change-Id: Ia734477ceb2105a1ed272463bd8220f1205a7ce9
Reviewed-on: https://pdfium-review.googlesource.com/12732
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp
index 87c2533..12ac399 100644
--- a/core/fxcrt/fx_basic_gcc.cpp
+++ b/core/fxcrt/fx_basic_gcc.cpp
@@ -11,6 +11,8 @@
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_string.h"
 
+namespace {
+
 template <typename IntType, typename CharType>
 IntType FXSYS_StrToInt(const CharType* str) {
   if (!str)
@@ -79,9 +81,8 @@
   return str;
 }
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+}  // namespace
+
 int32_t FXSYS_atoi(const char* str) {
   return FXSYS_StrToInt<int32_t, char>(str);
 }
@@ -94,47 +95,16 @@
 int64_t FXSYS_atoi64(const char* str) {
   return FXSYS_StrToInt<int64_t, char>(str);
 }
-int64_t FXSYS_wtoi64(const wchar_t* str) {
-  return FXSYS_StrToInt<int64_t, wchar_t>(str);
-}
 const char* FXSYS_i64toa(int64_t value, char* str, int radix) {
   return FXSYS_IntToStr<int64_t, uint64_t, char*>(value, str, radix);
 }
-#ifdef __cplusplus
-}
-#endif
+
 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
-#ifdef __cplusplus
-extern "C" {
-#endif
+
 int FXSYS_GetACP() {
   return 0;
 }
 
-uint32_t FXSYS_GetFullPathName(const char* filename,
-                               uint32_t buflen,
-                               char* buf,
-                               char** filepart) {
-  int srclen = FXSYS_strlen(filename);
-  if (!buf || (int)buflen < srclen + 1)
-    return srclen + 1;
-
-  strncpy(buf, filename, buflen);
-  return srclen;
-}
-
-uint32_t FXSYS_GetModuleFileName(void* hModule, char* buf, uint32_t bufsize) {
-  return 0xFFFFFFFF;
-}
-
-#ifdef __cplusplus
-}
-#endif
-#endif
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
-#ifdef __cplusplus
-extern "C" {
-#endif
 char* FXSYS_strlwr(char* str) {
   if (!str) {
     return nullptr;
@@ -207,14 +177,7 @@
 char* FXSYS_itoa(int value, char* str, int radix) {
   return FXSYS_IntToStr<int32_t, uint32_t, char*>(value, str, radix);
 }
-#ifdef __cplusplus
-}
-#endif
-#endif
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
-#ifdef __cplusplus
-extern "C" {
-#endif
+
 int FXSYS_WideCharToMultiByte(uint32_t codepage,
                               uint32_t dwFlags,
                               const wchar_t* wstr,
@@ -248,7 +211,5 @@
   }
   return wlen;
 }
-#ifdef __cplusplus
-}
-#endif
-#endif
+
+#endif  // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
diff --git a/core/fxcrt/fx_basic_gcc_unittest.cpp b/core/fxcrt/fx_basic_gcc_unittest.cpp
index 665eede..2960ee5 100644
--- a/core/fxcrt/fx_basic_gcc_unittest.cpp
+++ b/core/fxcrt/fx_basic_gcc_unittest.cpp
@@ -60,7 +60,6 @@
   EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483647"));
   // The min value.
   EXPECT_EQ(-2147483647 - 1, FXSYS_wtoi(L"-2147483648"));
-  EXPECT_EQ(9, FXSYS_wtoi64(L"9x9"));
 
   // Out of range values.
   EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483623423412348"));
@@ -68,31 +67,6 @@
   EXPECT_EQ(-2147483647 - 1, FXSYS_wtoi(L"-2147483652"));
 }
 
-TEST(fxcrt, FXSYS_wtoi64) {
-  EXPECT_EQ(0, FXSYS_wtoi64(L""));
-  EXPECT_EQ(0, FXSYS_wtoi64(L"0"));
-  EXPECT_EQ(-1, FXSYS_wtoi64(L"-1"));
-  EXPECT_EQ(2345, FXSYS_wtoi64(L"2345"));
-  EXPECT_EQ(-9223372036854775807LL, FXSYS_wtoi64(L"-9223372036854775807"));
-  // Handle the sign.
-  EXPECT_EQ(-2345, FXSYS_wtoi64(L"-2345"));
-  EXPECT_EQ(2345, FXSYS_wtoi64(L"+2345"));
-  // The max value.
-  EXPECT_EQ(9223372036854775807LL, FXSYS_wtoi64(L"9223372036854775807"));
-  // The min value.
-  EXPECT_EQ(-9223372036854775807LL - 1LL,
-            FXSYS_wtoi64(L"-9223372036854775808"));
-  // With invalid char.
-  EXPECT_EQ(9, FXSYS_wtoi64(L"9x9"));
-
-  // Out of range values.
-  EXPECT_EQ(9223372036854775807LL,
-            FXSYS_wtoi64(L"922337203685471234123475807"));
-  EXPECT_EQ(9223372036854775807LL, FXSYS_wtoi64(L"9223372036854775808"));
-  EXPECT_EQ(-9223372036854775807LL - 1LL,
-            FXSYS_wtoi64(L"-9223372036854775810"));
-}
-
 TEST(fxcrt, FXSYS_atoui) {
   EXPECT_EQ(0u, FXSYS_atoui(""));
   EXPECT_EQ(0u, FXSYS_atoui("0"));
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 2a9ce05..d8cf087 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -11,8 +11,22 @@
 
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_stream.h"
+#include "core/fxcrt/fx_system.h"
 #include "third_party/base/ptr_util.h"
 
+namespace {
+
+const float fraction_scales[] = {0.1f,          0.01f,         0.001f,
+                                 0.0001f,       0.00001f,      0.000001f,
+                                 0.0000001f,    0.00000001f,   0.000000001f,
+                                 0.0000000001f, 0.00000000001f};
+
+float FractionalScale(size_t scale_factor, int value) {
+  return fraction_scales[scale_factor] * value;
+}
+
+}  // namespace
+
 bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
   if (strc.Contains('.')) {
     float* pFloat = static_cast<float*>(pData);
@@ -70,19 +84,6 @@
   return true;
 }
 
-static const float fraction_scales[] = {
-    0.1f,         0.01f,         0.001f,        0.0001f,
-    0.00001f,     0.000001f,     0.0000001f,    0.00000001f,
-    0.000000001f, 0.0000000001f, 0.00000000001f};
-
-int FXSYS_FractionalScaleCount() {
-  return FX_ArraySize(fraction_scales);
-}
-
-float FXSYS_FractionalScale(size_t scale_factor, int value) {
-  return fraction_scales[scale_factor] * value;
-}
-
 float FX_atof(const CFX_ByteStringC& strc) {
   if (strc.IsEmpty())
     return 0.0;
@@ -112,10 +113,9 @@
   if (cc < len && strc[cc] == '.') {
     cc++;
     while (cc < len) {
-      value +=
-          FXSYS_FractionalScale(scale, FXSYS_DecimalCharToInt(strc.CharAt(cc)));
+      value += FractionalScale(scale, FXSYS_DecimalCharToInt(strc.CharAt(cc)));
       scale++;
-      if (scale == FXSYS_FractionalScaleCount())
+      if (scale == FX_ArraySize(fraction_scales))
         break;
       cc++;
     }
@@ -181,14 +181,6 @@
 #endif
 }
 
-wchar_t FX_GetFolderSeparator() {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-  return '\\';
-#else
-  return '/';
-#endif
-}
-
 uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits) {
   ASSERT(0 < nbits && nbits <= 32);
   const uint8_t* dataPtr = &pData[bitpos / 8];
diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
index fbb86fe..bd20b39 100644
--- a/core/fxcrt/fx_extension.h
+++ b/core/fxcrt/fx_extension.h
@@ -86,9 +86,6 @@
 
 size_t FXSYS_ToUTF16BE(uint32_t unicode, char* buf);
 
-float FXSYS_FractionalScale(size_t scale_factor, int value);
-int FXSYS_FractionalScaleCount();
-
 void* FX_Random_MT_Start(uint32_t dwSeed);
 void FX_Random_MT_Close(void* pContext);
 uint32_t FX_Random_MT_Generate(void* pContext);
diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h
index 6228181..abf031d 100644
--- a/core/fxcrt/fx_stream.h
+++ b/core/fxcrt/fx_stream.h
@@ -33,7 +33,6 @@
                     CFX_ByteString* filename,
                     bool* bFolder);
 void FX_CloseFolder(FX_FileHandle* handle);
-wchar_t FX_GetFolderSeparator();
 
 #define FX_FILEMODE_Write 0
 #define FX_FILEMODE_ReadOnly 1
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index ad7e6bb..1f63e6d 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -162,8 +162,6 @@
 #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
 size_t FXSYS_wcsftime(wchar_t* strDest,
                       size_t maxsize,
                       const wchar_t* format,
@@ -183,7 +181,9 @@
 #define FXSYS_wcslwr _wcslwr
 #define FXSYS_wcsupr _wcsupr
 #endif  // _NATIVE_WCHAR_T_DEFINED
+
 #else   // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_
+
 int FXSYS_GetACP();
 char* FXSYS_itoa(int value, char* str, int radix);
 int FXSYS_WideCharToMultiByte(uint32_t codepage,
@@ -200,11 +200,6 @@
                               int blen,
                               wchar_t* buf,
                               int buflen);
-uint32_t FXSYS_GetFullPathName(const char* filename,
-                               uint32_t buflen,
-                               char* buf,
-                               char** filepart);
-uint32_t FXSYS_GetModuleFileName(void* hModule, char* buf, uint32_t bufsize);
 char* FXSYS_strlwr(char* str);
 char* FXSYS_strupr(char* str);
 int FXSYS_stricmp(const char*, const char*);
@@ -225,7 +220,6 @@
 uint32_t FXSYS_atoui(const char* str);
 int32_t FXSYS_wtoi(const wchar_t* str);
 int64_t FXSYS_atoi64(const char* str);
-int64_t FXSYS_wtoi64(const wchar_t* str);
 const char* FXSYS_i64toa(int64_t value, char* str, int radix);
 int FXSYS_round(float f);
 #define FXSYS_sqrt2(a, b) (float)sqrt((a) * (a) + (b) * (b))
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 36cf105..4b395c9 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -611,6 +611,8 @@
      {1 << 14, FX_CHARSET_Default},
      {1 << 15, FX_CHARSET_US}}};
 
+constexpr wchar_t kFolderSeparator = L'/';
+
 }  // namespace
 
 CFX_FontDescriptor::CFX_FontDescriptor()
@@ -640,7 +642,7 @@
   CFX_ByteString bsName;
   bool bFolder;
   CFX_ByteString bsFolderSeparator =
-      CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator()));
+      CFX_ByteString::FromUnicode(CFX_WideString(kFolderSeparator));
   while (true) {
     if (!FX_GetNextFile(pCurHandle, &bsName, &bFolder)) {
       FX_CloseFolder(pCurHandle);