- Replace a 'for' with a 'do .. while '

- Make sure OutputDebugStringA terminates with a newline
Fixes winetest debug output. I wonder how it worked before. Dedicated to Stefan100.

svn path=/trunk/; revision=38087
This commit is contained in:
Timo Kreuzer 2008-12-14 23:18:59 +00:00
parent 39324400b9
commit 2f3c5f280b

View file

@ -326,17 +326,10 @@ OutputDebugStringA(LPCSTR _OutputString)
/* size of the remainder of the string */ /* size of the remainder of the string */
SIZE_T nOutputStringLen; SIZE_T nOutputStringLen;
for
(
/* output the whole string */ /* output the whole string */
nOutputStringLen = strlen(_OutputString); nOutputStringLen = strlen(_OutputString);
/* repeat until the string has been fully output */ do
nOutputStringLen > 0;
/* move to the next block */
_OutputString += nRoundLen, nOutputStringLen -= nRoundLen
)
{ {
/* we're connected to the debug monitor: /* we're connected to the debug monitor:
write the current block to the shared buffer */ write the current block to the shared buffer */
@ -375,21 +368,40 @@ OutputDebugStringA(LPCSTR _OutputString)
CHAR a_cBuffer[512]; CHAR a_cBuffer[512];
/* write a maximum of 511 bytes */ /* write a maximum of 511 bytes */
if(nOutputStringLen > (sizeof(a_cBuffer) - 1)) if(nOutputStringLen > (sizeof(a_cBuffer) - 2))
nRoundLen = sizeof(a_cBuffer) - 1; nRoundLen = sizeof(a_cBuffer) - 2;
else else
nRoundLen = nOutputStringLen; nRoundLen = nOutputStringLen;
/* copy the current block */ /* copy the current block */
memcpy(a_cBuffer, _OutputString, nRoundLen); memcpy(a_cBuffer, _OutputString, nRoundLen);
/* Have we reached the end of the string? */
if (nRoundLen == nOutputStringLen)
{
/* Make sure we terminate with a line break */
if (a_cBuffer[nRoundLen - 1] != '\n')
{
a_cBuffer[nRoundLen] = '\n';
nRoundLen++;
nOutputStringLen++;
}
}
/* null-terminate the current block */ /* null-terminate the current block */
a_cBuffer[nRoundLen] = 0; a_cBuffer[nRoundLen] = 0;
/* send the current block to the kernel debugger */ /* send the current block to the kernel debugger */
DbgPrint("%s", a_cBuffer); DbgPrint("%s", a_cBuffer);
} }
/* move to the next block */
_OutputString += nRoundLen;
nOutputStringLen -= nRoundLen;
} }
/* repeat until the string has been fully output */
while (nOutputStringLen > 0);
} }
#if 0 #if 0
/* ignore access violations and let other exceptions fall through */ /* ignore access violations and let other exceptions fall through */