diff src/oct-stream.cc @ 7709:fa41af732801

octave_scan_1: fix reading of hex numbers
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 14 Apr 2008 13:27:21 -0400
parents 2c4b0cbda85a
children 932b0cf51834
line wrap: on
line diff
--- a/src/oct-stream.cc	Mon Apr 14 13:13:25 2008 -0400
+++ b/src/oct-stream.cc	Mon Apr 14 13:27:21 2008 -0400
@@ -26,6 +26,7 @@
 #endif
 
 #include <cassert>
+#include <cctype>
 #include <cstring>
 
 #include <iomanip>
@@ -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')