[1/2] notepad: Use the explicit W-form for some string functions.

Michael Stefaniuc mstefani at redhat.de
Thu May 7 15:25:33 CDT 2009


---
 programs/notepad/dialog.c |   18 ++++++------
 programs/notepad/main.c   |   60 ++++++++++++++++++++++----------------------
 2 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c
index b651269..b028c38 100644
--- a/programs/notepad/dialog.c
+++ b/programs/notepad/dialog.c
@@ -68,13 +68,13 @@ static void UpdateWindowCaption(void)
   static const WCHAR hyphenW[] = { ' ','-',' ',0 };
 
   if (Globals.szFileTitle[0] != '\0')
-      lstrcpy(szCaption, Globals.szFileTitle);
+      lstrcpyW(szCaption, Globals.szFileTitle);
   else
       LoadString(Globals.hInstance, STRING_UNTITLED, szCaption, SIZEOF(szCaption));
 
   LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, SIZEOF(szNotepad));
-  lstrcat(szCaption, hyphenW);
-  lstrcat(szCaption, szNotepad);
+  lstrcatW(szCaption, hyphenW);
+  lstrcatW(szCaption, szNotepad);
 
   SetWindowText(Globals.hMainWnd, szCaption);
 }
@@ -86,7 +86,7 @@ int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCWSTR szString, DWORD dwFl
 
    /* Load and format szMessage */
    LoadString(Globals.hInstance, formatId, szResource, SIZEOF(szResource));
-   wnsprintf(szMessage, SIZEOF(szMessage), szResource, szString);
+   wnsprintfW(szMessage, SIZEOF(szMessage), szResource, szString);
 
    /* Load szCaption */
    if ((dwFlags & MB_ICONMASK) == MB_ICONEXCLAMATION)
@@ -259,7 +259,7 @@ void DoOpenFile(LPCWSTR szFileName)
     SetFocus(Globals.hEdit);
     
     /*  If the file starts with .LOG, add a time/date at the end and set cursor after */
-    if (GetWindowTextW(Globals.hEdit, log, sizeof(log)/sizeof(log[0])) && !lstrcmp(log, dotlog))
+    if (GetWindowTextW(Globals.hEdit, log, sizeof(log)/sizeof(log[0])) && !lstrcmpW(log, dotlog))
     {
 	static const WCHAR lfW[] = { '\r','\n',0 };
         SendMessageW(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1);
@@ -295,7 +295,7 @@ VOID DIALOG_FileOpen(VOID)
     ZeroMemory(&openfilename, sizeof(openfilename));
 
     GetCurrentDirectory(SIZEOF(szDir), szDir);
-    lstrcpy(szPath, txt_files);
+    lstrcpyW(szPath, txt_files);
 
     openfilename.lStructSize       = sizeof(openfilename);
     openfilename.hwndOwner         = Globals.hMainWnd;
@@ -334,7 +334,7 @@ BOOL DIALOG_FileSaveAs(VOID)
     ZeroMemory(&saveas, sizeof(saveas));
 
     GetCurrentDirectory(SIZEOF(szDir), szDir);
-    lstrcpy(szPath, txt_files);
+    lstrcpyW(szPath, txt_files);
 
     saveas.lStructSize       = sizeof(OPENFILENAMEW);
     saveas.hwndOwner         = Globals.hMainWnd;
@@ -370,11 +370,11 @@ static int notepad_print_header(HDC hdc, RECT *rc, BOOL dopage, BOOL header, int
     if (*text)
     {
         /* Write the header or footer */
-        GetTextExtentPoint32(hdc, text, lstrlen(text), &szMetric);
+        GetTextExtentPoint32W(hdc, text, lstrlenW(text), &szMetric);
         if (dopage)
             ExtTextOut(hdc, (rc->left + rc->right - szMetric.cx) / 2,
                        header ? rc->top : rc->bottom - szMetric.cy,
-                       ETO_CLIPPED, rc, text, lstrlen(text), NULL);
+                       ETO_CLIPPED, rc, text, lstrlenW(text), NULL);
         return 1;
     }
     return 0;
diff --git a/programs/notepad/main.c b/programs/notepad/main.c
index 3618168..eaab3c3 100644
--- a/programs/notepad/main.c
+++ b/programs/notepad/main.c
@@ -72,7 +72,7 @@ static const WCHAR value_szFooter[]         = {'s','z','T','r','a','i','l','e','
  */
 VOID SetFileName(LPCWSTR szFileName)
 {
-    lstrcpy(Globals.szFileName, szFileName);
+    lstrcpyW(Globals.szFileName, szFileName);
     Globals.szFileTitle[0] = 0;
     GetFileTitle(szFileName, Globals.szFileTitle, sizeof(Globals.szFileTitle));
 }
@@ -153,13 +153,13 @@ static VOID NOTEPAD_SaveSettingToRegistry(void)
         RegSetValueEx(hkey, value_iPointSize, 0, REG_DWORD, (LPBYTE)&data, sizeof(DWORD));
 
         RegSetValueEx(hkey, value_lfFaceName, 0, REG_SZ, (LPBYTE)&Globals.lfFont.lfFaceName,
-                      lstrlen(Globals.lfFont.lfFaceName) * sizeof(Globals.lfFont.lfFaceName[0]));
+                      lstrlenW(Globals.lfFont.lfFaceName) * sizeof(Globals.lfFont.lfFaceName[0]));
 
         RegSetValueEx(hkey, value_szHeader, 0, REG_SZ, (LPBYTE)&Globals.szHeader,
-                      lstrlen(Globals.szHeader) * sizeof(Globals.szHeader[0]));
+                      lstrlenW(Globals.szHeader) * sizeof(Globals.szHeader[0]));
 
         RegSetValueEx(hkey, value_szFooter, 0, REG_SZ, (LPBYTE)&Globals.szFooter,
-                      lstrlen(Globals.szFooter) * sizeof(Globals.szFooter[0]));
+                      lstrlenW(Globals.szFooter) * sizeof(Globals.szFooter[0]));
 
         RegCloseKey(hkey);
     }
