On Fri, 2004-04-30 at 18:58, Joe Orton wrote:
> On Thu, Apr 29, 2004 at 10:44:16AM -0400, Jeff Trawick wrote:
> > wow
> >
> > is there any chance you can merge your test case into the existing test
> > suite?
Index: file_io/os2/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/os2/seek.c,v
retrieving revision 1.26
diff -u -r1.26 seek.c
--- file_io/os2/seek.c 13 Feb 2004 09:38:24 -0000 1.26
+++ file_io/os2/seek.c 1 May 2004 18:38:40 -0000
@@ -70,7 +70,7 @@
case APR_END:
rc = apr_file_info_get(&finfo, APR_FINFO_NORM, thefile);
if (rc == APR_SUCCESS)
- rc = setptr(thefile, finfo.size - *offset);
+ rc = setptr(thefile, finfo.size + *offset);
break;
}
Index: file_io/unix/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/unix/seek.c,v
retrieving revision 1.34
diff -u -r1.34 seek.c
--- file_io/unix/seek.c 27 Mar 2004 13:11:17 -0000 1.34
+++ file_io/unix/seek.c 1 May 2004 18:38:40 -0000
@@ -69,7 +69,7 @@
case APR_END:
rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile);
if (rc == APR_SUCCESS)
- rc = setptr(thefile, finfo.size - *offset);
+ rc = setptr(thefile, finfo.size + *offset);
break;
}
Index: file_io/win32/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/seek.c,v
retrieving revision 1.28
diff -u -r1.28 seek.c
--- file_io/win32/seek.c 13 Feb 2004 09:38:27 -0000 1.28
+++ file_io/win32/seek.c 1 May 2004 18:38:40 -0000
@@ -73,7 +73,7 @@
case APR_END:
rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile);
if (rc == APR_SUCCESS)
- rc = setptr(thefile, finfo.size - *offset);
+ rc = setptr(thefile, finfo.size + *offset);
break;
default:
Index: test/testfile.c
===================================================================
RCS file: /home/cvspublic/apr/test/testfile.c,v
retrieving revision 1.72
diff -u -r1.72 testfile.c
--- test/testfile.c 13 Feb 2004 09:38:34 -0000 1.72
+++ test/testfile.c 1 May 2004 18:38:40 -0000
@@ -228,6 +228,27 @@
CuAssertStrEquals(tc, TESTSTR + 5, str);
apr_file_close(filetest);
+
+ /* Test for regression of sign error bug with SEEK_END and
+ buffered files. */
+ rv = apr_file_open(&filetest, FILENAME,
+ APR_READ | APR_BUFFERED,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ apr_assert_success(tc, "Open test file " FILENAME, rv);
+
+ offset = -5;
+ rv = apr_file_seek(filetest, SEEK_END, &offset);
+ CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ CuAssertIntEquals(tc, strlen(TESTSTR) - 5, nbytes);
+
+ memset(str, 0, nbytes + 1);
+ nbytes = 256;
+ rv = apr_file_read(filetest, str, &nbytes);
+ CuAssertIntEquals(tc, APR_SUCCESS, rv);
+ CuAssertIntEquals(tc, 5, nbytes);
+ CuAssertStrEquals(tc, TESTSTR + strlen(TESTSTR) - 5, str);
+
+ apr_file_close(filetest);
}
static void test_userdata_set(CuTest *tc)