diff src/option.c @ 6551:4e31d9f7c896 v7.4.602

updated for version 7.4.602 Problem: ":set" does not accept hex numbers as documented. Solution: Use vim_str2nr(). (ZyX)
author Bram Moolenaar <bram@vim.org>
date Tue, 27 Jan 2015 15:58:40 +0100
parents 3421b24e419c
children d6473d6501fd
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -4540,21 +4540,11 @@ do_set(arg, opt_flags)
 				goto skip;
 			    }
 			}
-				/* allow negative numbers (for 'undolevels') */
 			else if (*arg == '-' || VIM_ISDIGIT(*arg))
 			{
-			    i = 0;
-			    if (*arg == '-')
-				i = 1;
-#ifdef HAVE_STRTOL
-			    value = strtol((char *)arg, NULL, 0);
-			    if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
-				i += 2;
-#else
-			    value = atol((char *)arg);
-#endif
-			    while (VIM_ISDIGIT(arg[i]))
-				++i;
+			    /* Allow negative (for 'undolevels'), octal and
+			     * hex numbers. */
+			    vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL);
 			    if (arg[i] != NUL && !vim_iswhite(arg[i]))
 			    {
 				errmsg = e_invarg;