+ chg: use double-quotes as MRU list string limiter

This commit is contained in:
Rainer Kottenhoff 2019-07-23 09:45:49 +02:00
parent 3f55869086
commit 54fea83c8f
9 changed files with 59 additions and 40 deletions

View File

@ -1 +1 @@
2402
2403

View File

@ -233,7 +233,7 @@ rem Return: Resolved absolute path.
:: ====================================================================================================================
:END
pause
::endlocal
endlocal
::pause
::exit
:: ====================================================================================================================

View File

@ -3,7 +3,7 @@
<assemblyIdentity
name="Notepad3"
processorArchitecture="*"
version="5.19.721.2402"
version="5.19.723.2403"
type="win32"
/>
<description>Notepad3 BETA</description>

View File

@ -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));

View File

@ -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) {

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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