@@ -203,7 +203,7 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
     Globals.lfFont.lfClipPrecision  = CLIP_DEFAULT_PRECIS;
     Globals.lfFont.lfQuality        = DEFAULT_QUALITY;
     Globals.lfFont.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
-    lstrcpy(Globals.lfFont.lfFaceName, systemW);
+    lstrcpyW(Globals.lfFont.lfFaceName, systemW);
 
     LoadString(Globals.hInstance, STRING_PAGESETUP_HEADERVALUE, Globals.szHeader,
                sizeof(Globals.szHeader) / sizeof(Globals.szHeader[0]));
@@ -250,17 +250,17 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
         size = sizeof(Globals.lfFont.lfFaceName);
         if(RegQueryValueEx(hkey, value_lfFaceName, 0, &type, (LPBYTE)&data_helper, &size) == ERROR_SUCCESS)
             if(type == REG_SZ)
-                lstrcpy(Globals.lfFont.lfFaceName, data_helper);
-        
+                lstrcpyW(Globals.lfFont.lfFaceName, data_helper);
+
         size = sizeof(Globals.szHeader);
         if(RegQueryValueEx(hkey, value_szHeader, 0, &type, (LPBYTE)&data_helper, &size) == ERROR_SUCCESS)
             if(type == REG_SZ)
-                lstrcpy(Globals.szHeader, data_helper);
+                lstrcpyW(Globals.szHeader, data_helper);
 
         size = sizeof(Globals.szFooter);
         if(RegQueryValueEx(hkey, value_szFooter, 0, &type, (LPBYTE)&data_helper, &size) == ERROR_SUCCESS)
             if(type == REG_SZ)
-                lstrcpy(Globals.szFooter, data_helper);
+                lstrcpyW(Globals.szFooter, data_helper);
         RegCloseKey(hkey);
     }
 }
@@ -320,13 +320,13 @@ static VOID NOTEPAD_InitData(VOID)
     static const WCHAR all_files[] = { '*','.','*',0 };
 
     LoadString(Globals.hInstance, STRING_TEXT_FILES_TXT, p, MAX_STRING_LEN);
-    p += lstrlen(p) + 1;
-    lstrcpy(p, txt_files);
-    p += lstrlen(p) + 1;
+    p += lstrlenW(p) + 1;
+    lstrcpyW(p, txt_files);
+    p += lstrlenW(p) + 1;
     LoadString(Globals.hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN);
-    p += lstrlen(p) + 1;
-    lstrcpy(p, all_files);
-    p += lstrlen(p) + 1;
+    p += lstrlenW(p) + 1;
+    lstrcpyW(p, all_files);
+    p += lstrlenW(p) + 1;
     *p = '\0';
     Globals.hDevMode = NULL;
     Globals.hDevNames = NULL;
