[0.4.7][NOTEPAD] Fix a MSVC warning about Globals.encFile (#648) (#650) CORE-7538
authorJoachim Henze <Joachim.Henze@reactos.org>
Sat, 12 Mar 2022 23:20:56 +0000 (00:20 +0100)
committerJoachim Henze <Joachim.Henze@reactos.org>
Sat, 12 Mar 2022 23:20:56 +0000 (00:20 +0100)
Observable in MSVC2010SP1 x86 dbg-config
"...\dialog.c(365) : error C4133: 'function' : incompatible types - from 'ENCODING *' to 'int *'"
CORE-7538

the fix is a squashed port of:
0.4.10-dev-286-g 6830ecb118c80f0dd625b79fe37b66315e024f46 (#650)
0.4.10-dev-283-g 97df61edfa1a630ed48de98998a352b6b3eb5466
0.4.10-dev-282-g 534a309edcac565afa82f4356e942ae9aaed3b2e (#648) got superseded by 2nd commit

base/applications/notepad/dialog.c
base/applications/notepad/main.h
base/applications/notepad/text.c

index 04e6e7b..d92e11a 100644 (file)
@@ -496,7 +496,7 @@ DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
             {
                 hCombo = GetDlgItem(hDlg, ID_ENCODING);
                 if (hCombo)
-                    Globals.encFile = (int) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
+                    Globals.encFile = (ENCODING) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
 
                 hCombo = GetDlgItem(hDlg, ID_EOLN);
                 if (hCombo)
index c64ccf6..a84162f 100644 (file)
@@ -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);
index be7a764..2c6ee8c 100644 (file)
@@ -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";