httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/win32 readwrite.c
Date Sat, 17 Jun 2000 21:14:10 GMT
trawick     00/06/17 14:14:10

  Modified:    src/lib/apr/file_io/win32 readwrite.c
  Log:
  Win32 changes to ap_read() and ap_fgets():
  
  . ap_read() wasn't checking for *nbytes <= 0 on entry; it now handles
    it like the Unix code
  
  . the buffering logic in ap_read() started "while (lasterror == 0..."
    but didn't initialize lasterror
  
  . ap_read() returns APR_EOF if it hits eof before giving the caller any
    data
  
  . if ap_read() hits an error after reading data, error reporting is
    deferred to the next call
  
  . ap_fgets() clobbered the '\n'
  
  Revision  Changes    Path
  1.38      +23 -5     apache-2.0/src/lib/apr/file_io/win32/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- readwrite.c	2000/06/17 17:04:17	1.37
  +++ readwrite.c	2000/06/17 21:14:09	1.38
  @@ -67,6 +67,11 @@
       DWORD bread;
       int lasterror;
   
  +    if (*nbytes <= 0) {
  +        *nbytes = 0;
  +        return APR_SUCCESS;
  +    }
  +
       if (thefile->buffered) {
           char *pos = (char *)buf;
           ULONG blocksize;
  @@ -81,13 +86,16 @@
               thefile->dataRead = 0;
           }
   
  +        lasterror = 0;
           while (lasterror == 0 && size > 0) {
               if (thefile->bufpos >= thefile->dataRead) {
                   lasterror = ReadFile(thefile->filehand, thefile->buffer, APR_FILE_BUFSIZE,
&thefile->dataRead, NULL ) ? 0 : GetLastError();
   
                   if (thefile->dataRead == 0) {
  -                    if (lasterror == 0)
  +                    if (lasterror == 0) {
                           thefile->eof_hit = TRUE;
  +                        lasterror = APR_EOF;
  +                    }
                       break;
                   }
   
  @@ -102,12 +110,20 @@
               size -= blocksize;
           }
   
  -        *nbytes = lasterror == 0 ? pos - (char *)buf : 0;
  +        *nbytes = pos - (char *)buf;
  +        if (*nbytes) {
  +            lasterror = 0;
  +        }
           ap_unlock(thefile->mutex);
       } else {
           if (ReadFile(thefile->filehand, buf, *nbytes, &bread, NULL)) {
               *nbytes = bread;
  -            return APR_SUCCESS;
  +            if (bread) {
  +                return APR_SUCCESS;
  +            }
  +            else {
  +                return APR_EOF;
  +            }
           }
   
           *nbytes = 0;
  @@ -285,9 +301,11 @@
           }
           
           if (str[i] == '\r' || str[i] == '\x1A')
  -            i--;
  -        else if (str[i] == '\n')
  +            i--; /* don't keep this char */
  +        else if (str[i] == '\n') {
  +            i++; /* don't clobber this char below */
               break;
  +        }
       }
       str[i] = 0;
       return rv;
  
  
  

Mime
View raw message