X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fjson.c;h=f0b6456aae8c7ffe417558aea9796c83688dbefe;hb=25f78c28faf4f3e059a006c8423b701fe9e9e77c;hp=0a8bca27814ba692f817878dc2ccefca83e7e599;hpb=bf9712678fc9ec85bf2ac54407e16d76aa22e7b6;p=openvswitch diff --git a/lib/json.c b/lib/json.c index 0a8bca27..f0b6456a 100644 --- a/lib/json.c +++ b/lib/json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "dynamic-string.h" @@ -297,14 +296,14 @@ struct json_array * json_array(const struct json *json) { assert(json->type == JSON_ARRAY); - return (struct json_array *) &json->u.array; + return CONST_CAST(struct json_array *, &json->u.array); } struct shash * json_object(const struct json *json) { assert(json->type == JSON_OBJECT); - return (struct shash *) json->u.object; + return CONST_CAST(struct shash *, json->u.object); } bool @@ -909,14 +908,6 @@ json_lex_input(struct json_parser *p, unsigned char c) { struct json_token token; - p->byte_number++; - if (c == '\n') { - p->column_number = 0; - p->line_number++; - } else { - p->column_number++; - } - switch (p->lex_state) { case JSON_LEX_START: switch (c) { @@ -1093,6 +1084,13 @@ json_parser_feed(struct json_parser *p, const char *input, size_t n) size_t i; for (i = 0; !p->done && i < n; ) { if (json_lex_input(p, input[i])) { + p->byte_number++; + if (input[i] == '\n') { + p->column_number = 0; + p->line_number++; + } else { + p->column_number++; + } i++; } }