In a surprise last-minute request it became necessary for me to get
Athena Visual Studio running under Wine again
(http://appdb.winehq.org/objectManager.php?sClass=version&iId=15183).
A couple of commits to MSVCRT (that are needed for other reasons)
caused regressions in Wine's ability to run this application and I am
having a lot of difficulty getting Athena working again.  The commits
that revealed the problem are:
ebe4a9e321800fbe6d2004a640cd276a28d15c38: Remove CRs earlier in ascii mode.
7f3c70c52fe470d431a51b3363ed4f7336d5f7f5: Remove CRs earlier in ascii
mode in fseek, too.

After tracing down a lot of rabbit holes, it appears that the problem
is somehow related to how the buffer boundary influences the file
position reported by ftell.  I've attached a test case that appears
related to the issue.  I can use a native MSVCRT for now, but I would
appreciate some assistance so that this issue can be properly resolved
at some point.

Erich Hoover
[email protected]
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index e164555..b4adad7 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -36,8 +36,11 @@
 
 static HANDLE proc_handles[2];
 
+#define MSVCRT_BUFSIZ 512
+
 static void test_filbuf( void )
 {
+    char test_buffer[MSVCRT_BUFSIZ*2];
     FILE *fp;
     int c;
     fpos_t pos;
@@ -64,6 +67,21 @@ static void test_filbuf( void )
     ok(fgetpos(fp, &pos) == 0, "fgetpos fail\n");
     ok(pos == -2, "ftell does not match fgetpos\n");
     fclose(fp);
+
+    memset(test_buffer, ' ', sizeof(test_buffer));
+    test_buffer[MSVCRT_BUFSIZ-1] = '\r';
+    test_buffer[MSVCRT_BUFSIZ-2] = '\n';
+    fp = fopen("filbuf.tst", "wb");
+    fwrite(test_buffer, 1, sizeof(test_buffer), fp);
+    fclose(fp);
+
+    fp = fopen("filbuf.tst", "rt");
+    c = _filbuf(fp);
+    ok(c == ' ', "read wrong byte\n");
+    ok(ftell(fp) == 0, "ascii crlf removal does not match native (pos = %d)\n", ftell(fp));
+    ok(fgetpos(fp, &pos) == 0, "fgetpos fail\n");
+    ok(pos == 0, "ftell does not match fgetpos (pos = %d)\n", pos);
+    fclose(fp);
     unlink("filbuf.tst");
 }
 


Reply via email to