Re: fdopen behaviour correction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 16, 2002 at 11:02:10PM +0100, Uwe Bonnes wrote:
> >>>>> "Bill" == Bill Currie <bill@taniwha.org> writes:
> 
>     Bill> fdopen is not supposed to rewind the file descriptor being given a
>     Bill> FILE *.  Proof of this comes from quakeforge working in windows
>     Bill> natively but not in wine without the attatched patch.
> 
>     Bill> ChangeLog * dlls/msvcrt/file.c don't rewind the file after
>     Bill> creating the FILE* handle
> 
> It is good to have a test case for such cases in wine/dlls/msvcrt/tests. 

Ok, done. New patch attached (same changelog).

Bill
-- 
Leave others their otherness. -- Aratak
Index: dlls/msvcrt/file.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/file.c,v
retrieving revision 1.42
diff -u -r1.42 file.c
--- dlls/msvcrt/file.c	25 Nov 2002 20:50:01 -0000	1.42
+++ dlls/msvcrt/file.c	16 Dec 2002 23:18:30 -0000
@@ -620,8 +620,6 @@
   MSVCRT_FILE* file = msvcrt_alloc_fp(fd);
 
   TRACE(":fd (%d) mode (%s) FILE* (%p)\n",fd,mode,file);
-  if (file)
-    MSVCRT_rewind(file);
 
   return file;
 }
Index: dlls/msvcrt/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/tests/Makefile.in,v
retrieving revision 1.1
diff -u -r1.1 Makefile.in
--- dlls/msvcrt/tests/Makefile.in	30 Oct 2002 23:49:03 -0000	1.1
+++ dlls/msvcrt/tests/Makefile.in	16 Dec 2002 23:18:30 -0000
@@ -7,7 +7,7 @@
 EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
 
 CTESTS = \
-	scanf.c 
+	fdopen.c scanf.c 
 
 @MAKE_TEST_RULES@
 
--- /dev/null	1969-12-31 17:00:00.000000000 -0700
+++ dlls/msvcrt/tests/fdopen.c	2002-12-16 16:14:24.000000000 -0700
@@ -0,0 +1,53 @@
+/*
+ * Unit test suite for *scanf functions.
+ *
+ * Copyright 2002 Uwe Bonnes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+typedef long long __int64;
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <io.h>
+
+#include "wine/test.h"
+
+static void test_fdopen( void )
+{
+    static char buffer[] = {0,1,2,3,4,5,6,7,8,9};
+    int result;
+	int fd;
+	FILE *file;
+
+	fd = open ("fdopen.tst", O_WRONLY | O_CREAT | O_BINARY);
+	write (fd, buffer, sizeof (buffer));
+	close (fd);
+
+	fd = open ("fdopen.tst", O_RDONLY | O_BINARY);
+	lseek (fd, 5, SEEK_SET);
+	file = fdopen (fd, "rb");
+	ok (fread (buffer, 1, sizeof (buffer), file) == 5, "read wrong byte count");
+	ok (memcmp (buffer, buffer + 5, 5) == 0, "read wrong bytes");
+	fclose (file);
+	unlink ("fdopen.tst");
+}
+
+
+START_TEST(fdopen)
+{
+    test_fdopen();
+}

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux