2016-02-27 17:21 GMT+03:00 Bram Moolenaar <[email protected]>:
>
> Ben Fritz wrote:
>
>> On Friday, February 26, 2016 at 11:04:56 AM UTC-6, Bram Moolenaar wrote:
>> > Ozaki Kiichi wrote:
>> >
>> > > Some vim codes use C99 features;
>> >
>> > We aim at ANSI C, but some things may be optional.
>> >
>> > > * json.c: isinf(), NAN, INFINITY
>> >
>> > AFAIK isinf() is ANSI C.
>> >
>> > It appears INFINITY was first officially standardized in C99, but it
>> > existed much longer before that.  Not sure what else to use when
>> > INFINITY is not available.
>> >
>> > NAN is not even in C99, it appears.  Again, not sure what to do if it's
>> > not available.
>>
>> Both of these just bit me, trying to compile with a really old
>> compiler I'm stuck with on a Solaris server at work (gcc 2.95.2).
>>
>> I got around it by removing the Windows checks from the re-definitions
>> (see patch). Why do we limit this to Windows anyway?
>
> I'm very surprised you have _isnan() and _finite().  I thought these are
> a WIN32 thing.  The same check for isnan() is in eval.c.
>
> For INFINITY and NAN we can make it more generic.
>
> isnan(x) can be changed to "x != x".
>
> I don't know an alternative for isinf() though.

For isinf I think the following should be needed:

    /* In some header: */
    static inline isinf(const double f)
    /* In Neovim I would write this with macros that adds
     * `__attribute__((const)) __attribute__((always_inline))` */
    ;

    static inline isnan(const double f)
    /* In Neovim I would write this with macros that adds
     * `__attribute__((const)) __attribute__((always_inline))` */
    ;

    static inline isnan(const double f)
    {
        return f != f;
    }

    static inline isinf(const double f)
    {
        return !isnan(f) && f != 0 && f * 2 == f;
    }

. The idea is that *2 always modifies exponent, except for the cases
when `f` is 0, when `f` is infinite and when it is NaN. Not sure, but
I guess that if exponent is already big enough it should turn the
value into infinity, which is not equal to `f`.

>
> What exactly is missing on that system?
>
> Perhaps someone can make a configure check for this stuff.

I think that if hacks such as the above code are added they need to be
ignored when system actually has isinf or isnan, which means configure
check.

>
>
> --
> Citizens are not allowed to attend a movie house or theater nor ride in a
> public streetcar within at least four hours after eating garlic.
>                 [real standing law in Indiana, United States of America]
>
>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org        ///
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui