MSVCRT: Still problems in ASCII Mode

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Tue Feb 3 15:55:45 CST 2009


Hello,

it seems that in ASCII mode, fseek() may disturb reading. Appended patch
adds a todo_wine. 

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 9032e51..2a72212 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -306,7 +306,8 @@ static void test_asciimode(void)
 {
     FILE *fp;
     char buf[64];
-    int c, i, j;
+    int c, i, j, done, count1, count2;
+    
 
     /* Simple test of CR CR LF handling.  Test both fgets and fread code paths, they're different! */
     fp = fopen("ascii.tst", "wb");
@@ -372,6 +373,46 @@ static void test_asciimode(void)
     ok((c = fgetc(fp)) == '1', "fgetc fails to read next char when positioned on \\r\n");
     fclose(fp);
 
+    fp= fopen("ascii.tst","wb");
+    for (i=0; i<1000; i++)
+      {
+	unsigned char c = (rand()+ ' ') & 0x7f;
+	if (isgraph(c) || (c == ' '))
+	  fputc(c, fp);
+	else if ((c == '\r') || (c == '\n'))
+	  fputs("\r\n", fp);
+      }
+    fclose(fp);
+
+    done = 0;
+    count1 = 0;
+    
+    fp = fopen("ascii.tst", "r");
+    while (!done)
+      {
+	c= fgetc(fp);
+	if (c == EOF)
+	  done =  1;
+	else if (isalnum(c))
+	  count1 ++;
+      }
+    fclose(fp);
+	
+    done = 0;
+    count2 = 0;
+    
+    fp = fopen("ascii.tst", "r");
+    while (!done)
+      {
+	c= fgetc(fp);
+	fseek(fp, 0, SEEK_CUR);
+	if (c == EOF)
+	  done =  1;
+	else if (isalnum(c))
+	  count2 ++;
+     }
+    fclose(fp);
+    todo_wine ok((count1 == count2), "fseek caused short read %d vs %d\n", count2, count1);
     unlink("ascii.tst");
 }
 



More information about the wine-patches mailing list