On Thursday, December 12, 2013 2:57:59 PM UTC-5, Bram Moolenaar wrote:
> Aaron Burrow wrote:
> 
> 
> 
> > This patch fixes three things that seemed off to me.
> 
> > 
> 
> > 1. If you enter a count that is too large for a long; you just get the
> 
> > arbitrary value 999999999L.  This patch causes normal_cmd(...) to fail.
> 
> > 
> 
> > 2. If you try to read a value from the screen (with ctrla/ctrlx) that
> 
> > causes an overflow, vim will just use the part of the value coming after
> 
> > the overflow; this patch ``does nothing'' instead.
> 
> > 
> 
> > 3. If your ctrla/ctrlx produces a value that causes an unsigned overflow,
> 
> > vim will do wrapping for decimal, hex and octal.  I think that it should
> 
> > not wrap for decimal and instead do nothing.
> 
> > 
> 
> > At the very least, I think it is much saner to use strtoul(...) in
> 
> > vim_str2nr(...) as opposed to the rollyourown solution.
> 
> > 
> 
> > Patch attached.
> 
> 
> 
> How much of this is covered by tests?
> 
> 
> 
> Does strtoul() work properly on all platforms?
> 
> 
> 
> -- 
> 
> hundred-and-one symptoms of being an internet addict:
> 
> 42. Your virtual girlfriend finds a new net sweetheart with a larger 
> bandwidth.
> 
> 
> 
>  /// 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    ///

Test coverage is limited to vim/src/testdir/test35.in. It does test going from 
positive to negative and going to zero.

Maybe we want some tests that will take a look at the overflow scenario; but 
it's difficult because they would depend on the size of unsigned long.

The usage of strtoul(...) is limited to what is described in 7.20.1.4 of c89; 
as for actual implementations I don't know.  I've only tested on 64 bit Ubuntu 
12.04.

-- 
-- 
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/groups/opt_out.

Raspunde prin e-mail lui