|
|
@ -515,11 +515,10 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
|
|
|
|
if (encoding == -1)
|
|
|
|
if (encoding == -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
|
|
|
|
// 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
|
|
|
|
if (UnicodeConvertor.getNewBuf())
|
|
|
|
if (nullptr != UnicodeConvertor.getNewBuf())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int format = getEOLFormatForm(UnicodeConvertor.getNewBuf());
|
|
|
|
int format = getEOLFormatForm(UnicodeConvertor.getNewBuf(), UnicodeConvertor.getNewSize());
|
|
|
|
buf->setFormat(format == -1?WIN_FORMAT:(formatType)format);
|
|
|
|
buf->setFormat(format == -1?WIN_FORMAT:(formatType)format);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -577,7 +576,7 @@ bool FileManager::reloadBuffer(BufferID id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (nullptr != UnicodeConvertor.getNewBuf())
|
|
|
|
if (nullptr != UnicodeConvertor.getNewBuf())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int format = getEOLFormatForm(UnicodeConvertor.getNewBuf());
|
|
|
|
int format = getEOLFormatForm(UnicodeConvertor.getNewBuf(), UnicodeConvertor.getNewSize());
|
|
|
|
buf->setFormat(format == -1?WIN_FORMAT:(formatType)format);
|
|
|
|
buf->setFormat(format == -1?WIN_FORMAT:(formatType)format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -1248,7 +1247,7 @@ inline bool FileManager::loadFileData(Document doc, const TCHAR * filename, char
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (format == -1)
|
|
|
|
if (format == -1)
|
|
|
|
format = getEOLFormatForm(data);
|
|
|
|
format = getEOLFormatForm(data, lenFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1330,14 +1329,15 @@ int FileManager::docLength(Buffer * buffer) const
|
|
|
|
return docLen;
|
|
|
|
return docLen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int FileManager::getEOLFormatForm(const char *data) const
|
|
|
|
int FileManager::getEOLFormatForm(const char* const data, size_t length) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t len = strlen(data);
|
|
|
|
assert(data != nullptr && "invalid buffer for getEOLFormatForm()");
|
|
|
|
for (size_t i = 0 ; i < len ; i++)
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i != length; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (data[i] == CR)
|
|
|
|
if (data[i] == CR)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (i+1 < len && data[i+1] == LF)
|
|
|
|
if (i+1 < length && data[i+1] == LF)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return int(WIN_FORMAT);
|
|
|
|
return int(WIN_FORMAT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|