Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ext/json/ext/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#if defined(RUBY_DEBUG) && RUBY_DEBUG
# define JSON_ASSERT RUBY_ASSERT
# ifndef JSON_DEBUG
# define JSON_DEBUG 1
# endif
#else
# ifdef JSON_DEBUG
# include <assert.h>
Expand All @@ -20,6 +23,11 @@
# endif
#endif

#ifdef JSON_DEBUG
# define JSON_UNREACHABLE_RETURN(val) rb_bug("Unreachable")
#else
# define JSON_UNREACHABLE_RETURN UNREACHABLE_RETURN
#endif
/* shims */

#if SIZEOF_UINT64_T == SIZEOF_LONG_LONG
Expand Down
20 changes: 10 additions & 10 deletions ext/json/ext/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
case JSON_PHASE_OBJECT_KEY: goto JSON_PHASE_OBJECT_KEY;
case JSON_PHASE_OBJECT_COLON: goto JSON_PHASE_OBJECT_COLON;
}
UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);

JSON_PHASE_DONE: {
// The root document value is parsed; it is the lone survivor on
Expand Down Expand Up @@ -1623,10 +1623,10 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
case JSON_PHASE_ARRAY_COMMA: goto JSON_PHASE_ARRAY_COMMA;
case JSON_PHASE_OBJECT_COMMA: goto JSON_PHASE_OBJECT_COMMA;
case JSON_PHASE_VALUE: goto JSON_PHASE_VALUE;
case JSON_PHASE_OBJECT_KEY: UNREACHABLE_RETURN(Qundef);
case JSON_PHASE_OBJECT_KEY: JSON_UNREACHABLE_RETURN(Qundef);
case JSON_PHASE_OBJECT_COLON: goto JSON_PHASE_OBJECT_COLON;
}
UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);
}

JSON_PHASE_OBJECT_KEY: {
Expand All @@ -1648,7 +1648,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
raise_parse_error("expected object key, got: %s", state);
}
}
UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);
}

JSON_PHASE_OBJECT_COLON: {
Expand All @@ -1669,7 +1669,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
raise_parse_error("expected ':' after object key, got: %s", state);
}
}
UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);
}

JSON_PHASE_ARRAY_COMMA: {
Expand Down Expand Up @@ -1705,13 +1705,13 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
case JSON_PHASE_ARRAY_COMMA: goto JSON_PHASE_ARRAY_COMMA;
case JSON_PHASE_OBJECT_COMMA: goto JSON_PHASE_OBJECT_COMMA;
case JSON_PHASE_VALUE: goto JSON_PHASE_VALUE;
case JSON_PHASE_OBJECT_KEY: UNREACHABLE_RETURN(Qundef);
case JSON_PHASE_OBJECT_KEY: JSON_UNREACHABLE_RETURN(Qundef);
case JSON_PHASE_OBJECT_COLON: goto JSON_PHASE_OBJECT_COLON;
}
} else {
raise_parse_error("expected ',' or ']' after array value", state);
}
UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);
}

JSON_PHASE_OBJECT_COMMA: {
Expand Down Expand Up @@ -1754,16 +1754,16 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
case JSON_PHASE_ARRAY_COMMA: goto JSON_PHASE_ARRAY_COMMA;
case JSON_PHASE_OBJECT_COMMA: goto JSON_PHASE_OBJECT_COMMA;
case JSON_PHASE_VALUE: goto JSON_PHASE_VALUE;
case JSON_PHASE_OBJECT_KEY: UNREACHABLE_RETURN(Qundef);
case JSON_PHASE_OBJECT_KEY: JSON_UNREACHABLE_RETURN(Qundef);
case JSON_PHASE_OBJECT_COLON: goto JSON_PHASE_OBJECT_COLON;
}
} else {
raise_parse_error("expected ',' or '}' after object value, got: %s", state);
}
UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);
}

UNREACHABLE_RETURN(Qundef);
JSON_UNREACHABLE_RETURN(Qundef);
}

static void json_ensure_eof(JSON_ParserState *state)
Expand Down
Loading