python regression tests - a monster hammer to keep wine "in check" :)

Dan Kegel dank at kegel.com
Sat Jan 17 23:20:59 CST 2009


Sadly, I'm having trouble seeing how to do it this
way and get ftell() right.  ftell returns the position
of the fd minus the number of bytes in the buffer.
For that to work with this scheme, I'd have to store
the number of CRs removed... and I'm not sure where
in struct iobuf that could go, or whether native does
it that way.   (Maybe the high byte of intbuf?)

The problem is illustrated by

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int i;
    char buffer[512];

    FILE *f = fopen("tst", "w");
    fwrite("a\n", 1, 2, f);
    fwrite("bcd\n", 1, 4, f);
    fclose(f);

    f = fopen("tst", "r");
    memset(buffer, 0, 512);
    fgets(buffer, 512, f);
    printf("line 1: fgets read %d bytes, '%s'\n", strlen(buffer), buffer);
    if (memcmp(buffer, "a\n", 3))
        printf("Fail! first line wrong, expected 'a\\n'\n");
    printf("filepos: %ld\n", ftell(f));

    if (ftell(f) != 3)
        printf("Fail! ftell wrong, expected 3\n");
    fclose(f);
}

which outputs filepos 4 instead of 3 with my patch, and fails with
"ftell wrong".
- Dan

On Sat, Jan 17, 2009 at 12:40 PM, Luke Kenneth Casson Leighton
<lkcl at lkcl.net> wrote:
> spiffo, dan, jolly good show :)
>
> that fixed both #16982 _and_ #16970 - the character reading bit - with
> the exception that the ftell() position, which was wrong _before_ this
> patch, is still also wrong, as you suspected.
>
> l.
>
> On Sat, Jan 17, 2009 at 7:15 PM, Dan Kegel <dank at kegel.com> wrote:
>> Luke wrote:
>>> [MSVCRT__filbuf() needs to strip CR's.]
>>
>> Here's a quickie patch that kind of gets there,
>> but fails an ftell test.  My in-laws arrive in ten
>> minutes, so I probably can't go any further on
>> it this weekend.
>>
>> There are probably other simplifications that
>> could be made beyond this, I didn't rip out
>> all the scattered places that were involved
>> in \r removal.
>> - Dan
>>
>



More information about the wine-devel mailing list