Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1a60da74
Commit
1a60da74
authored
May 07, 2009
by
Michael Stefaniuc
Committed by
Alexandre Julliard
May 08, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notepad: Use the explicit W-form for some string functions.
parent
717ac52d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
39 deletions
+39
-39
dialog.c
programs/notepad/dialog.c
+9
-9
main.c
programs/notepad/main.c
+30
-30
No files found.
programs/notepad/dialog.c
View file @
1a60da74
...
...
@@ -68,13 +68,13 @@ static void UpdateWindowCaption(void)
static
const
WCHAR
hyphenW
[]
=
{
' '
,
'-'
,
' '
,
0
};
if
(
Globals
.
szFileTitle
[
0
]
!=
'\0'
)
lstrcpy
(
szCaption
,
Globals
.
szFileTitle
);
lstrcpy
W
(
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
);
lstrcat
W
(
szCaption
,
hyphenW
);
lstrcat
W
(
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
);
wnsprintf
W
(
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
]))
&&
!
lstrcmp
W
(
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
);
lstrcpy
W
(
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
);
lstrcpy
W
(
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
);
GetTextExtentPoint32
W
(
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
,
lstrlen
W
(
text
),
NULL
);
return
1
;
}
return
0
;
...
...
programs/notepad/main.c
View file @
1a60da74
...
...
@@ -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
);
lstrcpy
W
(
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
]));
lstrlen
W
(
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
]));
lstrlen
W
(
Globals
.
szHeader
)
*
sizeof
(
Globals
.
szHeader
[
0
]));
RegSetValueEx
(
hkey
,
value_szFooter
,
0
,
REG_SZ
,
(
LPBYTE
)
&
Globals
.
szFooter
,
lstrlen
(
Globals
.
szFooter
)
*
sizeof
(
Globals
.
szFooter
[
0
]));
lstrlen
W
(
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
);
lstrcpy
W
(
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
);
lstrcpy
W
(
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
);
lstrcpy
W
(
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
);
lstrcpy
W
(
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
+=
lstrlen
W
(
p
)
+
1
;
lstrcpy
W
(
p
,
txt_files
);
p
+=
lstrlen
W
(
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
+=
lstrlen
W
(
p
)
+
1
;
lstrcpy
W
(
p
,
all_files
);
p
+=
lstrlen
W
(
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
=
lstrlen
W
(
pszSrch
);
pszLast
--
;
while
(
pszLast
>=
pszSource
)
{
if
(
StrCmpN
(
pszLast
,
pszSrch
,
len
)
==
0
)
if
(
StrCmpN
W
(
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
=
lstrlen
W
(
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
=
StrRStrI
W
(
content
,
content
+
pos
-
len
,
fr
->
lpstrFindWhat
);
break
;
case
FR_DOWN
:
found
=
StrStrI
(
content
+
pos
,
fr
->
lpstrFindWhat
);
found
=
StrStrI
W
(
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
=
StrStr
W
(
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
=
lstrlen
W
(
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
&&
StrCmpNI
W
(
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
&&
StrCmpN
W
(
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
=
lstrlen
W
(
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
=
StrStrI
W
(
content
+
pos
,
fr
->
lpstrFindWhat
);
break
;
case
FR_DOWN
|
FR_MATCHCASE
:
found
=
StrStr
(
content
+
pos
,
fr
->
lpstrFindWhat
);
found
=
StrStr
W
(
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
);
wsprintf
W
(
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
);
lstrcpyn
W
(
buf
,
cmdline
,
MAX_PATH
-
lstrlenW
(
txtW
)
-
1
);
lstrcat
W
(
buf
,
txtW
);
file_name
=
buf
;
file_exists
=
FileExists
(
buf
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment