From f5d772773e588403bea8b5401f5e305b97dea16f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 21 Oct 2009 02:30:15 +0000 Subject: make line buffering os-specific git-svn-id: svn+q:///qpdf/trunk@852 71b93d88-0707-0410-a8cf-f5a4172ac649 --- include/qpdf/QUtil.hh | 4 ++++ libqpdf/QUtil.cc | 8 ++++++++ qpdf/qpdf.cc | 2 +- qpdf/test_driver.cc | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index 45dc9c5b..d0626a2e 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -52,6 +52,10 @@ namespace QUtil void binary_stdout(); QPDF_DLL void binary_stdin(); + // Set stdout to line buffered + QPDF_DLL + void setLineBuf(FILE*); + // May modify argv0 QPDF_DLL diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index bc81ce57..1bdae0fe 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -127,6 +127,14 @@ QUtil::binary_stdin() #endif } +void +QUtil::setLineBuf(FILE* f) +{ +#ifndef _WIN32 + setvbuf(f, (char *) NULL, _IOLBF, 0); +#endif +} + char* QUtil::getWhoami(char* argv0) { diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index f9af8609..431f6dab 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -534,7 +534,7 @@ parse_encrypt_options( int main(int argc, char* argv[]) { whoami = QUtil::getWhoami(argv[0]); - setvbuf(stdout, (char *) NULL, _IOLBF, 0); + QUtil::setLineBuf(stdout); // For libtool's sake.... if (strncmp(whoami, "lt-", 3) == 0) diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 68866b54..f4998913 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -320,7 +320,7 @@ void runtest(int n, char const* filename) int main(int argc, char* argv[]) { - setvbuf(stdout, (char *) NULL, _IOLBF, 0); + QUtil::setLineBuf(stdout); if ((whoami = strrchr(argv[0], '/')) == NULL) { whoami = argv[0]; -- cgit v1.2.3-54-g00ecf