aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/qpdf/QUtil.hh4
-rw-r--r--libqpdf/QUtil.cc8
-rw-r--r--qpdf/qpdf.cc2
-rw-r--r--qpdf/test_driver.cc2
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];