You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@attglobal.net> on 2002/03/12 02:57:53 UTC

Re: cvs commit: apr/file_io/unix seek.c

trawick@apache.org writes:

> trawick     02/03/11 14:17:29
> 
>   Modified:    .        CHANGES
>                file_io/unix seek.c
>   Log:
>   fix a problem in apr_file_seek on Unix for buffered files

>   Index: seek.c
>   ===================================================================
>   RCS file: /home/cvs/apr/file_io/unix/seek.c,v
>   retrieving revision 1.24
>   retrieving revision 1.25
>   diff -u -r1.24 -r1.25
>   --- seek.c	28 Aug 2001 16:41:14 -0000	1.24
>   +++ seek.c	11 Mar 2002 22:17:29 -0000	1.25
>   @@ -74,6 +74,7 @@
>    
>            if (rc != -1 ) {
>                thefile->bufpos = thefile->dataRead = 0;
>   +            thefile->filePtr = pos;
>                rc = 0;
>            }
>            else {

The following changes may be appropriate for Win32 and OS/2:

Index: file_io/os2/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/os2/seek.c,v
retrieving revision 1.19
diff -u -r1.19 seek.c
--- file_io/os2/seek.c	28 Aug 2001 16:41:14 -0000	1.19
+++ file_io/os2/seek.c	12 Mar 2002 01:58:29 -0000
@@ -76,8 +76,10 @@
     } else {
         rc = DosSetFilePtr(thefile->filedes, pos, FILE_BEGIN, &thefile->filePtr );
 
-        if ( !rc )
+        if ( !rc ) {
             thefile->bufpos = thefile->dataRead = 0;
+            thefile->filePtr = pos;
+        }
     }
 
     return APR_OS2_STATUS(rc);
Index: file_io/win32/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/seek.c,v
retrieving revision 1.21
diff -u -r1.21 seek.c
--- file_io/win32/seek.c	28 Aug 2001 16:41:14 -0000	1.21
+++ file_io/win32/seek.c	12 Mar 2002 01:58:29 -0000
@@ -81,8 +81,10 @@
             rc = apr_get_os_error();
         else
             rc = APR_SUCCESS;
-        if (rc == APR_SUCCESS)
+        if (rc == APR_SUCCESS) {
             thefile->eof_hit = thefile->bufpos = thefile->dataRead = 0;
+            thefile->filePtr = pos;
+        }
     }
 
     return rc;

Running the latest version testfile before and after the patch may be
instructive.

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: cvs commit: apr/file_io/unix seek.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On 12 Mar 2002 06:48:13 -0500, Jeff Trawick wrote:

>"Brian Havard" <br...@kheldar.apana.org.au> writes:
>
>> >+            thefile->filePtr = pos;
>> >+        }
>> >     }
>> > 
>> >     return APR_OS2_STATUS(rc);
>> 
>> This bit isn't necessary. DosSetFilePtr() stores the new file position in
>> the last parameter so thefile->filePtr is already set.
>
>Thanks for the check!
>
>(It still looks to me that it may be needed on Win32.)

Yes, it does.

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: cvs commit: apr/file_io/unix seek.c

Posted by Jeff Trawick <tr...@attglobal.net>.
"Brian Havard" <br...@kheldar.apana.org.au> writes:

> >+            thefile->filePtr = pos;
> >+        }
> >     }
> > 
> >     return APR_OS2_STATUS(rc);
> 
> This bit isn't necessary. DosSetFilePtr() stores the new file position in
> the last parameter so thefile->filePtr is already set.

Thanks for the check!

(It still looks to me that it may be needed on Win32.)

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: cvs commit: apr/file_io/unix seek.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On 11 Mar 2002 20:57:53 -0500, Jeff Trawick wrote:

>The following changes may be appropriate for Win32 and OS/2:
>
>Index: file_io/os2/seek.c
>===================================================================
>RCS file: /home/cvspublic/apr/file_io/os2/seek.c,v
>retrieving revision 1.19
>diff -u -r1.19 seek.c
>--- file_io/os2/seek.c	28 Aug 2001 16:41:14 -0000	1.19
>+++ file_io/os2/seek.c	12 Mar 2002 01:58:29 -0000
>@@ -76,8 +76,10 @@
>     } else {
>         rc = DosSetFilePtr(thefile->filedes, pos, FILE_BEGIN, &thefile->filePtr );
> 
>-        if ( !rc )
>+        if ( !rc ) {
>             thefile->bufpos = thefile->dataRead = 0;
>+            thefile->filePtr = pos;
>+        }
>     }
> 
>     return APR_OS2_STATUS(rc);

This bit isn't necessary. DosSetFilePtr() stores the new file position in
the last parameter so thefile->filePtr is already set.

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------