@@ -45,42 +45,28 @@ static int lept_parse_false(lept_context* c, lept_value* v) {
4545}
4646
4747static  int  lept_parse_value (lept_context *  c , lept_value *  v ) {
48-     int  ret_code  =  -1 ;
49- 
5048    switch  (* c  -> json ) {
51-         case  'n' :
52-             ret_code  =  lept_parse_null (c , v );
53-             break ;
54-         case  't' :
55-             ret_code  =  lept_parse_true (c , v );
56-             break ;
57-         case  'f' :
58-             ret_code  =  lept_parse_false (c , v );
59-             break ;
49+         case  'n' : return  lept_parse_null (c , v );
50+         case  't' : return  lept_parse_true (c , v );
51+         case  'f' : return  lept_parse_false (c , v );
6052        case  '\0' : return  LEPT_PARSE_EXPECT_VALUE ;
6153        default :   return  LEPT_PARSE_INVALID_VALUE ;
6254    }
63- 
64-     if  (c -> json [0 ] ==  ' ' ) {
65-         lept_parse_whitespace (c );
66- 
67-         if  (c -> json [0 ] !=  '\0' )
68-             return  LEPT_PARSE_ROOT_NOT_SINGULAR ;
69-         else  {
70-             return  ret_code ;
71-         }
72-     }
73- 
74-     return  ret_code ;
7555}
7656
7757int  lept_parse (lept_value *  v , const  char *  json ) {
7858    lept_context  c ;
59+     int  ret ;
7960    assert (v  !=  NULL );
8061    c .json  =  json ;
8162    v -> type  =  LEPT_NULL ;
8263    lept_parse_whitespace (& c );
83-     return  lept_parse_value (& c , v );
64+     if  ((ret  =  lept_parse_value (& c , v )) ==  LEPT_PARSE_OK ) {
65+         lept_parse_whitespace (& c );
66+         if  (* c .json  !=  '\0' )
67+             ret  =  LEPT_PARSE_ROOT_NOT_SINGULAR ;
68+     }
69+     return  ret ;
8470}
8571
8672lept_type  lept_get_type (const  lept_value *  v ) {
0 commit comments