From 66789aba2e24f3b30702d7f13e256c0556897423 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 22 Jan 2022 02:05:40 +0100 Subject: [PATCH] Fix error in x86 build Use the constant instead of the magic number. --- PowerEditor/src/ScintillaComponent/Buffer.cpp | 12 ++++++------ PowerEditor/src/ScintillaComponent/Buffer.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 112c9b730..9516a537f 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -647,14 +647,14 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin if (!fp) return BUFFER_INVALID; _fseeki64(fp, 0, SEEK_END); - size_t fileSize = _ftelli64(fp); + int64_t fileSize = _ftelli64(fp); fclose(fp); - + bool ownDoc = false; if (!doc) { // If file exceeds 200MB, activate large file mode - doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT, 0, fileSize < (200 * 1024 * 1024) ? 0 : SC_DOCUMENTOPTION_STYLES_NONE | SC_DOCUMENTOPTION_TEXT_LARGE); + doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT, 0, fileSize < NPP_STYLING_FILESIZE_LIMIT ? 0 : SC_DOCUMENTOPTION_STYLES_NONE | SC_DOCUMENTOPTION_TEXT_LARGE); ownDoc = true; } @@ -751,7 +751,7 @@ bool FileManager::reloadBuffer(BufferID id) if (!fp) return false; _fseeki64(fp, 0, SEEK_END); - size_t fileSize = _ftelli64(fp); + int64_t fileSize = _ftelli64(fp); fclose(fp); bool res = loadFileData(doc, fileSize, buf->getFullPathName(), data, &UnicodeConvertor, loadedFileFormat); @@ -1352,14 +1352,14 @@ LangType FileManager::detectLanguageFromTextBegining(const unsigned char *data, return L_TEXT; } -bool FileManager::loadFileData(Document doc, size_t fileSize, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat) +bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * filename, char* data, Utf8_16_Read * unicodeConvertor, LoadedFileFormat& fileFormat) { FILE *fp = generic_fopen(filename, TEXT("rb")); if (!fp) return false; // size/6 is the normal room Scintilla keeps for editing, but here we limit it to 1MiB when loading (maybe we want to load big files without editing them too much) - size_t bufferSizeRequested = fileSize +min(1 << 20, fileSize / 6); + int64_t bufferSizeRequested = fileSize +min(1 << 20, fileSize / 6); NppParameters& nppParam = NppParameters::getInstance(); NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker(); diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index a68a8329b..74c057b9f 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -24,6 +24,7 @@ class Notepad_plus; class Buffer; typedef Buffer* BufferID; //each buffer has unique ID by which it can be retrieved #define BUFFER_INVALID reinterpret_cast(0) +#define NPP_STYLING_FILESIZE_LIMIT (200 * 1024 * 1024) // 200MB+ file won't be styled typedef sptr_t Document; @@ -124,7 +125,7 @@ private: FileManager& operator=(FileManager&&) = delete; int detectCodepage(char* buf, size_t len); - bool loadFileData(Document doc, size_t fileSize, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat); + bool loadFileData(Document doc, int64_t fileSize, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat); LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen);