From d7b8b8b1f03ca870be0a778a958d06bffc813dc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Pinard?= Date: Sat, 23 Feb 2008 13:34:53 -0500 Subject: [PATCH] testdump output via subtask --- src/ChangeLog | 5 +++++ src/testdump.c | 41 ++++++++++++++++++++++++++++------------- tests/t40_testdump.py | 4 ---- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6187c0f..4e38ee7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-02-23 François Pinard + + * testdump.c (produce_count, produce_full_dump): Output as directed + by the subtask, rather than directly on stdout. + 2008-02-22 François Pinard Repair all Flex steps, which were broken since version 3.6. diff --git a/src/testdump.c b/src/testdump.c index 424b7b1..2f46742 100644 --- a/src/testdump.c +++ b/src/testdump.c @@ -144,6 +144,15 @@ compare_item (const void *void_first, const void *void_second) return (*first)->code - (*second)->code; } +static void +put_string (const char *string, RECODE_SUBTASK subtask) +{ + const char *cursor; + + for (cursor = string; *cursor; cursor++) + put_byte (*cursor, subtask); +} + static bool produce_count (RECODE_SUBTASK subtask) { @@ -229,22 +238,23 @@ produce_count (RECODE_SUBTASK subtask) if (column + count_width + non_count_width > 80) { - putchar ('\n'); + put_byte ('\n', subtask); delayed = 0; column = 0; } else while (delayed) { - putchar (' '); + put_byte (' ', subtask); delayed--; } - printf ("%*d %.4X", count_width, (*cursor)->count, character); + sprintf (buffer, "%*d %.4X", count_width, (*cursor)->count, character); + put_string (buffer, subtask); if (mnemonic) { - putchar (' '); - fputs (mnemonic, stdout); + put_byte (' ', subtask); + put_string (mnemonic, subtask); delayed = 6 - 1 - strlen (mnemonic); } else @@ -254,7 +264,7 @@ produce_count (RECODE_SUBTASK subtask) } if (column) - putchar ('\n'); + put_byte ('\n', subtask); } /* Clean-up. */ @@ -281,6 +291,7 @@ produce_full_dump (RECODE_SUBTASK subtask) const char *charname; /* charname for code */ bool french; /* if output should be in French */ const char *string; /* environment value */ + char buffer[50]; /* Decide if we prefer French or English output. */ @@ -295,17 +306,21 @@ produce_full_dump (RECODE_SUBTASK subtask) french = true; } - fputs (_("UCS2 Mne Description\n\n"), stdout); + put_string (_("UCS2 Mne Description\n\n"), subtask); while (1) { const char *mnemonic = ucs2_to_rfc1345 (character); - printf ("%.4X", character); + sprintf (buffer, "%.4X", character); + put_string (buffer, subtask); if (mnemonic) - printf (" %-3s", mnemonic); + { + sprintf (buffer, " %-3s", mnemonic); + put_string (buffer, subtask); + } else - fputs (" ", stdout); + put_string (" ", subtask); if (french) { @@ -322,10 +337,10 @@ produce_full_dump (RECODE_SUBTASK subtask) if (charname) { - fputs (" ", stdout); - fputs (charname, stdout); + put_string (" ", subtask); + put_string (charname, subtask); } - printf ("\n"); + put_byte ('\n', subtask); if (!get_ucs2 (&character, subtask)) break; diff --git a/tests/t40_testdump.py b/tests/t40_testdump.py index cac7304..21da2b6 100644 --- a/tests/t40_testdump.py +++ b/tests/t40_testdump.py @@ -16,7 +16,6 @@ class Test_test7: ''' def test_1(self): - common.external(True) common.request('test7..x,us..count') common.validate('', self.output) @@ -30,7 +29,6 @@ class Test_test8: ''' def test_1(self): - common.external(True) common.request('test8..x,us..count') common.validate('', self.output) @@ -45,7 +43,6 @@ class Test_test15: ''' def test_1(self): - common.external(True) common.request('test15..x2,us..count') common.validate('', self.output) @@ -60,6 +57,5 @@ class Test_test16: ''' def test_1(self): - common.external(True) common.request('test16..x2,us..count') common.validate('', self.output) -- 2.40.0