make line buffering os-specific

git-svn-id: svn+q:///qpdf/trunk@852 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
Jay Berkenbilt 2009-10-21 02:30:15 +00:00
parent 27ee889c0e
commit f5d772773e
4 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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)

View File

@ -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];