From: Christopher Watford Date: Wed, 8 Jul 2009 04:02:05 +0000 (+0000) Subject: Add const qualifier to the json_tokener_parse functions X-Git-Tag: json-c-0.10-20120530~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1a22ac85f8251688f77da52d000958fab3a8d66;p=thirdparty%2Fjson-c.git Add const qualifier to the json_tokener_parse functions Eric Haszlakiewicz, EHASZLA at transunion dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@42 327403b1-1117-474d-bef2-5cb71233fd97 --- diff --git a/json_tokener.c b/json_tokener.c index a1951b90..02facda0 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -99,7 +99,7 @@ void json_tokener_reset(struct json_tokener *tok) tok->err = json_tokener_success; } -struct json_object* json_tokener_parse(char *str) +struct json_object* json_tokener_parse(const char *str) { struct json_tokener* tok; struct json_object* obj; @@ -180,7 +180,7 @@ char* strndup(const char* str, size_t n) struct json_object* json_tokener_parse_ex(struct json_tokener *tok, - char *str, int len) + const char *str, int len) { struct json_object *obj = NULL; char c = '\1'; @@ -305,7 +305,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_comment: { /* Advance until we change state */ - char *case_start = str; + const char *case_start = str; while(c != '*') { if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) { printbuf_memappend_fast(tok->pb, case_start, str-case_start); @@ -320,7 +320,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_comment_eol: { /* Advance until we change state */ - char *case_start = str; + const char *case_start = str; while(c != '\n') { if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) { printbuf_memappend_fast(tok->pb, case_start, str-case_start); @@ -346,7 +346,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_string: { /* Advance until we change state */ - char *case_start = str; + const char *case_start = str; while(1) { if(c == tok->quote_char) { printbuf_memappend_fast(tok->pb, case_start, str-case_start); @@ -464,7 +464,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_number: { /* Advance until we change state */ - char *case_start = str; + const char *case_start = str; int case_len=0; while(c && strchr(json_number_chars, c)) { ++case_len; @@ -546,7 +546,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, case json_tokener_state_object_field: { /* Advance until we change state */ - char *case_start = str; + const char *case_start = str; while(1) { if(c == tok->quote_char) { printbuf_memappend_fast(tok->pb, case_start, str-case_start); diff --git a/json_tokener.h b/json_tokener.h index 59035bb6..7d40b40a 100644 --- a/json_tokener.h +++ b/json_tokener.h @@ -87,9 +87,9 @@ extern const char* json_tokener_errors[]; extern struct json_tokener* json_tokener_new(void); extern void json_tokener_free(struct json_tokener *tok); extern void json_tokener_reset(struct json_tokener *tok); -extern struct json_object* json_tokener_parse(char *str); +extern struct json_object* json_tokener_parse(const char *str); extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok, - char *str, int len); + const char *str, int len); #ifdef __cplusplus }