Mercurial > octave
changeset 21635:986dbd769bb1
Handle large hex and binary integer input (bug #47690)
* lex.ll (octave_base_lexer::handle_number): Use uintmax_t for hex and
binary integer input.
author | mmuetzel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 20 Apr 2016 10:58:29 +0200 |
parents | 96518f623c91 |
children | a3a412dee704 |
files | libinterp/parse-tree/lex.ll |
diffstat | 1 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Wed Apr 20 11:06:03 2016 -0700 +++ b/libinterp/parse-tree/lex.ll Wed Apr 20 10:58:29 2016 +0200 @@ -2780,23 +2780,24 @@ if (looks_like_hex (tmptxt, strlen (tmptxt))) { - unsigned long ival; - - nread = sscanf (tmptxt, "%lx", &ival); - - value = static_cast<double> (ival); + uintmax_t long_int_value; + + nread = sscanf (tmptxt, "%jx", &long_int_value); + + value = static_cast<double> (long_int_value); } else if (looks_like_bin (tmptxt, strlen (tmptxt))) { - uint64_t ivalue = 0; + uintmax_t long_int_value = 0; for (size_t i = 0; i < strlen (tmptxt); i++) { - ivalue <<= 1; - ivalue += static_cast<uint64_t> (tmptxt[i] == '1'); + long_int_value <<= 1; + long_int_value += static_cast<uintmax_t> (tmptxt[i] == '1'); } - value = static_cast<double> (ivalue); + value = static_cast<double> (long_int_value); + nread = 1; // Just to pass the assert stmt below } else