found major bug in parsing, fixed it

This commit is contained in:
Daniel Larimer 2014-05-15 13:35:49 -04:00
parent 2837892ec0
commit 271fe8b909

View file

@ -8,6 +8,7 @@
//#include <utfcpp/utf8.h> //#include <utfcpp/utf8.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream>
namespace fc namespace fc
{ {
@ -104,11 +105,6 @@ namespace fc
{ {
char c = in.peek(); char c = in.peek();
// if( c != ' ' )
// FC_THROW_EXCEPTION( parse_error_exception,
// "Expected '\"' but read '${char}'",
// ("char", string(&c, (&c) + 1) ) );
// in.get();
while( true ) while( true )
{ {
switch( c = in.peek() ) switch( c = in.peek() )
@ -118,15 +114,17 @@ namespace fc
break; break;
case '\t': case '\t':
case ' ': case ' ':
case '\0':
case '\n':
in.get(); in.get();
return token.str(); return token.str();
default: default:
std::cerr<<c;
token << c; token << c;
in.get(); in.get();
} }
} }
// FC_THROW_EXCEPTION( parse_error_exception, "EOF before closing '\"' in string '${token}'", return token.str();
// ("token", token.str() ) );
} }
catch( const fc::eof_exception& eof ) catch( const fc::eof_exception& eof )
{ {
@ -375,9 +373,10 @@ namespace fc
} }
return variant(); return variant();
} }
variant json::from_string( const fc::string& utf8_str ) variant json::from_string( const std::string& utf8_str )
{ {
fc::stringstream in( utf8_str ); std::stringstream in( utf8_str );
in.exceptions( std::ifstream::eofbit );
return variant_from_stream( in ); return variant_from_stream( in );
} }