[PATCH 5/6] [WineTest] Replaced unix stdio calls with direct kernel32 ones
Eric Pouech
eric.pouech at orange.fr
Fri Nov 4 15:14:28 CDT 2011
#28191
A+
---
programs/winetest/gui.c | 29 ++++++++++-------------------
programs/winetest/main.c | 6 +++---
programs/winetest/util.c | 27 ++++++++++++++++++++++-----
programs/winetest/winetest.h | 1 +
4 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/programs/winetest/gui.c b/programs/winetest/gui.c
index a9f3465..97a2e86 100644
--- a/programs/winetest/gui.c
+++ b/programs/winetest/gui.c
@@ -64,8 +64,7 @@ textStatus (va_list ap)
{
char *str = vstrmake (NULL, ap);
- fputs (str, stderr);
- fputc ('\n', stderr);
+ xprintf_stderr("%s\n", str);
heap_free (str);
return 0;
}
@@ -119,8 +118,7 @@ textStep (va_list ap)
char *str = vstrmake (NULL, ap);
progressCurr++;
- fputs (str, stderr);
- fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
+ xprintf_stderr("%s (%d of %d)\n", str, progressCurr, progressMax);
heap_free (str);
return 0;
}
@@ -147,8 +145,7 @@ textDelta (va_list ap)
char *str = vstrmake (NULL, ap);
progressCurr += inc;
- fputs (str, stderr);
- fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
+ xprintf_stderr ("%s (%d of %d)\n", str, progressCurr, progressMax);
heap_free (str);
return 0;
}
@@ -172,9 +169,7 @@ guiDelta (va_list ap)
static int
textTag (va_list ap)
{
- fputs ("Tag: ", stderr);
- fputs (tag, stderr);
- fputc ('\n', stderr);
+ xprintf_stderr ("Tag: %s\n", tag);
return 0;
}
@@ -191,9 +186,7 @@ textDir (va_list ap)
{
char *str = vstrmake (NULL, ap);
- fputs ("Temporary directory: ", stderr);
- fputs (str, stderr);
- fputc ('\n', stderr);
+ xprintf_stderr ("Temporary directory: %s\n", str);
heap_free (str);
return 0;
}
@@ -214,9 +207,7 @@ textOut (va_list ap)
{
char *str = vstrmake (NULL, ap);
- fputs ("Log file: ", stderr);
- fputs (str, stderr);
- fputc ('\n', stderr);
+ xprintf_stderr ("Log file: %s\n", str);
heap_free (str);
return 0;
}
@@ -235,7 +226,7 @@ guiOut (va_list ap)
static int
textWarning (va_list ap)
{
- fputs ("Warning: ", stderr);
+ xprintf_stderr ("Warning: ");
textStatus (ap);
return 0;
}
@@ -254,7 +245,7 @@ guiWarning (va_list ap)
static int
textError (va_list ap)
{
- fputs ("Error: ", stderr);
+ xprintf_stderr ("Error: ");
textStatus (ap);
return 0;
}
@@ -292,8 +283,8 @@ textAsk (va_list ap)
int ret = MBdefault (uType);
char *str = vstrmake (NULL, ap);
- fprintf (stderr, "Question of type %d: %s\n"
- "Returning default: %d\n", uType, str, ret);
+ xprintf_stderr ("Question of type %d: %s\n"
+ "Returning default: %d\n", uType, str, ret);
heap_free (str);
return ret;
}
diff --git a/programs/winetest/main.c b/programs/winetest/main.c
index 3f6dd6b..e3f95b3 100644
--- a/programs/winetest/main.c
+++ b/programs/winetest/main.c
@@ -1085,7 +1085,7 @@ run_tests (char *logname, char *outdir)
static BOOL WINAPI ctrl_handler(DWORD ctrl_type)
{
if (ctrl_type == CTRL_C_EVENT) {
- printf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
+ xprintf("Ignoring Ctrl-C, use Ctrl-Break if you really want to terminate\n");
return TRUE;
}
@@ -1137,7 +1137,7 @@ static void extract_only (const char *target_dir)
static void
usage (void)
{
- fprintf (stderr,
+ xprintf_stderr(
"Usage: winetest [OPTION]... [TESTS]\n\n"
" --help print this message and exit\n"
" --version print the build version and exit\n"
@@ -1180,7 +1180,7 @@ int main( int argc, char *argv[] )
exit (0);
}
else if (!strcmp(argv[i], "--version")) {
- printf("%-12.12s\n", build_id[0] ? build_id : "unknown");
+ xprintf("%-12.12s\n", build_id[0] ? build_id : "unknown");
exit (0);
}
else if ((argv[i][0] != '-' && argv[i][0] != '/') || argv[i][2]) {
diff --git a/programs/winetest/util.c b/programs/winetest/util.c
index d0776ea..3b308a0 100644
--- a/programs/winetest/util.c
+++ b/programs/winetest/util.c
@@ -101,19 +101,16 @@ char *strmake (size_t *lenp, ...)
return p;
}
-void xprintf (const char *fmt, ...)
+static void printf_internal (HANDLE out, const char *fmt, va_list ap)
{
- va_list ap;
size_t size;
DWORD written;
char *buffer, *head;
- va_start (ap, fmt);
buffer = vstrfmtmake (&size, fmt, ap);
head = buffer;
- va_end (ap);
while (size) {
- if (!WriteFile( logfile, head, size, &written, NULL ))
+ if (!WriteFile( out, head, size, &written, NULL ))
report (R_FATAL, "Can't write logs: %u", GetLastError());
head += written;
size -= written;
@@ -121,6 +118,24 @@ void xprintf (const char *fmt, ...)
heap_free (buffer);
}
+void xprintf (const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ printf_internal (logfile, fmt, ap);
+ va_end (ap);
+}
+
+void xprintf_stderr(const char* format, ...)
+{
+ va_list va;
+
+ va_start(va, format);
+ printf_internal(GetStdHandle(STD_ERROR_HANDLE), format, va);
+ va_end(va);
+}
+
int
goodtagchar (char c)
{
@@ -138,3 +153,5 @@ findbadtagchar (const char *tag)
else return tag;
return NULL;
}
+
+
diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h
index 2b9046c..77198cf 100644
--- a/programs/winetest/winetest.h
+++ b/programs/winetest/winetest.h
@@ -29,6 +29,7 @@
void fatal (const char* msg);
void warning (const char* msg);
void xprintf (const char *fmt, ...);
+void xprintf_stderr (const char* fmt, ...);
char *vstrmake (size_t *lenp, va_list ap);
char *strmake (size_t *lenp, ...);
int goodtagchar (char c);
More information about the wine-patches
mailing list