From 574e87b1ee04791ed0338e93e270326d3073b97c Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 13 Mar 2019 09:43:02 +0100 Subject: [PATCH] + upd: EOL detection method by Zufuliu + upd: VS2017 and VS2019 version info --- .gitignore | 2 ++ src/Edit.c | 53 ++++++++++++++++++------------- src/Version.h | 4 +-- test/config/Notepad3_distrib.ini | Bin 1220 -> 1258 bytes 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index d498444d5..1996a3042 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ Thumbs.db /src/VersionEx.h /minipath/src/VersionEx.h +/test/test.log + /Version_*.cmd /Versions/build.txt /np3portableapp/_buildname.txt diff --git a/src/Edit.c b/src/Edit.c index 1032012be..0519c9efb 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -838,40 +838,49 @@ void EditDetectEOLMode(LPCSTR lpData, DWORD cbData, EditFileIOStatus* status) DocLn linesCount[3] = { 0, 0, 0 }; - LPCSTR cp = lpData; - LPCSTR const end = cp + cbData; - while (cp < end) { - switch (*cp) { - case '\n': - ++cp; + + // tools/GenerateTable.py + static const UINT8 eol_table[16] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, // 00 - 0F + }; + + const UINT8* ptr = (const UINT8*)lpData; + const UINT8* const end = ptr + cbData; + do { + // skip to line end + UINT ch; + UINT type = 0; + while (ptr < end && ((ch = *ptr++) > '\r' || (type = eol_table[ch]) == 0)) { /* nop */ } + switch (type) { + case 1: //'\n' ++linesCount[SC_EOL_LF]; break; - case '\r': - ++cp; - if (*cp == '\n') { - ++cp; + case 2: //'\r' + if (*ptr == '\n') { + ++ptr; ++linesCount[SC_EOL_CRLF]; } else { ++linesCount[SC_EOL_CR]; } break; - default: - ++cp; - break; } - } + } while (ptr < end); + DocLn const linesMax = max_ln(max_ln(linesCount[0], linesCount[1]), linesCount[2]); - if (linesMax == linesCount[SC_EOL_CRLF]) { - iEOLMode = SC_EOL_CRLF; - } - else if (linesMax == linesCount[SC_EOL_CR]) { - iEOLMode = SC_EOL_CR; - } - else { - iEOLMode = SC_EOL_LF; + if (linesMax != linesCount[iEOLMode]) + { + if (linesMax == linesCount[SC_EOL_CRLF]) { + iEOLMode = SC_EOL_CRLF; + } + else if (linesMax == linesCount[SC_EOL_CR]) { + iEOLMode = SC_EOL_CR; + } + else { + iEOLMode = SC_EOL_LF; + } } status->iEOLMode = iEOLMode; diff --git a/src/Version.h b/src/Version.h index 7bf95eb23..4cd9d9462 100644 --- a/src/Version.h +++ b/src/Version.h @@ -62,7 +62,7 @@ #if defined(_MSC_VER) #if (_MSC_VER >= 1920) #if(_MSC_FULL_VER >= v192027404) - #define VER_CPL MS Visual C++ 2019 16.(RC) Prev 4.(0-1) + #define VER_CPL MS Visual C++ 2019 16.0.0 Prev 4.(0-2) #elif(_MSC_FULL_VER >= 192027323) #define VER_CPL MS Visual C++ 2019 16.0.0 Prev 3.0 #elif(_MSC_FULL_VER >= 192027305) @@ -72,7 +72,7 @@ #endif #elif (_MSC_VER >= 1916) #if(_MSC_FULL_VER >= 191627027) - #define VER_CPL MS Visual C++ 2017 v15.9.(7-8) + #define VER_CPL MS Visual C++ 2017 v15.9.(7-9) #elif(_MSC_FULL_VER >= 191627026) #define VER_CPL MS Visual C++ 2017 v15.9.(5-6) #elif(_MSC_FULL_VER >= 191627025) diff --git a/test/config/Notepad3_distrib.ini b/test/config/Notepad3_distrib.ini index 7d3e6e81e26729fbf2217accd57182faac166f99..1f621e1bac78912dc84f0f82f2666958202a2eb7 100644 GIT binary patch delta 42 tcmX@Y`HFLbiF_(U2@qy7