1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

revert changes in parse.c

This commit is contained in:
lurchi 2016-09-05 11:53:54 +02:00
parent 48b9e626ed
commit 2614da4953

View file

@ -119,7 +119,7 @@ psyc_parse_remaining_buffer (PsycParseState *state);
*
* @return PARSE_ERROR or PARSE_SUCCESS
*/
inline ParseRC
static inline ParseRC
parse_keyword (ParseState *state, PsycString *name)
{
name->data = state->buffer.data + state->cursor;
@ -138,7 +138,7 @@ parse_keyword (ParseState *state, PsycString *name)
*
* @return PARSE_SUCCESS, PARSE_ERROR or PARSE_INSUFFICIENT
*/
inline ParseRC
static inline ParseRC
parse_length (ParseState *state, size_t *len)
{
ParseRC ret = PARSE_ERROR;
@ -165,7 +165,7 @@ parse_length (ParseState *state, size_t *len)
*
* @return PARSE_SUCCESS or PARSE_INCOMPLETE
*/
inline ParseRC
static inline ParseRC
parse_binary (ParseState *state, size_t length, PsycString *value, size_t *parsed)
{
size_t remaining = length - *parsed;
@ -197,7 +197,7 @@ parse_binary (ParseState *state, size_t length, PsycString *value, size_t *parse
*
* @return PARSE_SUCCESS or PARSE_INSUFFICIENT
*/
inline ParseRC
static inline ParseRC
parse_until (ParseState *state, const char end, PsycString *value)
{
value->data = state->buffer.data + state->cursor;
@ -282,7 +282,7 @@ psyc_parse_modifier (PsycParseState *state, char *oper,
/** Parse PSYC packets. */
#ifdef __INLINE_PSYC_PARSE
extern inline
static inline
#endif
PsycParseRC
psyc_parse (PsycParseState *state, char *oper,
@ -573,9 +573,8 @@ psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem)
{
ParseRC ret;
if (state->cursor >= state->buffer.length) {
if (state->cursor >= state->buffer.length)
return PSYC_PARSE_LIST_END;
}
state->startc = state->cursor;
@ -640,7 +639,6 @@ psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem)
}
break;
case PARSE_INSUFFICIENT: // end of buffer
state->cursor = state->buffer.length;
return PSYC_PARSE_LIST_ELEM_LAST;
case PARSE_ERROR:
return PSYC_PARSE_LIST_ERROR_ELEM_TYPE;
@ -685,14 +683,12 @@ psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem)
switch (parse_binary((ParseState*)state, state->elemlen, elem,
&state->elem_parsed)) {
case PARSE_SUCCESS:
state->part = PSYC_LIST_PART_ELEM_START;
if (elem->length == state->elem_parsed)
ret = PSYC_PARSE_LIST_ELEM;
else
ret = PSYC_PARSE_LIST_ELEM_END;
break;
case PARSE_INCOMPLETE:
state->part = PSYC_LIST_PART_ELEM;
if (elem->length == state->elem_parsed)
ret = PSYC_PARSE_LIST_ELEM_START;
else
@ -704,17 +700,16 @@ psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem)
} else {
switch (parse_until((ParseState*)state, '|', elem)) {
case PARSE_SUCCESS:
state->part = PSYC_LIST_PART_ELEM_START;
ret = PSYC_PARSE_LIST_ELEM;
break;
case PARSE_INSUFFICIENT:
state->cursor = state->buffer.length;
return PSYC_PARSE_LIST_ELEM_LAST;
default: // should not be reached
return PSYC_PARSE_LIST_ERROR;
}
}
state->part = PSYC_LIST_PART_ELEM_START;
state->startc = state->cursor;
return ret;
}
@ -878,7 +873,6 @@ psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem)
}
break;
case PARSE_INSUFFICIENT: // end of buffer
//state->cursor = state->buffer.length;
return PSYC_PARSE_DICT_VALUE_LAST;
case PARSE_ERROR:
return PSYC_PARSE_DICT_ERROR_VALUE_TYPE;
@ -923,7 +917,6 @@ psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem)
switch (parse_binary((ParseState*)state, state->elemlen, elem,
&state->elem_parsed)) {
case PARSE_SUCCESS:
state->part = PSYC_DICT_PART_KEY_START;
if (elem->length == state->elem_parsed)
ret = PSYC_PARSE_DICT_VALUE;
else
@ -941,17 +934,16 @@ psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem)
} else {
switch (parse_until((ParseState*)state, '{', elem)) {
case PARSE_SUCCESS:
state->part = PSYC_DICT_PART_KEY_START;
ret = PSYC_PARSE_DICT_VALUE;
break;
case PARSE_INSUFFICIENT:
state->cursor = state->buffer.length;
return PSYC_PARSE_DICT_VALUE_LAST;
default: // should not be reached
return PSYC_PARSE_DICT_ERROR;
}
}
state->part = PSYC_DICT_PART_KEY_START;
return ret;
}
@ -1094,9 +1086,8 @@ psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value)
{
PsycParseIndexRC ret;
if (state->cursor >= state->buffer.length) {
if (state->cursor >= state->buffer.length)
return PSYC_PARSE_UPDATE_END;
}
state->startc = state->cursor;