# HG changeset patch # User Jaroslav Hajek # Date 1208194041 14400 # Node ID fa41af73280150004a9801edd0ed39e88727c023 # Parent b42abee70a989b05a6387199a779e801994591ae octave_scan_1: fix reading of hex numbers diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-14 Jaroslav Hajek + + * oct-stream.cc (octave_scan_1): Ensure digit following X is hex + digit before reading number as hex. + 2008-04-14 John W. Eaton * file-io.cc (Ffread): Allow SKIP arg to be omitted. diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -26,6 +26,7 @@ #endif #include +#include #include #include @@ -1066,14 +1067,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')