Ozaki Kiichi wrote:
> 2016年9月10日土曜日 22時59分53秒 UTC+9 Bram Moolenaar:
> > Ozaki Kiichi wrote:
> >
> > > > ! if (++last_timer_id < 0)
> > > > ! /* Overflow! Might cause duplicates... */
> > > > ! last_timer_id = 0;
> > >
> > > Sorry, I realized this is not proper overflow detection in standard C.
> > > We had to check before increment.
> > >
> > > https://gist.github.com/ichizok/d9d220ba44e512a6b26d34c1bfc05711
> >
> > Hmm, we don't use LONG_MAX anywhere currently. Not sure about
> > portability.
> >
> > I think the current check should work. Another way would be:
> >
> > prev_val = last_timer_id;
> > if ++last_timer_id <= prev_val)
> > last_timer_id = 0;
> >
> >
> > --
> > If evolution theories are correct, humans will soon grow a third
> > hand for operating the mouse.
> >
> > /// 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 ///
>
> Overflow causes a undefined behavior,
> therefore, in C spec, checking "after overflow occurring actually" does not
> work.
>
> But,
>
> > I think the current check should work.
>
> in practical, that may be so...
>
> I want to withdraw once and think again.
I suppose some optimizer might turn the code into something else. In
practice the CPU instruction would be increment. That either wraps
around or goes back to zero (for unsigned).
Let's just put in the code I suggested, it's a bit more reliable than
checking for negative.
--
hundred-and-one symptoms of being an internet addict:
226. You sit down at the computer right after dinner and your spouse
says "See you in the morning."
/// 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.