From 8d7a27547ff1c7ec4c7c773d2d90af88354b8ad3 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 2 Dec 2004 00:02:54 +0000 Subject: [PATCH] better fix for irix istream --- dtool/src/prc/configPage.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index 47bc2351d8..1f9e219d1f 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -148,7 +148,7 @@ read_prc(istream &in) { in.read(buffer, buffer_size); size_t count = in.gcount(); - while (count != 0 && !in.fail() && !in.eof()) { + while (count != 0) { char *buffer_end = buffer + count; // Look for the first line in the buffer.. @@ -178,8 +178,16 @@ read_prc(istream &in) { prev_line = string(start, length); } - in.read(buffer, buffer_size); - count = in.gcount(); + if (in.fail() || in.eof()) { + // If we got a failure reading the buffer last time, don't keep + // reading again. Irix seems to require this test; otherwise, + // it repeatedly returns the same text at the end of the file. + count = 0; + + } else { + in.read(buffer, buffer_size); + count = in.gcount(); + } } if (!prev_line.empty()) {