lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 02.06.2011 22:33, schrieb liam mail:


On 2 June 2011 20:19, Marc Balmer <marc@msys.ch <mailto:marc@msys.ch>>
wrote:

    Am 02.06.2011 20:47, schrieb Marc Balmer:

        Am 02.06.2011 19:44, schrieb liam mail:



            On 2 June 2011 18:09, Tony Finch <dot@dotat.at
            <mailto:dot@dotat.at> <mailto:dot@dotat.at
            <mailto:dot@dotat.at>>>
            wrote:

            Marc Balmer <marc@msys.ch <mailto:marc@msys.ch>
            <mailto:marc@msys.ch <mailto:marc@msys.ch>>> wrote:
             >
             > What does the standard say is*() should return if the
            argument is
            EOF?
             > Is that specified at all?

            It seems to be unspecified. This is probably a bug in the
            standard.
            Here's a link to C99 with all the technical corrigenda
            included. The
            relevant part is section 7.4 starting on page 181.

            http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf

            Tony.
            --
            f.anthony.n.finch <dot@dotat.at <mailto:dot@dotat.at>
            <mailto:dot@dotat.at <mailto:dot@dotat.at>>> http://dotat.at/
            Rockall, Malin, Hebrides: South 5 to 7, occasionally gale 8
            at first in
            Rockall and Malin, veering west or northwest 4 or 5, then
            backing
            southwest 5
            or 6 later. Rough or very rough. Occasional rain. Moderate
            or good,
            occasionally poor.



            Although the C99 standard does not state it, the C99
            rationale v5.1[1]
            does
            "*7.4.1Character classification functions *
            **The definitions of /printing character /and /control
            character /have
            been generalized from ASCII.
            Note that none of these functions returns a nonzero value
            (true) for the
            argument value *EOF*."


        So if Microsoft claims to be in support of the C99 standard, this is
        clearly a bug in their implementation of the SDK.


  IIRC Microsoft do not claim to support C99 on any platform.



            [1]
            http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf


    for general amusement, this is how to make a microsoft compiler
    halfway standards compliant:

    #undef isalnum
    #define isalnum(_c)      ( _c == EOF ? 0 : _isctype(_c,_ALPHA|_DIGIT) )
    #undef isdigit
    #define isdigit(_c)      ( _c == EOF ? 0 : _isctype(_c,_DIGIT) )


I wonder if -1 is being truncated to 0xFF and your locale allows 0xFF to
be passed to is* function as it is part of the special character set.
EOZ is defined in lzio.h and used in lzio.c and llex.c. what happens
when you change these to use EOF from stdio.h instead of -1 ?

I had my program output the value of EOF using printf("%d\n", EOF); and that was -1.