--- libelwix/src/json.c 2017/11/28 11:14:00 1.1.2.6 +++ libelwix/src/json.c 2017/11/28 14:57:45 1.1.2.8 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: json.c,v 1.1.2.6 2017/11/28 11:14:00 misho Exp $ +* $Id: json.c,v 1.1.2.8 2017/11/28 14:57:45 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -325,10 +325,8 @@ json_parse(json_t * __restrict json, const char *jstr, } break; case '\"': - if (json_parse_string(json, jstr, jlen, jtoks, toksnum) == -1) { - elwix_SetErr(J_ERR_INVAL, "%s", jerrstr[J_ERR_INVAL]); + if (json_parse_string(json, jstr, jlen, jtoks, toksnum) == -1) return (u_int) -1; - } cx++; /* start new string token */ if (jtoks && json->h_parent != -1) jtoks[json->h_parent].tok_size++; @@ -428,8 +426,8 @@ json_token2val(const char *jstr, jtok_t * __restrict t if (!v) return NULL; - AIT_SET_STRSIZ(v, tok->tok_end - tok->tok_start); - strncpy(AIT_GET_STR(v), jstr + tok->tok_start, AIT_LEN(v) - 1); + AIT_SET_STRSIZ(v, json_toklen(tok)); + strncpy(AIT_GET_STR(v), json_tokstr(jstr, tok), AIT_LEN(v) - 1); return v; } @@ -450,12 +448,12 @@ json_token2str(const char *jstr, jtok_t * __restrict t if (!jstr || !tok) return NULL; - len = tok->tok_end - tok->tok_start; + len = json_toklen(tok); str = e_malloc(len + 1); if (!str) return NULL; else { - strncpy(str, jstr + tok->tok_start, len); + strncpy(str, json_tokstr(jstr, tok), len); str[len] = 0; }