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