From ba8ac3f14e5eecb0c37b0df67370304cc1682755 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 3 Apr 2017 14:53:05 -0400 Subject: Drop FXSYS_ from file methods This Cl drops the FXSYS_ from file methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I095c64fed69bf70e00a2594fa94a1fdc71a7060e Reviewed-on: https://pdfium-review.googlesource.com/3610 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/fx_basic_gcc.cpp | 6 ++--- core/fxcrt/fx_system.h | 14 +--------- core/fxge/ge/cfx_folderfontinfo.cpp | 42 ++++++++++++++--------------- core/fxge/ge/cfx_folderfontinfo.h | 2 +- third_party/libjpeg/cdjpeg.h | 10 +++---- third_party/libjpeg/fpdfapi_jerror.c | 2 +- third_party/libjpeg/fpdfapi_jmemmgr.c | 6 ++--- third_party/libjpeg/jinclude.h | 4 +-- third_party/libjpeg/jmemsys.h | 2 +- third_party/libjpeg/jpeglib.h | 4 +-- xfa/fgas/crt/ifgas_stream.cpp | 50 +++++++++++++++++------------------ 11 files changed, 65 insertions(+), 77 deletions(-) diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp index 98a6ead64b..2033265f10 100644 --- a/core/fxcrt/fx_basic_gcc.cpp +++ b/core/fxcrt/fx_basic_gcc.cpp @@ -135,9 +135,9 @@ uint32_t FXSYS_GetModuleFileName(void* hModule, char* buf, uint32_t bufsize) { #ifdef __cplusplus extern "C" { #endif -FXSYS_FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode) { - return FXSYS_fopen(CFX_ByteString::FromUnicode(filename).c_str(), - CFX_ByteString::FromUnicode(mode).c_str()); +FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode) { + return fopen(CFX_ByteString::FromUnicode(filename).c_str(), + CFX_ByteString::FromUnicode(mode).c_str()); } char* FXSYS_strlwr(char* str) { if (!str) { diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h index c471085e25..15b81f4778 100644 --- a/core/fxcrt/fx_system.h +++ b/core/fxcrt/fx_system.h @@ -122,18 +122,6 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE -#define FXSYS_FILE FILE -#define FXSYS_fopen fopen -#define FXSYS_fclose fclose -#define FXSYS_SEEK_END SEEK_END -#define FXSYS_SEEK_SET SEEK_SET -#define FXSYS_fseek fseek -#define FXSYS_ftell ftell -#define FXSYS_fread fread -#define FXSYS_fwrite fwrite -#define FXSYS_fprintf fprintf -#define FXSYS_fflush fflush - #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #ifdef _NATIVE_WCHAR_T_DEFINED #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m)) @@ -141,7 +129,7 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); #define FXSYS_wfopen _wfopen #endif // _NATIVE_WCHAR_T_DEFINED #else -FXSYS_FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode); +FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode); #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #ifdef __cplusplus diff --git a/core/fxge/ge/cfx_folderfontinfo.cpp b/core/fxge/ge/cfx_folderfontinfo.cpp index 52dfc2d243..15a8daf95c 100644 --- a/core/fxge/ge/cfx_folderfontinfo.cpp +++ b/core/fxge/ge/cfx_folderfontinfo.cpp @@ -33,15 +33,15 @@ const struct { {"Times-Italic", "Times New Roman Italic"}, }; -CFX_ByteString FPDF_ReadStringFromFile(FXSYS_FILE* pFile, uint32_t size) { +CFX_ByteString FPDF_ReadStringFromFile(FILE* pFile, uint32_t size) { CFX_ByteString buffer; - if (!FXSYS_fread(buffer.GetBuffer(size), size, 1, pFile)) + if (!fread(buffer.GetBuffer(size), size, 1, pFile)) return CFX_ByteString(); buffer.ReleaseBuffer(size); return buffer; } -CFX_ByteString FPDF_LoadTableFromTT(FXSYS_FILE* pFile, +CFX_ByteString FPDF_LoadTableFromTT(FILE* pFile, const uint8_t* pTables, uint32_t nTables, uint32_t tag) { @@ -50,7 +50,7 @@ CFX_ByteString FPDF_LoadTableFromTT(FXSYS_FILE* pFile, if (GET_TT_LONG(p) == tag) { uint32_t offset = GET_TT_LONG(p + 8); uint32_t size = GET_TT_LONG(p + 12); - FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET); + fseek(pFile, offset, SEEK_SET); return FPDF_ReadStringFromFile(pFile, size); } } @@ -149,34 +149,34 @@ void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) { } void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) { - FXSYS_FILE* pFile = FXSYS_fopen(path.c_str(), "rb"); + FILE* pFile = fopen(path.c_str(), "rb"); if (!pFile) return; - FXSYS_fseek(pFile, 0, FXSYS_SEEK_END); + fseek(pFile, 0, SEEK_END); - uint32_t filesize = FXSYS_ftell(pFile); + uint32_t filesize = ftell(pFile); uint8_t buffer[16]; - FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET); + fseek(pFile, 0, SEEK_SET); - size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile); + size_t readCnt = fread(buffer, 12, 1, pFile); if (readCnt != 1) { - FXSYS_fclose(pFile); + fclose(pFile); return; } if (GET_TT_LONG(buffer) == kTableTTCF) { uint32_t nFaces = GET_TT_LONG(buffer + 8); if (nFaces > std::numeric_limits::max() / 4) { - FXSYS_fclose(pFile); + fclose(pFile); return; } uint32_t face_bytes = nFaces * 4; uint8_t* offsets = FX_Alloc(uint8_t, face_bytes); - readCnt = FXSYS_fread(offsets, 1, face_bytes, pFile); + readCnt = fread(offsets, 1, face_bytes, pFile); if (readCnt != face_bytes) { FX_Free(offsets); - FXSYS_fclose(pFile); + fclose(pFile); return; } for (uint32_t i = 0; i < nFaces; i++) { @@ -187,16 +187,16 @@ void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) { } else { ReportFace(path, pFile, filesize, 0); } - FXSYS_fclose(pFile); + fclose(pFile); } void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, - FXSYS_FILE* pFile, + FILE* pFile, uint32_t filesize, uint32_t offset) { - FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET); + fseek(pFile, offset, SEEK_SET); char buffer[16]; - if (!FXSYS_fread(buffer, 12, 1, pFile)) + if (!fread(buffer, 12, 1, pFile)) return; uint32_t nTables = GET_TT_SHORT(buffer + 4); @@ -353,15 +353,15 @@ uint32_t CFX_FolderFontInfo::GetFontData(void* hFont, if (!datasize || size < datasize) return datasize; - FXSYS_FILE* pFile = FXSYS_fopen(pFont->m_FilePath.c_str(), "rb"); + FILE* pFile = fopen(pFont->m_FilePath.c_str(), "rb"); if (!pFile) return 0; - if (FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET) < 0 || - FXSYS_fread(buffer, datasize, 1, pFile) != 1) { + if (fseek(pFile, offset, SEEK_SET) < 0 || + fread(buffer, datasize, 1, pFile) != 1) { datasize = 0; } - FXSYS_fclose(pFile); + fclose(pFile); return datasize; } diff --git a/core/fxge/ge/cfx_folderfontinfo.h b/core/fxge/ge/cfx_folderfontinfo.h index 9e9a1a2a6a..17940bdbee 100644 --- a/core/fxge/ge/cfx_folderfontinfo.h +++ b/core/fxge/ge/cfx_folderfontinfo.h @@ -48,7 +48,7 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo { void ScanPath(const CFX_ByteString& path); void ScanFile(const CFX_ByteString& path); void ReportFace(const CFX_ByteString& path, - FXSYS_FILE* pFile, + FILE* pFile, uint32_t filesize, uint32_t offset); void* GetSubstFont(const CFX_ByteString& face); diff --git a/third_party/libjpeg/cdjpeg.h b/third_party/libjpeg/cdjpeg.h index 3d728ee9c7..7ca7c66646 100644 --- a/third_party/libjpeg/cdjpeg.h +++ b/third_party/libjpeg/cdjpeg.h @@ -31,7 +31,7 @@ struct cjpeg_source_struct { JMETHOD(void, finish_input, (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); - FXSYS_FILE *input_file; + FILE* input_file; JSAMPARRAY buffer; JDIMENSION buffer_height; @@ -59,7 +59,7 @@ struct djpeg_dest_struct { djpeg_dest_ptr dinfo)); /* Target file spec; filled in by djpeg.c after object is created. */ - FXSYS_FILE * output_file; + FILE* output_file; /* Output pixel-row buffer. Created by module init or start_output. * Width is cinfo->output_width * cinfo->output_components; @@ -138,7 +138,7 @@ EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); /* djpeg support routines (in rdcolmap.c) */ -EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FXSYS_FILE * infile)); +EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE* infile)); /* common support routines (in cdjpeg.c) */ @@ -147,8 +147,8 @@ EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, cd_progress_ptr progress)); EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); -EXTERN(FXSYS_FILE *) read_stdin JPP((void)); -EXTERN(FXSYS_FILE *) write_stdout JPP((void)); +EXTERN(FILE*) read_stdin JPP((void)); +EXTERN(FILE*) write_stdout JPP((void)); /* miscellaneous useful macros */ diff --git a/third_party/libjpeg/fpdfapi_jerror.c b/third_party/libjpeg/fpdfapi_jerror.c index adfb9fe19d..2d4f5ff185 100644 --- a/third_party/libjpeg/fpdfapi_jerror.c +++ b/third_party/libjpeg/fpdfapi_jerror.c @@ -94,7 +94,7 @@ output_message (j_common_ptr cinfo) (*cinfo->err->format_message) (cinfo, buffer); /* Send it to stderr, adding a newline */ - FXSYS_fprintf(stderr, "%s\n", buffer); + fprintf(stderr, "%s\n", buffer); } diff --git a/third_party/libjpeg/fpdfapi_jmemmgr.c b/third_party/libjpeg/fpdfapi_jmemmgr.c index 47ead48ac4..c4e589ab36 100644 --- a/third_party/libjpeg/fpdfapi_jmemmgr.c +++ b/third_party/libjpeg/fpdfapi_jmemmgr.c @@ -195,18 +195,18 @@ print_mem_stats (j_common_ptr cinfo, int pool_id) * fprintf directly rather than going through the trace message code. * This is helpful because message parm array can't handle longs. */ - FXSYS_fprintf(stderr, "Freeing pool %d, total space = %ld\n", + fprintf(stderr, "Freeing pool %d, total space = %ld\n", pool_id, mem->total_space_allocated); for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; lhdr_ptr = lhdr_ptr->hdr.next) { - FXSYS_fprintf(stderr, " Large chunk used %ld\n", + fprintf(stderr, " Large chunk used %ld\n", (long) lhdr_ptr->hdr.bytes_used); } for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; shdr_ptr = shdr_ptr->hdr.next) { - FXSYS_fprintf(stderr, " Small chunk used %ld free %ld\n", + fprintf(stderr, " Small chunk used %ld free %ld\n", (long) shdr_ptr->hdr.bytes_used, (long) shdr_ptr->hdr.bytes_left); } diff --git a/third_party/libjpeg/jinclude.h b/third_party/libjpeg/jinclude.h index 6f6a87c79e..56b04fbcc1 100644 --- a/third_party/libjpeg/jinclude.h +++ b/third_party/libjpeg/jinclude.h @@ -98,6 +98,6 @@ */ #define JFREAD(file,buf,sizeofbuf) \ - ((size_t) FXSYS_fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) + ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) #define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) FXSYS_fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) + ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/third_party/libjpeg/jmemsys.h b/third_party/libjpeg/jmemsys.h index 896688181b..df697a062b 100644 --- a/third_party/libjpeg/jmemsys.h +++ b/third_party/libjpeg/jmemsys.h @@ -129,7 +129,7 @@ typedef struct backing_store_struct { /* Private fields for system-dependent backing-store management */ /* For a typical implementation with temp files, we need: */ - FXSYS_FILE * temp_file; /* stdio reference to temp file */ + FILE* temp_file; /* stdio reference to temp file */ char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ } backing_store_info; diff --git a/third_party/libjpeg/jpeglib.h b/third_party/libjpeg/jpeglib.h index f6af4f2b47..844620a97e 100644 --- a/third_party/libjpeg/jpeglib.h +++ b/third_party/libjpeg/jpeglib.h @@ -1010,8 +1010,8 @@ EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); #if 0 /* Standard data source and destination managers: stdio streams. */ /* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FXSYS_FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FXSYS_FILE * infile)); +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); #endif /* Default parameter setup for compression */ diff --git a/xfa/fgas/crt/ifgas_stream.cpp b/xfa/fgas/crt/ifgas_stream.cpp index 4981145f74..8627c9f17c 100644 --- a/xfa/fgas/crt/ifgas_stream.cpp +++ b/xfa/fgas/crt/ifgas_stream.cpp @@ -64,7 +64,7 @@ class CFGAS_FileStreamImp : public IFGAS_StreamImp { bool SetLength(int32_t iLength) override; protected: - FXSYS_FILE* m_hFile; + FILE* m_hFile; int32_t m_iLength; }; @@ -292,20 +292,20 @@ class CFGAS_FileRead : public IFX_SeekableReadStream { CFX_RetainPtr m_pStream; }; -int32_t FileLength(FXSYS_FILE* file) { +int32_t FileLength(FILE* file) { ASSERT(file); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ return _filelength(_fileno(file)); #else - int32_t iPos = FXSYS_ftell(file); - FXSYS_fseek(file, 0, FXSYS_SEEK_END); - int32_t iLen = FXSYS_ftell(file); - FXSYS_fseek(file, iPos, FXSYS_SEEK_SET); + int32_t iPos = ftell(file); + fseek(file, 0, SEEK_END); + int32_t iLen = ftell(file); + fseek(file, iPos, SEEK_SET); return iLen; #endif } -bool FileSetSize(FXSYS_FILE* file, int32_t size) { +bool FileSetSize(FILE* file, int32_t size) { ASSERT(file); #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ return _chsize(_fileno(file), size) == 0; @@ -327,7 +327,7 @@ CFGAS_FileStreamImp::CFGAS_FileStreamImp() : m_hFile(nullptr), m_iLength(0) {} CFGAS_FileStreamImp::~CFGAS_FileStreamImp() { if (m_hFile) - FXSYS_fclose(m_hFile); + fclose(m_hFile); } bool CFGAS_FileStreamImp::LoadFile(const wchar_t* pszSrcFileName, @@ -379,14 +379,14 @@ bool CFGAS_FileStreamImp::LoadFile(const wchar_t* pszSrcFileName, } } CFX_ByteString szFileName = CFX_ByteString::FromUnicode(pszSrcFileName); - m_hFile = FXSYS_fopen(szFileName.c_str(), wsMode); + m_hFile = fopen(szFileName.c_str(), wsMode); if (!m_hFile) { if (dwAccess & FX_STREAMACCESS_Write) { if (dwAccess & FX_STREAMACCESS_Create) { - m_hFile = FXSYS_fopen(szFileName.c_str(), "w+b"); + m_hFile = fopen(szFileName.c_str(), "w+b"); } if (!m_hFile) { - m_hFile = FXSYS_fopen(szFileName.c_str(), "r+b"); + m_hFile = fopen(szFileName.c_str(), "r+b"); if (!m_hFile) { return false; } @@ -414,21 +414,21 @@ int32_t CFGAS_FileStreamImp::GetLength() const { } int32_t CFGAS_FileStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { ASSERT(m_hFile); - FXSYS_fseek(m_hFile, iOffset, eSeek); - return FXSYS_ftell(m_hFile); + fseek(m_hFile, iOffset, eSeek); + return ftell(m_hFile); } int32_t CFGAS_FileStreamImp::GetPosition() { ASSERT(m_hFile); - return FXSYS_ftell(m_hFile); + return ftell(m_hFile); } bool CFGAS_FileStreamImp::IsEOF() const { ASSERT(m_hFile); - return FXSYS_ftell(m_hFile) >= m_iLength; + return ftell(m_hFile) >= m_iLength; } int32_t CFGAS_FileStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { ASSERT(m_hFile); ASSERT(pBuffer && iBufferSize > 0); - return FXSYS_fread(pBuffer, 1, iBufferSize, m_hFile); + return fread(pBuffer, 1, iBufferSize, m_hFile); } int32_t CFGAS_FileStreamImp::ReadString(wchar_t* pStr, int32_t iMaxLength, @@ -438,19 +438,19 @@ int32_t CFGAS_FileStreamImp::ReadString(wchar_t* pStr, if (m_iLength <= 0) { return 0; } - int32_t iPosition = FXSYS_ftell(m_hFile); + int32_t iPosition = ftell(m_hFile); int32_t iLen = std::min((m_iLength - iPosition) / 2, iMaxLength); if (iLen <= 0) { return 0; } - iLen = FXSYS_fread(pStr, 2, iLen, m_hFile); + iLen = fread(pStr, 2, iLen, m_hFile); int32_t iCount = 0; while (*pStr != L'\0' && iCount < iLen) { pStr++, iCount++; } iPosition += iCount * 2; - if (FXSYS_ftell(m_hFile) != iPosition) { - FXSYS_fseek(m_hFile, iPosition, 0); + if (ftell(m_hFile) != iPosition) { + fseek(m_hFile, iPosition, 0); } bEOS = (iPosition >= m_iLength); return iCount; @@ -459,9 +459,9 @@ int32_t CFGAS_FileStreamImp::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { ASSERT(m_hFile && (GetAccessModes() & FX_STREAMACCESS_Write) != 0); ASSERT(pBuffer && iBufferSize > 0); - int32_t iRet = FXSYS_fwrite(pBuffer, 1, iBufferSize, m_hFile); + int32_t iRet = fwrite(pBuffer, 1, iBufferSize, m_hFile); if (iRet != 0) { - int32_t iPos = FXSYS_ftell(m_hFile); + int32_t iPos = ftell(m_hFile); if (iPos > m_iLength) { m_iLength = iPos; } @@ -471,9 +471,9 @@ int32_t CFGAS_FileStreamImp::WriteData(const uint8_t* pBuffer, int32_t CFGAS_FileStreamImp::WriteString(const wchar_t* pStr, int32_t iLength) { ASSERT(m_hFile && (GetAccessModes() & FX_STREAMACCESS_Write) != 0); ASSERT(pStr && iLength > 0); - int32_t iRet = FXSYS_fwrite(pStr, 2, iLength, m_hFile); + int32_t iRet = fwrite(pStr, 2, iLength, m_hFile); if (iRet != 0) { - int32_t iPos = FXSYS_ftell(m_hFile); + int32_t iPos = ftell(m_hFile); if (iPos > m_iLength) { m_iLength = iPos; } @@ -482,7 +482,7 @@ int32_t CFGAS_FileStreamImp::WriteString(const wchar_t* pStr, int32_t iLength) { } void CFGAS_FileStreamImp::Flush() { ASSERT(m_hFile && (GetAccessModes() & FX_STREAMACCESS_Write) != 0); - FXSYS_fflush(m_hFile); + fflush(m_hFile); } bool CFGAS_FileStreamImp::SetLength(int32_t iLength) { ASSERT(m_hFile && (GetAccessModes() & FX_STREAMACCESS_Write) != 0); -- cgit v1.2.3