Mercurial > hg > octave-avbm
changeset 11750:3d929f68d226 release-3-0-x
octave_scan_1: fix reading of hex numbers
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 14 Apr 2008 13:27:21 -0400 |
parents | b172a66c7433 |
children | e474c782e1e2 |
files | src/ChangeLog src/oct-stream.cc |
diffstat | 2 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-14 Jaroslav Hajek <highegg@gmail.com> + + * oct-stream.cc (octave_scan_1): Ensure digit following X is hex + digit before reading number as hex. + 2008-04-14 John W. Eaton <jwe@octave.org> * file-io.cc (Ffread): Allow SKIP arg to be omitted.
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -26,6 +26,7 @@ #endif #include <cassert> +#include <cctype> #include <cstring> #include <iomanip> @@ -1065,14 +1066,18 @@ { if (c1 == '0') { - int c2 = is.get (); + int c2 = is.peek (); if (c2 == 'x' || c2 == 'X') - is >> std::hex >> ref >> std::dec; + { + is.ignore (); + if (std::isxdigit (is.peek ())) + is >> std::hex >> ref >> std::dec; + else + ref = 0; + } else { - is.putback (c2); - if (c2 == '0' || c2 == '1' || c2 == '2' || c2 == '3' || c2 == '4' || c2 == '5' || c2 == '6' || c2 == '7')