https://git.reactos.org/?p=reactos.git;a=commitdiff;h=97df61edfa1a630ed48de…
commit 97df61edfa1a630ed48de98998a352b6b3eb5466
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Fri Jun 29 14:59:16 2018 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Fri Jun 29 18:49:44 2018 +0200
[NOTEPAD] Avoid a cast.
---
base/applications/notepad/dialog.c | 2 +-
base/applications/notepad/main.h | 4 ++--
base/applications/notepad/text.c | 9 +++++----
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c
index e1c660b7ae..04e6e7b837 100644
--- a/base/applications/notepad/dialog.c
+++ b/base/applications/notepad/dialog.c
@@ -362,7 +362,7 @@ VOID DoOpenFile(LPCTSTR szFileName)
goto done;
}
- if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, (int
*)&Globals.encFile, &Globals.iEoln))
+ if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, &Globals.encFile,
&Globals.iEoln))
{
ShowLastError();
goto done;
diff --git a/base/applications/notepad/main.h b/base/applications/notepad/main.h
index c64ccf6e2f..a84162fbc0 100644
--- a/base/applications/notepad/main.h
+++ b/base/applications/notepad/main.h
@@ -91,8 +91,8 @@ extern NOTEPAD_GLOBALS Globals;
VOID SetFileName(LPCTSTR szFileName);
/* from text.c */
-BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, int *pencFile, int
*piEoln);
-BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, int encFile, int iEoln);
+BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int
*piEoln);
+BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int
iEoln);
/* from settings.c */
void NOTEPAD_LoadSettingsFromRegistry(void);
diff --git a/base/applications/notepad/text.c b/base/applications/notepad/text.c
index be7a76446a..2c6ee8cd07 100644
--- a/base/applications/notepad/text.c
+++ b/base/applications/notepad/text.c
@@ -48,7 +48,7 @@ static BOOL Append(LPWSTR *ppszText, DWORD *pdwTextLen, LPCWSTR
pszAppendText, D
}
BOOL
-ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, int *pencFile, int *piEoln)
+ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int
*piEoln)
{
DWORD dwSize;
LPBYTE pBytes = NULL;
@@ -58,7 +58,7 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, int
*pencFile, int *
DWORD dwCharCount;
BOOL bSuccess = FALSE;
BYTE b = 0;
- int encFile = ENCODING_ANSI;
+ ENCODING encFile = ENCODING_ANSI;
int iCodePage = 0;
WCHAR szCrlf[2] = {'\r', '\n'};
DWORD adwEolnCount[3] = {0, 0, 0};
@@ -147,6 +147,7 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, int
*pencFile, int *
pszAllocText[dwCharCount] = '\0';
pszText = pszAllocText;
break;
+ DEFAULT_UNREACHABLE;
}
dwPos = 0;
@@ -221,7 +222,7 @@ done:
return bSuccess;
}
-static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, int
encFile)
+static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING
encFile)
{
LPBYTE pBytes = NULL;
LPBYTE pAllocBuffer = NULL;
@@ -315,7 +316,7 @@ done:
return bSuccess;
}
-BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, int encFile, int iEoln)
+BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int
iEoln)
{
WCHAR wcBom;
LPCWSTR pszLF = L"\n";