Drop FXSYS_ from string methods

This Cl drops the FXSYS_ from string methods which are the same on
all platforms.

Bug: pdfium:694
Change-Id: I1698aafd84f40474997549ae91ce35603377e303
Reviewed-on: https://pdfium-review.googlesource.com/3597
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index a87370f..54e565b 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -130,7 +130,7 @@
       }
       if ((m_GlyphIndex[charcode] == 0 || m_GlyphIndex[charcode] == 0xffff) &&
           name) {
-        if (name[0] == '.' && FXSYS_strcmp(name, ".notdef") == 0) {
+        if (name[0] == '.' && strcmp(name, ".notdef") == 0) {
           m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 32);
         } else {
           m_GlyphIndex[charcode] =
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index 4c7b86a..a264a78 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -172,7 +172,7 @@
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
       CalcExtGID(charcode);
 #endif
-      if (m_GlyphIndex[charcode] == 0 && FXSYS_strcmp(name, ".notdef") == 0) {
+      if (m_GlyphIndex[charcode] == 0 && strcmp(name, ".notdef") == 0) {
         m_Encoding.m_Unicodes[charcode] = 0x20;
         m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 0x20);
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -240,8 +240,7 @@
           FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
       SetExtGID(name, charcode);
       if (m_GlyphIndex[charcode] == 0) {
-        if (FXSYS_strcmp(name, ".notdef") != 0 &&
-            FXSYS_strcmp(name, "space") != 0) {
+        if (strcmp(name, ".notdef") != 0 && strcmp(name, "space") != 0) {
           m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
               m_Font.GetFace(),
               bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode);
@@ -304,8 +303,7 @@
     m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
     m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name);
     if (m_GlyphIndex[charcode] == 0) {
-      if (FXSYS_strcmp(name, ".notdef") != 0 &&
-          FXSYS_strcmp(name, "space") != 0) {
+      if (strcmp(name, ".notdef") != 0 && strcmp(name, "space") != 0) {
         m_GlyphIndex[charcode] = FXFT_Get_Char_Index(
             m_Font.GetFace(),
             bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode);
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index fb2c723..975592d 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -966,7 +966,8 @@
   if (face.GetLength() >= LF_FACESIZE)
     return nullptr;
 
-  FXSYS_strcpy(lfa.lfFaceName, face.c_str());
+  strncpy(lfa.lfFaceName, face.c_str(),
+          (face.GetLength() + 1) * sizeof(CFX_ByteString::CharType));
   return AddWindowsFont(&lfa, bVert, bTranslateName);
 }
 
diff --git a/core/fxcodec/codec/ccodec_bmpmodule.cpp b/core/fxcodec/codec/ccodec_bmpmodule.cpp
index f237b14..d891a37 100644
--- a/core/fxcodec/codec/ccodec_bmpmodule.cpp
+++ b/core/fxcodec/codec/ccodec_bmpmodule.cpp
@@ -28,7 +28,7 @@
 };
 static void bmp_error_data(bmp_decompress_struct_p bmp_ptr,
                            const char* err_msg) {
-  FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1);
+  strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1);
   longjmp(bmp_ptr->jmpbuf, 1);
 }
 static void bmp_read_scanline(bmp_decompress_struct_p bmp_ptr,
diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp
index 91c64a0..b7352ba 100644
--- a/core/fxcodec/codec/ccodec_gifmodule.cpp
+++ b/core/fxcodec/codec/ccodec_gifmodule.cpp
@@ -30,7 +30,7 @@
 
 static void gif_error_data(gif_decompress_struct_p gif_ptr,
                            const char* err_msg) {
-  FXSYS_strncpy((char*)gif_ptr->err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1);
+  strncpy((char*)gif_ptr->err_ptr, err_msg, GIF_MAX_ERROR_SIZE - 1);
   longjmp(gif_ptr->jmpbuf, 1);
 }
 
diff --git a/core/fxcodec/codec/ccodec_pngmodule.cpp b/core/fxcodec/codec/ccodec_pngmodule.cpp
index 4bd4cfc..2b8f957 100644
--- a/core/fxcodec/codec/ccodec_pngmodule.cpp
+++ b/core/fxcodec/codec/ccodec_pngmodule.cpp
@@ -19,8 +19,7 @@
 
 static void _png_error_data(png_structp png_ptr, png_const_charp error_msg) {
   if (png_get_error_ptr(png_ptr)) {
-    FXSYS_strncpy((char*)png_get_error_ptr(png_ptr), error_msg,
-                  PNG_ERROR_SIZE - 1);
+    strncpy((char*)png_get_error_ptr(png_ptr), error_msg, PNG_ERROR_SIZE - 1);
   }
   longjmp(png_jmpbuf(png_ptr), 1);
 }
@@ -252,7 +251,7 @@
                              CFX_DIBAttribute* pAttribute) {
   if (setjmp(png_jmpbuf(ctx->png_ptr))) {
     if (pAttribute &&
-        0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) {
+        0 == strcmp(m_szLastError, "Read Header Callback Error")) {
       _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute);
     }
     return false;
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index c109b61..52cb81b 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -103,15 +103,15 @@
   while (i <= des_size && (avail_in > 0 || bits_left >= code_size_cur)) {
     if (code_size_cur > 12) {
       if (err_msg_ptr) {
-        FXSYS_strncpy(err_msg_ptr, "Code Length Out Of Range",
-                      GIF_MAX_ERROR_SIZE - 1);
+        strncpy(err_msg_ptr, "Code Length Out Of Range",
+                GIF_MAX_ERROR_SIZE - 1);
       }
       return 0;
     }
     if (avail_in > 0) {
       if (bits_left > 31) {
         if (err_msg_ptr)
-          FXSYS_strncpy(err_msg_ptr, "Decode Error", GIF_MAX_ERROR_SIZE - 1);
+          strncpy(err_msg_ptr, "Decode Error", GIF_MAX_ERROR_SIZE - 1);
         return 0;
       }
       pdfium::base::CheckedNumeric<uint32_t> safe_code = *next_in++;
@@ -119,8 +119,8 @@
       safe_code |= code_store;
       if (!safe_code.IsValid()) {
         if (err_msg_ptr) {
-          FXSYS_strncpy(err_msg_ptr, "Code Store Out Of Range",
-                        GIF_MAX_ERROR_SIZE - 1);
+          strncpy(err_msg_ptr, "Code Store Out Of Range",
+                  GIF_MAX_ERROR_SIZE - 1);
         }
         return 0;
       }
@@ -146,8 +146,8 @@
               DecodeString(code);
             } else if (code > code_next) {
               if (err_msg_ptr) {
-                FXSYS_strncpy(err_msg_ptr, "Decode Error, Out Of Range",
-                              GIF_MAX_ERROR_SIZE - 1);
+                strncpy(err_msg_ptr, "Decode Error, Out Of Range",
+                        GIF_MAX_ERROR_SIZE - 1);
               }
               return 0;
             } else {
@@ -522,7 +522,7 @@
   if (!gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6))
     return 2;
 
-  if (FXSYS_strncmp(gif_header_ptr->signature, GIF_SIGNATURE, 3) != 0 ||
+  if (strncmp(gif_header_ptr->signature, GIF_SIGNATURE, 3) != 0 ||
       gif_header_ptr->version[0] != '8' || gif_header_ptr->version[2] != 'a') {
     gif_error(gif_ptr, "Not A Gif Image");
     return 0;
diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp
index e041065..98a6ead 100644
--- a/core/fxcrt/fx_basic_gcc.cpp
+++ b/core/fxcrt/fx_basic_gcc.cpp
@@ -119,7 +119,7 @@
   if (!buf || (int)buflen < srclen + 1)
     return srclen + 1;
 
-  FXSYS_strcpy(buf, filename);
+  strncpy(buf, filename, buflen);
   return srclen;
 }
 
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index 3819153..d9a352c 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -121,11 +121,7 @@
 
 #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
 #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
-#define FXSYS_strncmp strncmp
-#define FXSYS_strcmp strcmp
-#define FXSYS_strcpy strcpy
-#define FXSYS_strncpy strncpy
-#define FXSYS_strstr strstr
+
 #define FXSYS_FILE FILE
 #define FXSYS_fopen fopen
 #define FXSYS_fclose fclose
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 5bce4b4..3d15ca3 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -159,7 +159,9 @@
     return 0;
   if (name.GetLength() >= (long)buf_size)
     return name.GetLength() + 1;
-  FXSYS_strcpy(buffer, name.c_str());
+
+  strncpy(buffer, name.c_str(),
+          (name.GetLength() + 1) * sizeof(CFX_ByteString::CharType));
   return name.GetLength() + 1;
 }
 
diff --git a/third_party/libjpeg/jerror.h b/third_party/libjpeg/jerror.h
index 06d3440..7ac6575 100644
--- a/third_party/libjpeg/jerror.h
+++ b/third_party/libjpeg/jerror.h
@@ -227,10 +227,10 @@
    (cinfo)->err->msg_parm.i[2] = (p3), \
    (cinfo)->err->msg_parm.i[3] = (p4), \
    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
-#define ERREXITS(cinfo,code,str)  \
-  ((cinfo)->err->msg_code = (code), \
-   FXSYS_strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
-   (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
+#define ERREXITS(cinfo,code,str)                                \
+  ((cinfo)->err->msg_code = (code),                             \
+   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+   (*(cinfo)->err->error_exit)((j_common_ptr)(cinfo)))
 
 #define MAKESTMT(stuff)		do { stuff } while (0)
 
@@ -283,9 +283,9 @@
 	   _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
 	   (cinfo)->err->msg_code = (code); \
 	   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
-#define TRACEMSS(cinfo,lvl,code,str)  \
-  ((cinfo)->err->msg_code = (code), \
-   FXSYS_strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
-   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
+#define TRACEMSS(cinfo,lvl,code,str)                            \
+  ((cinfo)->err->msg_code = (code),                             \
+   strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+   (*(cinfo)->err->emit_message)((j_common_ptr)(cinfo), (lvl)))
 
 #endif /* JERROR_H */