Author: cfinck
Date: Sat Jan 17 13:58:18 2009
New Revision: 38840
URL:
http://svn.reactos.org/svn/reactos?rev=38840&view=rev
Log:
Convert all line-endings to LF first in StringOut before passing the strings to printf and
OutputDebugStringA.
Both functions treat the string as text and convert the line-endings themselves to CRLF.
If you already give them a CRLF line-ending, it'll be converted to CRCRLF..
By unifying the line-endings in StringOut, it is also possible now to pass both LF and
CRLF to the function.
This should fix the empty lines in the BuildBot log.
Thanks to Christoph for the help!
Modified:
trunk/rostests/rosautotest/tools.c
Modified: trunk/rostests/rosautotest/tools.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/rosautotest/tools.c?rev=3…
==============================================================================
--- trunk/rostests/rosautotest/tools.c [iso-8859-1] (original)
+++ trunk/rostests/rosautotest/tools.c [iso-8859-1] Sat Jan 17 13:58:18 2009
@@ -38,13 +38,15 @@
*Output++ = HexCharacters[((UCHAR)*Input >> 4) % 16];
*Output++ = HexCharacters[(UCHAR)*Input % 16];
}
- } while(*++Input);
+ }
+ while(*++Input);
*Output = 0;
}
/**
* Outputs a string through the standard output and the debug output.
+ * The string may have LF or CRLF line endings.
*
* @param String
* The string to output
@@ -52,6 +54,41 @@
VOID
StringOut(PCHAR String)
{
- printf(String);
- OutputDebugStringA(String);
+ PCHAR NewString;
+ PCHAR pNewString;
+ size_t Length;
+
+ /* The piped output of the tests may use CRLF line endings, so convert them to LF.
+ As both printf and OutputDebugStringA operate in text mode, the line-endings will
be properly converted again later. */
+ Length = strlen(String);
+ NewString = HeapAlloc(hProcessHeap, 0, Length + 1);
+ pNewString = NewString;
+
+ do
+ {
+ /* If this is a CRLF line-ending, only copy a \n to the new string and skip the
next character */
+ if(*String == '\r' && *(String + 1) == '\n')
+ {
+ *pNewString = '\n';
+ ++String;
+ }
+ else
+ {
+ /* Otherwise copy the string */
+ *pNewString = *String;
+ }
+
+ ++pNewString;
+ }
+ while(*++String);
+
+ /* Null-terminate it */
+ *pNewString = 0;
+
+ /* Output it */
+ printf(NewString);
+ OutputDebugStringA(NewString);
+
+ /* Cleanup */
+ HeapFree(hProcessHeap, 0, NewString);
}