Browse Source

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
tags/json-c-0.10-20120530
Christopher Watford 16 years ago
parent
commit
b1a22ac85f
2 changed files with 9 additions and 9 deletions
  1. +7
    -7
      json_tokener.c
  2. +2
    -2
      json_tokener.h

+ 7
- 7
json_tokener.c View File

@@ -99,7 +99,7 @@ void json_tokener_reset(struct json_tokener *tok)
tok->err = json_tokener_success; 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_tokener* tok;
struct json_object* obj; 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, 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; struct json_object *obj = NULL;
char c = '\1'; char c = '\1';
@@ -305,7 +305,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
case json_tokener_state_comment: case json_tokener_state_comment:
{ {
/* Advance until we change state */ /* Advance until we change state */
char *case_start = str;
const char *case_start = str;
while(c != '*') { while(c != '*') {
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) { if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
printbuf_memappend_fast(tok->pb, case_start, str-case_start); 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: case json_tokener_state_comment_eol:
{ {
/* Advance until we change state */ /* Advance until we change state */
char *case_start = str;
const char *case_start = str;
while(c != '\n') { while(c != '\n') {
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) { if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
printbuf_memappend_fast(tok->pb, case_start, str-case_start); 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: case json_tokener_state_string:
{ {
/* Advance until we change state */ /* Advance until we change state */
char *case_start = str;
const char *case_start = str;
while(1) { while(1) {
if(c == tok->quote_char) { if(c == tok->quote_char) {
printbuf_memappend_fast(tok->pb, case_start, str-case_start); 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: case json_tokener_state_number:
{ {
/* Advance until we change state */ /* Advance until we change state */
char *case_start = str;
const char *case_start = str;
int case_len=0; int case_len=0;
while(c && strchr(json_number_chars, c)) { while(c && strchr(json_number_chars, c)) {
++case_len; ++case_len;
@@ -546,7 +546,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
case json_tokener_state_object_field: case json_tokener_state_object_field:
{ {
/* Advance until we change state */ /* Advance until we change state */
char *case_start = str;
const char *case_start = str;
while(1) { while(1) {
if(c == tok->quote_char) { if(c == tok->quote_char) {
printbuf_memappend_fast(tok->pb, case_start, str-case_start); printbuf_memappend_fast(tok->pb, case_start, str-case_start);


+ 2
- 2
json_tokener.h View File

@@ -87,9 +87,9 @@ extern const char* json_tokener_errors[];
extern struct json_tokener* json_tokener_new(void); extern struct json_tokener* json_tokener_new(void);
extern void json_tokener_free(struct json_tokener *tok); extern void json_tokener_free(struct json_tokener *tok);
extern void json_tokener_reset(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, extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
char *str, int len);
const char *str, int len);


#ifdef __cplusplus #ifdef __cplusplus
} }


Loading…
Cancel
Save