Skip to content

Commit

Permalink
Omit Obj/Arr open token from jsonTokenIsValue() test
Browse files Browse the repository at this point in the history
More correct, less caller specific.
  • Loading branch information
jgarzik committed Nov 7, 2015
1 parent bfef9e2 commit eb6cd64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions include/univalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ extern const char *uvTypeName(UniValue::VType t);
static inline bool jsonTokenIsValue(enum jtokentype jtt)
{
switch (jtt) {
case JTOK_OBJ_OPEN:
case JTOK_ARR_OPEN:
case JTOK_KW_NULL:
case JTOK_KW_TRUE:
case JTOK_KW_FALSE:
Expand Down
7 changes: 4 additions & 3 deletions lib/univalue_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,16 @@ bool UniValue::read(const char *raw)
return false;
raw += consumed;

bool isValue = jsonTokenIsValue(tok);
bool isValueOpen = jsonTokenIsValue(tok) ||
tok == JTOK_OBJ_OPEN || tok == JTOK_ARR_OPEN;

if (expect(VALUE)) {
if (!isValue)
if (!isValueOpen)
return false;
clearExpect(VALUE);

} else if (expect(ARR_VALUE)) {
bool isArrValue = isValue || (tok == JTOK_ARR_CLOSE);
bool isArrValue = isValueOpen || (tok == JTOK_ARR_CLOSE);
if (!isArrValue)
return false;

Expand Down

0 comments on commit eb6cd64

Please sign in to comment.