Add tests for the flag FORMAT_MESSAGE_IGNORE_INSERTS, and act

accordingly.
This commit is contained in:
Duane Clark 2001-05-09 19:43:51 +00:00 committed by Alexandre Julliard
parent 32ee168200
commit 8a3f6285c7
1 changed files with 392 additions and 379 deletions

View File

@ -140,8 +140,8 @@ DWORD WINAPI FormatMessageA(
DWORD dwLanguageId,
LPSTR lpBuffer,
DWORD nSize,
va_list* _args
) {
va_list* _args )
{
LPDWORD args=(LPDWORD)_args;
#ifdef __i386__
/* This implementation is completely dependant on the format of the va_list on x86 CPUs */
@ -210,6 +210,11 @@ DWORD WINAPI FormatMessageA(
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;
@ -251,11 +256,12 @@ DWORD WINAPI FormatMessageA(
sprintf(fmtstr,"%%%s",f);
f+=strlen(f); /*at \0*/
}
} else
} else {
if(!args)
break;
else
fmtstr=HEAP_strdupA(GetProcessHeap(),0,"%s");
}
if (args) {
int sz;
LPSTR b;
@ -273,6 +279,7 @@ DWORD WINAPI FormatMessageA(
} else {
b = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz = 100);
/* CMF - This makes a BIG assumption about va_list */
TRACE("A BIG assumption\n");
while (vsnprintf(b, sz, fmtstr, (va_list) argliststart) < 0) {
b = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, b, sz += 100);
}
@ -306,13 +313,11 @@ DWORD WINAPI FormatMessageA(
} else {
ch = *f;
f++;
if (ch == '\r')
{
if (ch == '\r') {
if (*f == '\n')
f++;
ADD_TO_T(' ');
}
else
} else {
if (ch == '\n')
{
ADD_TO_T('\r');
@ -322,6 +327,8 @@ DWORD WINAPI FormatMessageA(
ADD_TO_T(ch);
}
}
}
}
*t='\0';
}
talloced = strlen(target)+1;
@ -358,8 +365,8 @@ DWORD WINAPI FormatMessageW(
DWORD dwLanguageId,
LPWSTR lpBuffer,
DWORD nSize,
va_list* _args
) {
va_list* _args )
{
LPDWORD args=(LPDWORD)_args;
#ifdef __i386__
/* This implementation is completely dependant on the format of the va_list on x86 CPUs */
@ -428,6 +435,11 @@ DWORD WINAPI FormatMessageW(
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;
@ -440,6 +452,7 @@ DWORD WINAPI FormatMessageW(
ADD_TO_T('%');
continue;
}
switch (*f) {
case '1':case '2':case '3':case '4':case '5':
case '6':case '7':case '8':case '9':
@ -458,8 +471,7 @@ DWORD WINAPI FormatMessageW(
}
if (*f=='!') {
f++;
if (NULL!=(x=strchr(f,'!')))
{
if (NULL!=(x=strchr(f,'!'))) {
*x='\0';
fmtstr=HeapAlloc( GetProcessHeap(), 0, strlen(f)+2);
sprintf(fmtstr,"%%%s",f);
@ -469,11 +481,12 @@ DWORD WINAPI FormatMessageW(
sprintf(fmtstr,"%%%s",f);
f+=strlen(f); /*at \0*/
}
} else
} else {
if(!args)
break;
else
fmtstr=HEAP_strdupA( GetProcessHeap(),0,"%s");
}
if (dwFlags & FORMAT_MESSAGE_ARGUMENT_ARRAY)
argliststart=args+insertnr-1;
else
@ -519,13 +532,11 @@ DWORD WINAPI FormatMessageW(
} else {
ch = *f;
f++;
if (ch == '\r')
{
if (ch == '\r') {
if (*f == '\n')
f++;
ADD_TO_T(' ');
}
else
} else {
if (ch == '\n')
{
ADD_TO_T('\r');
@ -535,6 +546,8 @@ DWORD WINAPI FormatMessageW(
ADD_TO_T(ch);
}
}
}
}
*t='\0';
}
talloced = strlen(target)+1;