OS/2: Fix bug in buffered read where buffer control variables were left in
an inconsistent state after a 0 length read (EOF). The amount of data in
the buffer (dataRead) was being reset but the current position within the
buffer (bufpos) was not. This changes it so that dataRead is not reset,
allowing the buffer contents to be reused after a seek.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62238 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/file_io/os2/readwrite.c b/file_io/os2/readwrite.c
index 4e4ce04..d2cea2e 100644
--- a/file_io/os2/readwrite.c
+++ b/file_io/os2/readwrite.c
@@ -88,12 +88,17 @@
while (rc == 0 && size > 0) {
if (thefile->bufpos >= thefile->dataRead) {
- rc = DosRead(thefile->filedes, thefile->buffer, APR_FILE_BUFSIZE, &thefile->dataRead );
- if (thefile->dataRead == 0) {
+ ULONG bytesread;
+ rc = DosRead(thefile->filedes, thefile->buffer,
+ APR_FILE_BUFSIZE, &bytesread);
+
+ if (bytesread == 0) {
if (rc == 0)
thefile->eof_hit = TRUE;
break;
}
+
+ thefile->dataRead = bytesread;
thefile->filePtr += thefile->dataRead;
thefile->bufpos = 0;
}