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
df834692
Commit
df834692
authored
Apr 18, 2010
by
Andrew Nguyen
Committed by
Alexandre Julliard
Apr 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Separate format string parsing in FormatMessageW into a new function.
parent
fcdd0d30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
98 deletions
+111
-98
format_msg.c
dlls/kernel32/format_msg.c
+111
-98
No files found.
dlls/kernel32/format_msg.c
View file @
df834692
...
...
@@ -404,6 +404,115 @@ static LPCWSTR format_insertW( int insert, LPCWSTR format, DWORD flags,
return
format
;
}
/**********************************************************************
* format_messageW (internal)
*/
static
LPWSTR
format_messageW
(
DWORD
dwFlags
,
LPCWSTR
fmtstr
,
struct
format_args
*
format_args
)
{
LPWSTR
target
,
t
;
DWORD
talloced
;
LPCWSTR
f
;
DWORD
width
=
dwFlags
&
FORMAT_MESSAGE_MAX_WIDTH_MASK
;
BOOL
eos
=
FALSE
;
WCHAR
ch
;
target
=
t
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
100
*
sizeof
(
WCHAR
)
);
talloced
=
100
;
#define ADD_TO_T(c) do {\
*t++=c;\
if ((DWORD)(t-target) == talloced) {\
target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2*sizeof(WCHAR));\
t = target+talloced;\
talloced*=2;\
} \
} while (0)
f
=
fmtstr
;
if
(
dwFlags
&
FORMAT_MESSAGE_IGNORE_INSERTS
)
{
while
(
*
f
&&
!
eos
)
ADD_TO_T
(
*
f
++
);
}
else
{
while
(
*
f
&&
!
eos
)
{
if
(
*
f
==
'%'
)
{
int
insertnr
;
WCHAR
*
str
,
*
x
;
f
++
;
if
(
!*
f
)
{
ADD_TO_T
(
'%'
);
continue
;
}
switch
(
*
f
)
{
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
insertnr
=
*
f
-
'0'
;
switch
(
f
[
1
])
{
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
f
++
;
insertnr
=
insertnr
*
10
+
*
f
-
'0'
;
f
++
;
break
;
default:
f
++
;
break
;
}
f
=
format_insertW
(
insertnr
,
f
,
dwFlags
,
format_args
,
&
str
);
for
(
x
=
str
;
*
x
;
x
++
)
ADD_TO_T
(
*
x
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
break
;
case
'n'
:
ADD_TO_T
(
'\r'
);
ADD_TO_T
(
'\n'
);
f
++
;
break
;
case
'0'
:
eos
=
TRUE
;
f
++
;
break
;
default:
ADD_TO_T
(
*
f
++
);
break
;
}
}
else
{
ch
=
*
f
;
f
++
;
if
(
ch
==
'\r'
)
{
if
(
*
f
==
'\n'
)
f
++
;
if
(
width
)
ADD_TO_T
(
' '
);
else
{
ADD_TO_T
(
'\r'
);
ADD_TO_T
(
'\n'
);
}
}
else
{
if
(
ch
==
'\n'
)
{
if
(
width
)
ADD_TO_T
(
' '
);
else
{
ADD_TO_T
(
'\r'
);
ADD_TO_T
(
'\n'
);
}
}
else
ADD_TO_T
(
ch
);
}
}
}
}
*
t
=
'\0'
;
return
target
;
}
#undef ADD_TO_T
/***********************************************************************
* FormatMessageA (KERNEL32.@)
...
...
@@ -603,13 +712,10 @@ DWORD WINAPI FormatMessageW(
{
struct
format_args
format_args
;
DWORD
ret
=
0
;
LPWSTR
target
,
t
;
LPWSTR
target
;
DWORD
talloced
;
LPWSTR
from
;
LPCWSTR
f
;
DWORD
width
=
dwFlags
&
FORMAT_MESSAGE_MAX_WIDTH_MASK
;
BOOL
eos
=
FALSE
;
WCHAR
ch
;
TRACE
(
"(0x%x,%p,%d,0x%x,%p,%d,%p)
\n
"
,
dwFlags
,
lpSource
,
dwMessageId
,
dwLanguageId
,
lpBuffer
,
nSize
,
args
);
...
...
@@ -652,102 +758,9 @@ DWORD WINAPI FormatMessageW(
from
=
load_messageW
(
kernel32_handle
,
dwMessageId
,
dwLanguageId
);
if
(
!
from
)
return
0
;
}
target
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
100
*
sizeof
(
WCHAR
)
);
t
=
target
;
talloced
=
100
;
#define ADD_TO_T(c) do {\
*t++=c;\
if ((DWORD)(t-target) == talloced) {\
target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,talloced*2*sizeof(WCHAR));\
t = target+talloced;\
talloced*=2;\
} \
} while (0)
if
(
from
)
{
f
=
from
;
if
(
dwFlags
&
FORMAT_MESSAGE_IGNORE_INSERTS
)
{
while
(
*
f
&&
!
eos
)
ADD_TO_T
(
*
f
++
);
}
else
{
while
(
*
f
&&
!
eos
)
{
if
(
*
f
==
'%'
)
{
int
insertnr
;
WCHAR
*
str
,
*
x
;
f
++
;
if
(
!*
f
)
{
ADD_TO_T
(
'%'
);
continue
;
}
target
=
format_messageW
(
dwFlags
,
from
,
&
format_args
);
switch
(
*
f
)
{
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
insertnr
=*
f
-
'0'
;
switch
(
f
[
1
])
{
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
f
++
;
insertnr
=
insertnr
*
10
+*
f
-
'0'
;
f
++
;
break
;
default:
f
++
;
break
;
}
f
=
format_insertW
(
insertnr
,
f
,
dwFlags
,
&
format_args
,
&
str
);
for
(
x
=
str
;
*
x
;
x
++
)
ADD_TO_T
(
*
x
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
break
;
case
'n'
:
ADD_TO_T
(
'\r'
);
ADD_TO_T
(
'\n'
);
f
++
;
break
;
case
'0'
:
eos
=
TRUE
;
f
++
;
break
;
default:
ADD_TO_T
(
*
f
++
);
break
;
}
}
else
{
ch
=
*
f
;
f
++
;
if
(
ch
==
'\r'
)
{
if
(
*
f
==
'\n'
)
f
++
;
if
(
width
)
ADD_TO_T
(
' '
);
else
{
ADD_TO_T
(
'\r'
);
ADD_TO_T
(
'\n'
);
}
}
else
{
if
(
ch
==
'\n'
)
{
if
(
width
)
ADD_TO_T
(
' '
);
else
{
ADD_TO_T
(
'\r'
);
ADD_TO_T
(
'\n'
);
}
}
else
ADD_TO_T
(
ch
);
}
}
}
}
*
t
=
'\0'
;
}
talloced
=
strlenW
(
target
)
+
1
;
TRACE
(
"-- %s
\n
"
,
debugstr_w
(
target
));
if
(
dwFlags
&
FORMAT_MESSAGE_ALLOCATE_BUFFER
)
{
...
...
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