@@ -44,10 +44,10 @@ printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." )
4444 fprintf ( fout, " %s=null\n " , path.c_str () );
4545 break ;
4646 case Json::intValue:
47- fprintf ( fout, " %s=%s\n " , path.c_str (), Json::valueToString ( value.asInt () ).c_str () );
47+ fprintf ( fout, " %s=%s\n " , path.c_str (), Json::valueToString ( value.asLargestInt () ).c_str () );
4848 break ;
4949 case Json::uintValue:
50- fprintf ( fout, " %s=%s\n " , path.c_str (), Json::valueToString ( value.asUInt () ).c_str () );
50+ fprintf ( fout, " %s=%s\n " , path.c_str (), Json::valueToString ( value.asLargestUInt () ).c_str () );
5151 break ;
5252 case Json::realValue:
5353 fprintf ( fout, " %s=%.16g\n " , path.c_str (), value.asDouble () );
@@ -224,37 +224,45 @@ int main( int argc, const char *argv[] )
224224 return exitCode;
225225 }
226226
227- std::string input = readInputTestFile ( path.c_str () );
228- if ( input.empty () )
227+ try
229228 {
230- printf ( " Failed to read input or empty input: %s\n " , path.c_str () );
231- return 3 ;
232- }
229+ std::string input = readInputTestFile ( path.c_str () );
230+ if ( input.empty () )
231+ {
232+ printf ( " Failed to read input or empty input: %s\n " , path.c_str () );
233+ return 3 ;
234+ }
233235
234- std::string basePath = removeSuffix ( argv[1 ], " .json" );
235- if ( !parseOnly && basePath.empty () )
236- {
237- printf ( " Bad input path. Path does not end with '.expected':\n %s\n " , path.c_str () );
238- return 3 ;
239- }
236+ std::string basePath = removeSuffix ( argv[1 ], " .json" );
237+ if ( !parseOnly && basePath.empty () )
238+ {
239+ printf ( " Bad input path. Path does not end with '.expected':\n %s\n " , path.c_str () );
240+ return 3 ;
241+ }
240242
241- std::string actualPath = basePath + " .actual" ;
242- std::string rewritePath = basePath + " .rewrite" ;
243- std::string rewriteActualPath = basePath + " .actual-rewrite" ;
243+ std::string actualPath = basePath + " .actual" ;
244+ std::string rewritePath = basePath + " .rewrite" ;
245+ std::string rewriteActualPath = basePath + " .actual-rewrite" ;
244246
245- Json::Value root;
246- exitCode = parseAndSaveValueTree ( input, actualPath, " input" , root, features, parseOnly );
247- if ( exitCode == 0 && !parseOnly )
248- {
249- std::string rewrite;
250- exitCode = rewriteValueTree ( rewritePath, root, rewrite );
251- if ( exitCode == 0 )
247+ Json::Value root;
248+ exitCode = parseAndSaveValueTree ( input, actualPath, " input" , root, features, parseOnly );
249+ if ( exitCode == 0 && !parseOnly )
252250 {
253- Json::Value rewriteRoot;
254- exitCode = parseAndSaveValueTree ( rewrite, rewriteActualPath,
255- " rewrite" , rewriteRoot, features, parseOnly );
251+ std::string rewrite;
252+ exitCode = rewriteValueTree ( rewritePath, root, rewrite );
253+ if ( exitCode == 0 )
254+ {
255+ Json::Value rewriteRoot;
256+ exitCode = parseAndSaveValueTree ( rewrite, rewriteActualPath,
257+ " rewrite" , rewriteRoot, features, parseOnly );
258+ }
256259 }
257260 }
261+ catch ( const std::exception &e )
262+ {
263+ printf ( " Unhandled exception:\n %s\n " , e.what () );
264+ exitCode = 1 ;
265+ }
258266
259267 return exitCode;
260268}
0 commit comments