diff --git a/src/Helpers.c b/src/Helpers.c index 9476b83f4..81064e1ea 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -1541,27 +1541,26 @@ DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSe // // SplitFilePathLineNum() // -void SplitFilePathLineNum(LPWSTR lpszPath, int * lineNum) { +bool SplitFilePathLineNum(LPWSTR lpszPath, int* lineNum) { LPWSTR const lpszSplit = StrRChr(lpszPath, NULL, L':'); + bool res = false; if (lpszSplit) { char chLnNumber[128]; char const defchar = (char)0x24; WideCharToMultiByte(CP_ACP, (WC_COMPOSITECHECK | WC_DISCARDNS), &lpszSplit[1], -1, chLnNumber, COUNTOF(chLnNumber), &defchar, NULL); - te_xint_t iExprError = 0; + te_xint_t iExprError = true; int const ln = (int)te_interp(chLnNumber, &iExprError); - if (iExprError == 0) { + if (!iExprError) { + res = true; lpszSplit[0] = L'\0'; // split if (lineNum) { *lineNum = ln; } } - } else { - if (lineNum) { - *lineNum = -1; // not found - } } + return res; } diff --git a/src/Helpers.h b/src/Helpers.h index c089ea20c..6deeba6bc 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -425,7 +425,7 @@ bool PathCanonicalizeEx(LPWSTR lpszPath, DWORD cchPath); DWORD GetLongPathNameEx(LPWSTR lpszPath, DWORD cchBuffer); void PathGetDisplayName(LPWSTR lpszDestPath, DWORD cchDestBuffer, LPCWSTR lpszSourcePath); DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSearchPathIfRelative); -void SplitFilePathLineNum(LPWSTR lpszPath, int *lineNum); +bool SplitFilePathLineNum(LPWSTR lpszPath, int *lineNum); bool StrLTrimI(LPWSTR pszSource,LPCWSTR pszTrimChars); bool StrRTrimI(LPWSTR pszSource,LPCWSTR pszTrimChars); diff --git a/src/Notepad3.c b/src/Notepad3.c index c1ec0321c..9c399ddf1 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -6919,14 +6919,15 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid) if (StrStrIA(chScheme, "file:") == chScheme) { WCHAR wchUrl[INTERNET_MAX_URL_LENGTH] = { L'\0' }; - WCHAR wchPath[MAX_PATH] = { L'\0' }; int const cchUrl = MultiByteToWideChar(Encoding_SciCP, 0, pUrlBegin, (int)length, wchUrl, COUNTOF(wchUrl)); wchUrl[cchUrl] = L'\0'; StrTrim(wchUrl, L" \r\n\t"); - SplitFilePathLineNum(wchPath, NULL); + int ln = -1; + SplitFilePathLineNum(wchUrl, &ln); + WCHAR wchPath[MAX_PATH] = { L'\0' }; DWORD cchPath = MAX_PATH; if (FAILED(PathCreateFromUrl(wchUrl, wchPath, &cchPath, 0))) { const char *p = &pUrlBegin[CONSTSTRGLEN("file://")];