@@ -358,11 +358,11 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, int index)
 
 static LPWSTR NOTEPAD_StrRStr(LPWSTR pszSource, LPWSTR pszLast, LPWSTR pszSrch)
 {
-    int len = lstrlen(pszSrch);
+    int len = lstrlenW(pszSrch);
     pszLast--;
     while (pszLast >= pszSource)
     {
-        if (StrCmpN(pszLast, pszSrch, len) == 0)
+        if (StrCmpNW(pszLast, pszSrch, len) == 0)
             return pszLast;
         pszLast--;
     }
@@ -376,7 +376,7 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr)
 {
     LPWSTR content;
     LPWSTR found;
-    int len = lstrlen(fr->lpstrFindWhat);
+    int len = lstrlenW(fr->lpstrFindWhat);
     int fileLen;
     DWORD pos;
 
@@ -389,16 +389,16 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr)
     switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
     {
         case 0:
-            found = StrRStrI(content, content+pos-len, fr->lpstrFindWhat);
+            found = StrRStrIW(content, content+pos-len, fr->lpstrFindWhat);
             break;
         case FR_DOWN:
-            found = StrStrI(content+pos, fr->lpstrFindWhat);
+            found = StrStrIW(content+pos, fr->lpstrFindWhat);
             break;
         case FR_MATCHCASE:
             found = NOTEPAD_StrRStr(content, content+pos-len, fr->lpstrFindWhat);
             break;
         case FR_DOWN|FR_MATCHCASE:
-            found = StrStr(content+pos, fr->lpstrFindWhat);
+            found = StrStrW(content+pos, fr->lpstrFindWhat);
             break;
         default:    /* shouldn't happen */
             return;
@@ -418,7 +418,7 @@ void NOTEPAD_DoFind(FINDREPLACEW *fr)
 static void NOTEPAD_DoReplace(FINDREPLACEW *fr)
 {
     LPWSTR content;
-    int len = lstrlen(fr->lpstrFindWhat);
+    int len = lstrlenW(fr->lpstrFindWhat);
     int fileLen;
     DWORD pos;
     DWORD pos_start;
@@ -432,11 +432,11 @@ static void NOTEPAD_DoReplace(FINDREPLACEW *fr)
     switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
     {
         case FR_DOWN:
-            if ( pos-pos_start == len && StrCmpNI(fr->lpstrFindWhat, content+pos_start, len) == 0)
+            if ( pos-pos_start == len && StrCmpNIW(fr->lpstrFindWhat, content+pos_start, len) == 0)
                 SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
             break;
         case FR_DOWN|FR_MATCHCASE:
-            if ( pos-pos_start == len && StrCmpN(fr->lpstrFindWhat, content+pos_start, len) == 0)
+            if ( pos-pos_start == len && StrCmpNW(fr->lpstrFindWhat, content+pos_start, len) == 0)
                 SendMessageW(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)fr->lpstrReplaceWith);
             break;
         default:    /* shouldn't happen */
@@ -451,7 +451,7 @@ static void NOTEPAD_DoReplaceAll(FINDREPLACEW *fr)
 {
     LPWSTR content;
     LPWSTR found;
-    int len = lstrlen(fr->lpstrFindWhat);
+    int len = lstrlenW(fr->lpstrFindWhat);
     int fileLen;
     DWORD pos;
 
@@ -466,10 +466,10 @@ static void NOTEPAD_DoReplaceAll(FINDREPLACEW *fr)
         switch (fr->Flags & (FR_DOWN|FR_MATCHCASE))
         {
             case FR_DOWN:
-                found = StrStrI(content+pos, fr->lpstrFindWhat);
+                found = StrStrIW(content+pos, fr->lpstrFindWhat);
                 break;
             case FR_DOWN|FR_MATCHCASE:
-                found = StrStr(content+pos, fr->lpstrFindWhat);
+                found = StrStrW(content+pos, fr->lpstrFindWhat);
                 break;
             default:    /* shouldn't happen */
                 return;
@@ -602,7 +602,7 @@ static int AlertFileDoesNotExist(LPCWSTR szFileName)
    WCHAR szResource[MAX_STRING_LEN];
 
    LoadString(Globals.hInstance, STRING_DOESNOTEXIST, szResource, SIZEOF(szResource));
-   wsprintf(szMessage, szResource, szFileName);
+   wsprintfW(szMessage, szResource, szFileName);
 
    LoadString(Globals.hInstance, STRING_ERROR, szResource, SIZEOF(szResource));
 
@@ -683,8 +683,8 @@ static void HandleCommandLine(LPWSTR cmdline)
             }
             else
             {
-                lstrcpyn(buf, cmdline, MAX_PATH - lstrlen(txtW) - 1);
-                lstrcat(buf, txtW);
+                lstrcpynW(buf, cmdline, MAX_PATH - lstrlenW(txtW) - 1);
+                lstrcatW(buf, txtW);
                 file_name = buf;
                 file_exists = FileExists(buf);
             }
-- 
1.6.0.6



More information about the wine-patches mailing list