Thanks.
Please don't use rand() in testcases, though.
Would a constant 'a' suffice in this case?
Which app did you find this in, btw?
On Tue, Feb 3, 2009 at 1:55 PM, Uwe Bonnes
<bon(a)elektron.ikp.physik.tu-darmstadt.de> wrote:
> Hello,
>
> it seems that in ASCII mode, fseek() may disturb reading. Appended patch
> adds a todo_wine.
>
> Bye
> --
> Uwe Bonnes bon(a)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");
> }
>
>