diff --git a/Versions/build.txt b/Versions/build.txt
index 65b7a7f80..6ee72971b 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-2402
+2403
diff --git a/np3portableapp/build_np3portableapp.cmd b/np3portableapp/build_np3portableapp.cmd
index 7f6ecd804..ed95f45c7 100644
--- a/np3portableapp/build_np3portableapp.cmd
+++ b/np3portableapp/build_np3portableapp.cmd
@@ -233,7 +233,7 @@ rem Return: Resolved absolute path.
:: ====================================================================================================================
:END
-pause
-::endlocal
+endlocal
+::pause
::exit
:: ====================================================================================================================
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index d99e16b9f..0a82a73a2 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,7 +3,7 @@
Notepad3 BETA
diff --git a/src/Dialogs.c b/src/Dialogs.c
index 3a6586f20..a433aee02 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -3992,7 +3992,7 @@ int Toolbar_GetButtons(HANDLE hwnd, int cmdBase, LPWSTR lpszButtons, int cchButt
(tbb.idCommand == 0) ? 0 : tbb.idCommand - cmdBase + 1);
StringCchCat(tchButtons, COUNTOF(tchButtons), tchItem);
}
- TrimStringW(tchButtons);
+ TrimSpcW(tchButtons);
StringCchCopyN(lpszButtons, cchButtons, tchButtons, COUNTOF(tchButtons));
return(c);
}
@@ -4003,7 +4003,7 @@ int Toolbar_SetButtons(HANDLE hwnd, int cmdBase, LPCWSTR lpszButtons, LPCTBBUTTO
ZeroMemory(tchButtons, COUNTOF(tchButtons) * sizeof(tchButtons[0]));
StringCchCopyN(tchButtons, COUNTOF(tchButtons), lpszButtons, COUNTOF(tchButtons) - 2);
- TrimStringW(tchButtons);
+ TrimSpcW(tchButtons);
WCHAR *p = StrStr(tchButtons, L" ");
while (p) {
MoveMemory((WCHAR*)p, (WCHAR*)p + 1, (StringCchLen(p,0) + 1) * sizeof(WCHAR));
diff --git a/src/Helpers.c b/src/Helpers.c
index 842fe523c..91f79b806 100644
--- a/src/Helpers.c
+++ b/src/Helpers.c
@@ -894,19 +894,33 @@ bool PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
//=============================================================================
//
-// StrLTrim()
+// StrLTrimI()
//
-bool StrLTrim(LPWSTR pszSource,LPCWSTR pszTrimChars)
+bool StrLTrimI(LPWSTR pszSource,LPCWSTR pszTrimChars)
{
- if (!pszSource || !*pszSource)
- return false;
+ if (!pszSource || !*pszSource) { return false; }
LPWSTR psz = pszSource;
while (StrChrI(pszTrimChars, *psz)) { ++psz; }
- MoveMemory(pszSource,psz,sizeof(WCHAR)*(StringCchLenW(psz,0) + 1));
+ MoveMemory(pszSource, psz, sizeof(WCHAR)*(StringCchLenW(psz,0) + 1));
- return true;
+ return (psz != pszSource);
+}
+
+//=============================================================================
+//
+// StrRTrimI()
+//
+bool StrRTrimI(LPWSTR pszSource, LPCWSTR pszTrimChars)
+{
+ if (!pszSource || !*pszSource) { return false; }
+ size_t const length = StringCchLenW(pszSource, 0);
+
+ size_t len = length;
+ while ((len > 0) && StrChrI(pszTrimChars, pszSource[--len])) { pszSource[len] = L'\0'; }
+
+ return (length != len);
}
@@ -967,13 +981,15 @@ bool ExtractFirstArgument(LPCWSTR lpArgs, LPWSTR lpArg1, LPWSTR lpArg2, int len)
{
StringCchCopy(lpArg1, len, lpArgs);
+ if (StrIsEmpty(lpArg1)) { return false; }
if (lpArg2) { *lpArg2 = L'\0'; }
- if (!TrimStringW(lpArg1)) { return false; }
+
+ TrimSpcW(lpArg1);
bool bQuoted = false;
if (*lpArg1 == L'\"') {
*lpArg1 = L' ';
- TrimStringW(lpArg1);
+ TrimSpcW(lpArg1);
bQuoted = true;
}
@@ -990,10 +1006,10 @@ bool ExtractFirstArgument(LPCWSTR lpArgs, LPWSTR lpArg1, LPWSTR lpArg2, int len)
StringCchCopy(lpArg2, len, psz + 1);
}
}
- TrimStringW(lpArg1);
+ TrimSpcW(lpArg1);
if (lpArg2) {
- TrimStringW(lpArg2);
+ TrimSpcW(lpArg2);
}
return true;
}
@@ -1541,7 +1557,11 @@ bool MRU_Load(LPMRULIST pmru)
StringCchPrintf(tchName, COUNTOF(tchName), L"%.2i", i + 1);
WCHAR tchItem[2048] = { L'\0' };
if (IniSectionGetString(RegKey_Section, tchName, L"", tchItem, COUNTOF(tchItem))) {
- StrTrim(tchItem, L"\x02\x03");
+ size_t const len = StringCchLen(tchItem, 0);
+ if ((len > 0) && (tchItem[0] == L'"') && (tchItem[len-1] == L'"')) {
+ MoveMemory(tchItem, (tchItem+1), len * sizeof(WCHAR));
+ tchItem[len - 2] = L'\0'; // clear dangling '"'
+ }
pmru->pszItems[n] = StrDup(tchItem);
StringCchPrintf(tchName, COUNTOF(tchName), L"ENC%.2i", i + 1);
@@ -1577,7 +1597,7 @@ bool MRU_Save(LPMRULIST pmru)
if (pmru->pszItems[i]) {
WCHAR tchName[32] = { L'\0' };
StringCchPrintf(tchName, COUNTOF(tchName), L"%.2i", i + 1);
- StringCchPrintf(tchValue, COUNTOF(tchValue), L"\x02%s\x03", pmru->pszItems[i]);
+ StringCchPrintf(tchValue, COUNTOF(tchValue), L"\"%s\"", pmru->pszItems[i]);
IniSectionSetString(RegKey_Section, tchName, tchValue);
if (pmru->iEncoding[i] > 0) {
@@ -2106,7 +2126,7 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int iCount, int iLe
static WCHAR wchTmpBuff[MIDSZ_BUFFER];
StringCchCopyW(wchTmpBuff, COUNTOF(wchTmpBuff), wchCSVStrg);
- TrimStringW(wchTmpBuff);
+ TrimSpcW(wchTmpBuff);
// fill default
for (int i = 0; i < iCount; ++i) {
if (sDefault && *sDefault)
@@ -2145,7 +2165,7 @@ int ReadVectorFromString(LPCWSTR wchStrg, int iVector[], int iCount, int iMin, i
static WCHAR wchTmpBuff[SMALL_BUFFER];
StringCchCopyW(wchTmpBuff, COUNTOF(wchTmpBuff), wchStrg);
- TrimStringW(wchTmpBuff);
+ TrimSpcW(wchTmpBuff);
// ensure single spaces only
WCHAR *p = StrStr(wchTmpBuff, L" ");
while (p) {
diff --git a/src/Helpers.h b/src/Helpers.h
index be9da89b3..eeced1a67 100644
--- a/src/Helpers.h
+++ b/src/Helpers.h
@@ -290,24 +290,23 @@ void PathGetDisplayName(LPWSTR lpszDestPath, DWORD cchDestBuffer, LPCWSTR lpszS
DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSearchPathIfRelative);
-bool StrLTrim(LPWSTR pszSource,LPCWSTR pszTrimChars);
+bool StrLTrimI(LPWSTR pszSource,LPCWSTR pszTrimChars);
+bool StrRTrimI(LPWSTR pszSource,LPCWSTR pszTrimChars);
-inline bool TrimStringA(LPSTR lpString) {
+inline bool TrimSpcA(LPSTR lpString) {
if (!lpString || !*lpString) { return false; }
- StrTrimA(lpString, " ");
- return true;
+ return (bool)StrTrimA(lpString, " \t\v");
};
-inline bool TrimStringW(LPWSTR lpString) {
+inline bool TrimSpcW(LPWSTR lpString) {
if (!lpString || !*lpString) { return false; }
- StrTrimW(lpString, L" ");
- return true;
+ return (bool)StrTrimW(lpString, L" \t\v");
};
#if (defined(UNICODE) || defined(_UNICODE))
-#define TrimString TrimStringW
+#define TrimSpc TrimSpcW
#else
-#define TrimString TrimStringA
+#define TrimSpc TrimSpcA
#endif
bool ExtractFirstArgument(LPCWSTR lpArgs, LPWSTR lpArg1, LPWSTR lpArg2, int len);
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 489ba29af..27e1767cc 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -7567,7 +7567,7 @@ void ParseCommandLine()
else if (!bIsFileArg && ((*lp1 == L'/') || (*lp1 == L'-'))) {
// LTrim
- StrLTrim(lp1, L"-/");
+ StrLTrimI(lp1, L"-/");
// Encoding
cpi_enc_t const encoding = Encoding_MatchW(lp1);
@@ -7628,7 +7628,7 @@ void ParseCommandLine()
else if (StrCmpNI(lp1, L"tmpfbuf=", CSTRLEN(L"tmpfbuf=")) == 0) {
StringCchCopyN(s_wchTmpFilePath, COUNTOF(s_wchTmpFilePath),
lp1 + CSTRLEN(L"tmpfbuf="), len - CSTRLEN(L"tmpfbuf="));
- TrimStringW(s_wchTmpFilePath);
+ TrimSpcW(s_wchTmpFilePath);
NormalizePathEx(s_wchTmpFilePath, COUNTOF(s_wchTmpFilePath), true, s_flagSearchPathIfRelative);
s_flagIsElevatedRelaunch = true;
}
@@ -7656,7 +7656,7 @@ void ParseCommandLine()
StringCchCopy(Globals.IniFile, COUNTOF(Globals.IniFile), L"*?");
else if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) {
StringCchCopyN(Globals.IniFile, COUNTOF(Globals.IniFile), lp1, len);
- TrimStringW(Globals.IniFile);
+ TrimSpcW(Globals.IniFile);
NormalizePathEx(Globals.IniFile, COUNTOF(Globals.IniFile), true, false);
}
break;
diff --git a/src/Styles.c b/src/Styles.c
index 77081f443..6ee6966b2 100644
--- a/src/Styles.c
+++ b/src/Styles.c
@@ -2374,7 +2374,7 @@ bool Style_StrGetFont(LPCWSTR lpszStyle, LPWSTR lpszFont, int cchFont)
if ((p = StrChr(lpszFont, L';')) != NULL) {
*p = L'\0';
}
- TrimStringW(lpszFont);
+ TrimSpcW(lpszFont);
if (_IsItemInStyleString(lpszFont, L"Default")) {
if (IsFontAvailable(L"Consolas")) {
StringCchCopyN(lpszFont, cchFont, L"Consolas", cchFont);
@@ -2402,7 +2402,7 @@ bool Style_StrGetFontQuality(LPCWSTR lpszStyle,LPWSTR lpszQuality,int cchQuality
p = StrChr(tch, L';');
if (p)
*p = L'\0';
- TrimStringW(tch);
+ TrimSpcW(tch);
if (_IsItemInStyleString(tch, L"none") ||
_IsItemInStyleString(tch, L"standard") ||
_IsItemInStyleString(tch, L"cleartype") ||
@@ -2474,7 +2474,7 @@ bool Style_StrGetSize(LPCWSTR lpszStyle, float* f)
}
p = StrChr(tch, L';');
if (p) { *p = L'\0'; }
- TrimStringW(tch);
+ TrimSpcW(tch);
float fValue = 0.0;
if (Char2FloatW(tch, &fValue))
@@ -2506,7 +2506,7 @@ bool Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize)
StringCchCopy(tch, COUNTOF(tch), (p + CSTRLEN(L"size:")));
p = StrChr(tch, L';');
if (p) { *p = L'\0'; }
- TrimStringW(tch);
+ TrimSpcW(tch);
float fValue = 0.0f;
if (Char2FloatW(tch, &fValue)) {
@@ -2614,7 +2614,7 @@ bool Style_StrGetColor(LPCWSTR lpszStyle, COLOR_LAYER layer, COLORREF* rgb)
p = StrChr(tch, L';');
if (p)
*p = L'\0';
- TrimStringW(tch);
+ TrimSpcW(tch);
unsigned int iValue = 0;
int itok = swscanf_s(tch, L"%x", &iValue);
if (itok == 1)
@@ -2642,7 +2642,7 @@ bool Style_StrGetAlpha(LPCWSTR lpszStyle, int* iOutValue, bool bAlpha1st)
p = StrChr(tch, L';');
if (p)
*p = L'\0';
- TrimStringW(tch);
+ TrimSpcW(tch);
int iValue = 0;
int itok = swscanf_s(tch, L"%i", &iValue);
if (itok == 1) {
diff --git a/src/VersionEx.h b/src/VersionEx.h
index 10b726167..b31db9325 100644
--- a/src/VersionEx.h
+++ b/src/VersionEx.h
@@ -7,8 +7,8 @@
#define SAPPNAME "Notepad3"
#define VERSION_MAJOR 5
#define VERSION_MINOR 19
-#define VERSION_REV 721
-#define VERSION_BUILD 2402
+#define VERSION_REV 723
+#define VERSION_BUILD 2403
#define SCINTILLA_VER 420
#define ONIGURUMA_REGEX_VER 6.9.3
#define VERSION_PATCH BETA