From 9d9116831508c6c9cd81c32834701af14b7647a4 Mon Sep 17 00:00:00 2001 From: Nick Ing-Simmons Date: Wed, 22 Jan 2003 08:32:59 +0000 Subject: [PATCH] Tweak APItest for new semantics of printf. Now printf() is always real printf() and not #define'd to PerlIO_stdoutf() so PerlIO_flush() when STDOUT is redirected back to original file does not affect stdout unless we are using :stdio as implementation. So things printf()ed XS side are not written to file (and turn up at end of test). So add an XS function which does fflush(stdout), modify .pm file to export it and .t file to call it. p4raw-id: //depot/perlio@18547 --- ext/XS/APItest/APItest.pm | 4 ++-- ext/XS/APItest/APItest.xs | 5 +++++ ext/XS/APItest/t/printf.t | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ext/XS/APItest/APItest.pm b/ext/XS/APItest/APItest.pm index bd8463b..581fa38 100644 --- a/ext/XS/APItest/APItest.pm +++ b/ext/XS/APItest/APItest.pm @@ -13,10 +13,10 @@ use base qw/ DynaLoader Exporter /; # Export everything since these functions are only used by a test script our @EXPORT = qw( print_double print_int print_long - print_float print_long_double have_long_double + print_float print_long_double have_long_double print_flush ); -our $VERSION = '0.01'; +our $VERSION = '0.02'; bootstrap XS::APItest $VERSION; diff --git a/ext/XS/APItest/APItest.xs b/ext/XS/APItest/APItest.xs index d5c6b52..b141252 100644 --- a/ext/XS/APItest/APItest.xs +++ b/ext/XS/APItest/APItest.xs @@ -53,3 +53,8 @@ print_float(val) float val CODE: printf("%5.3f\n",val); + +void +print_flush() + CODE: + fflush(stdout); diff --git a/ext/XS/APItest/t/printf.t b/ext/XS/APItest/t/printf.t index 91f328c..ef2769e 100644 --- a/ext/XS/APItest/t/printf.t +++ b/ext/XS/APItest/t/printf.t @@ -33,10 +33,12 @@ print_long(4); print_float(4); print_long_double() if $ldok; # val=7 hardwired +print_flush(); + # Now redirect STDOUT and read from the file ok open(STDOUT, ">&", $oldout), "restore STDOUT"; ok open(my $foo, "; close $foo; -- 1.8.3.1