http://bugs.winehq.org/show_bug.cgi?id=16982 Summary: fgets as first read on file followed by fread gives wrong results Product: Wine Version: 1.0.1 Platform: Other OS/Version: other Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: msvcrt AssignedTo: wine-bugs(a)winehq.org ReportedBy: lkcl(a)lkcl.net Created an attachment (id=18770) --> (http://bugs.winehq.org/attachment.cgi?id=18770) test case following simple app: #include <stdio.h> int main(int argc, char *argv[]) { int i; char buffer[512]; char *buf; FILE *f = fopen("tst", "w"); fwrite("hell\n", 1, 5, f); fwrite("argh\n", 1, 5, f); fwrite("wizz\n", 1, 5, f); fwrite("hell\n", 1, 5, f); fclose(f); f = fopen("tst", "r"); /*i = fread(buffer, 1, 5, f); printf("buffer: read %d '%s' buffer[4]: %d\n", i, buffer, buffer[4]); */ buf = fgets(buffer, 512, f); printf("fgets: '%s'\n", buf); i = fread(buffer, 1, 5, f); printf("buffer: read %d buffer[0]: %d '%s' buffer[4]: %d\n", i, buffer[0], buffer, buffer[4]); printf("filepos: %d\n", ftell(f)); fclose(f); } with builtin msvcrt: fgets: 'hell ' buffer: read 4 buffer[0]: 97 'argh^M' buffer[4]: 13 filepos: 11 with native msvcrt.dll: fgets: 'hell ' buffer: read 5 buffer[0]: 97 'argh ' buffer[4]: 10 filepos: 12 where it's going wrong is that it _says_ it's read 4 characters when actually you asked for 5, on the fread(). that, and you get a \r instead of a \n. also - note the filepos count - in the native run, it _does_ move along on the \r\n so it's not the "number of characters returned" that are counted but it's the "actual position in the real file". euurrrgh. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email Do not reply to this email, post in Bugzilla using the above URL to reply. ------- You are receiving this mail because: ------- You are watching all bug changes.