diff --git a/Versions/build.txt b/Versions/build.txt
index 3c6eb2a8d..1507ddb96 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-2715
+2716
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index 5978cbdb5..a1b84fbd1 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,7 +3,7 @@
Notepad3 BETA
diff --git a/src/Edit.c b/src/Edit.c
index 9f0e0f807..afa3133fa 100644
--- a/src/Edit.c
+++ b/src/Edit.c
@@ -280,7 +280,7 @@ void EditInitWordDelimiter(HWND hwnd)
if (StrIsNotEmpty(Settings2.AutoCompleteFillUpChars))
{
WideCharToMultiByte(Encoding_SciCP, 0, Settings2.AutoCompleteFillUpChars, -1, AutoCompleteFillUpChars, (int)COUNTOF(AutoCompleteFillUpChars), NULL, NULL);
- UnSlash(AutoCompleteFillUpChars, Encoding_SciCP);
+ UnSlashA(AutoCompleteFillUpChars, Encoding_SciCP);
s_ACFillUpCharsHaveNewLn = false;
int i = 0;
@@ -5356,6 +5356,7 @@ static LRESULT CALLBACK EditBoxForPasteFixes(HWND hwnd, UINT uMsg, WPARAM wParam
SendMessage(hwnd, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)tchBuf2);
}
else {
+ UnSlashW(s_tchBuf);
SendMessage(hwnd, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)s_tchBuf);
}
}
@@ -5773,6 +5774,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
}
else {
StringCchCopyA(lpszSelection, len + 1, pClip);
+ UnSlashA(lpszSelection, Encoding_SciCP);
}
}
FreeMem(pClip);
@@ -5980,10 +5982,10 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
}
}
else {
- UnSlash(sg_pefrData->szFind, Encoding_SciCP);
+ UnSlashA(sg_pefrData->szFind, Encoding_SciCP);
SetDlgItemTextMB2W(hwnd, IDC_FINDTEXT, sg_pefrData->szFind);
if (GetDlgItem(hwnd, IDC_REPLACE)) {
- UnSlash(sg_pefrData->szReplace, Encoding_SciCP);
+ UnSlashA(sg_pefrData->szReplace, Encoding_SciCP);
SetDlgItemTextMB2W(hwnd, IDC_REPLACETEXT, sg_pefrData->szReplace);
}
}
diff --git a/src/Helpers.c b/src/Helpers.c
index a097d15d8..ebcab6f21 100644
--- a/src/Helpers.c
+++ b/src/Helpers.c
@@ -1888,11 +1888,11 @@ size_t SlashW(LPWSTR pchOutput, size_t cchOutLen, LPCWSTR pchInput)
*
* Convert C style \a, \b, \f, \n, \r, \t, \v, \xhh, \uhhhh and \\ into their indicated characters.
*/
-size_t UnSlash(LPSTR pchInOut, UINT cpEdit)
+size_t UnSlashA(LPSTR pchInOut, UINT cpEdit)
{
LPSTR s = pchInOut;
LPSTR o = pchInOut;
- LPSTR const sStart = pchInOut;
+ LPCSTR const sStart = pchInOut;
while (*s) {
if (*s == '\\') {
@@ -1922,22 +1922,22 @@ size_t UnSlash(LPSTR pchInOut, UINT cpEdit)
WCHAR val[2] = L"";
int hex;
val[0] = 0;
- hex = GetHexDigit(*(s + 1));
+ hex = GetHexDigitA(*(s + 1));
if (hex >= 0) {
++s;
val[0] = (WCHAR)hex;
- hex = GetHexDigit(*(s + 1));
+ hex = GetHexDigitA(*(s + 1));
if (hex >= 0) {
++s;
val[0] *= 16;
val[0] += (WCHAR)hex;
if (!bShort) {
- hex = GetHexDigit(*(s + 1));
+ hex = GetHexDigitA(*(s + 1));
if (hex >= 0) {
++s;
val[0] *= 16;
val[0] += (WCHAR)hex;
- hex = GetHexDigit(*(s + 1));
+ hex = GetHexDigitA(*(s + 1));
if (hex >= 0) {
++s;
val[0] *= 16;
@@ -1978,6 +1978,85 @@ size_t UnSlash(LPSTR pchInOut, UINT cpEdit)
return (size_t)((ptrdiff_t)(o - sStart));
}
+size_t UnSlashW(LPWSTR pchInOut)
+{
+ LPWSTR s = pchInOut;
+ LPWSTR o = pchInOut;
+ LPCWSTR const sStart = pchInOut;
+
+ while (*s) {
+ if (*s == '\\') {
+ ++s;
+ if (*s == L'a')
+ *o = L'\a';
+ else if (*s == L'b')
+ *o = L'\b';
+ else if (*s == L'e')
+ *o = L'\x1B';
+ else if (*s == L'f')
+ *o = L'\f';
+ else if (*s == L'n')
+ *o = L'\n';
+ else if (*s == L'r')
+ *o = L'\r';
+ else if (*s == L't')
+ *o = L'\t';
+ else if (*s == L'v')
+ *o = L'\v';
+ else if (*s == L'\\')
+ *o = L'\\';
+ else if (*s == L'x' || *s == L'u') {
+ bool bShort = (*s == L'x');
+ WCHAR val = L'\0';
+ int hex = GetHexDigitW(*(s + 1));
+ if (hex >= 0) {
+ val = (WCHAR)hex;
+ hex = GetHexDigitW(*(++s + 1));
+ if (hex >= 0) {
+ ++s;
+ val *= 16;
+ val += (WCHAR)hex;
+ if (!bShort) {
+ hex = GetHexDigitW(*(s + 1));
+ if (hex >= 0) {
+ val *= 16;
+ val += (WCHAR)hex;
+ hex = GetHexDigitW(*(++s + 1));
+ if (hex >= 0) {
+ ++s;
+ val *= 16;
+ val += (WCHAR)hex;
+ }
+ }
+ }
+ }
+
+ if (val) {
+ *o = val;
+ }
+ else
+ --o;
+ }
+ else
+ --o;
+ }
+ else {
+ *o = '\\'; // revert
+ *++o = *s;
+ }
+ }
+ else
+ *o = *s;
+
+ ++o;
+ if (*s) {
+ ++s;
+ }
+ }
+ *o = '\0';
+ return (size_t)((ptrdiff_t)(o - sStart));
+}
+
/**
* check, if we have regex sub-group referencing
*/
@@ -2015,7 +2094,7 @@ void TransformBackslashes(char* pszInput, bool bRegEx, UINT cpEdit, int* iReplac
// regex handles backslashes itself
// except: replacement is not delegated to regex engine
if (!bRegEx || (iReplaceMsg && (SCI_REPLACETARGET == *iReplaceMsg))) {
- UnSlash(pszInput, cpEdit);
+ UnSlashA(pszInput, cpEdit);
}
}
diff --git a/src/Helpers.h b/src/Helpers.h
index 913560706..6db37af16 100644
--- a/src/Helpers.h
+++ b/src/Helpers.h
@@ -355,7 +355,9 @@ UINT CharSetFromCodePage(const UINT uCodePage);
size_t SlashA(LPSTR pchOutput, size_t cchOutLen, LPCSTR pchInput);
size_t SlashW(LPWSTR pchOutput, size_t cchOutLen, LPCWSTR pchInput);
-size_t UnSlash(LPSTR pchInOut, UINT cpEdit);
+size_t UnSlashA(LPSTR pchInOut, UINT cpEdit);
+size_t UnSlashW(LPWSTR pchInOut);
+
void TransformBackslashes(char* pszInput, bool, UINT cpEdit, int* iReplaceMsg);
void TransformMetaChars(char* pszInput, bool, int iEOLMode);
@@ -541,14 +543,20 @@ __inline bool IsAlphaNumeric(WCHAR ch) {
((ch >= L'A') && (ch <= L'Z'));
}
-// If the character is an hexa digit, get its value.
-__inline int GetHexDigit(char ch) {
+// If the character is an hexadecimal digit, get its value.
+__inline int GetHexDigitA(char ch) {
if (ch >= '0' && ch <= '9') { return ch - '0'; }
if (ch >= 'A' && ch <= 'F') { return ch - 'A' + 10; }
if (ch >= 'a' && ch <= 'f') { return ch - 'a' + 10; }
return -1;
}
+__inline int GetHexDigitW(WCHAR ch) {
+ if (ch >= L'0' && ch <= L'9') { return ch - L'0'; }
+ if (ch >= L'A' && ch <= L'F') { return ch - L'A' + 10; }
+ if (ch >= L'a' && ch <= L'f') { return ch - L'a' + 10; }
+ return -1;
+}
// ----------------------------------------------------------------------------
void UrlEscapeEx(LPCWSTR lpURL, LPWSTR lpEscaped, DWORD* pcchEscaped, bool bEscReserved);
diff --git a/src/VersionEx.h b/src/VersionEx.h
index 0165e5a6b..ac97f2a3b 100644
--- a/src/VersionEx.h
+++ b/src/VersionEx.h
@@ -8,8 +8,8 @@
#define SAPPNAME "Notepad3"
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
-#define VERSION_REV 127
-#define VERSION_BUILD 2715
+#define VERSION_REV 128
+#define VERSION_BUILD 2716
#define SCINTILLA_VER 430
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27