MCPcopy Create free account
hub / github.com/crownengine/crown / skip_value

Function skip_value

src/core/json/sjson.cpp:145–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143 }
144
145 static const char *skip_value(const char *json)
146 {
147 if (json == NULL) {
148 fatal("json is NULL");
149 return NULL;
150 }
151
152 switch (*json) {
153 case '"':
154 if (strncmp(json, "\"\"\"", 3) == 0) {
155 json = strstr(json + 3, "\"\"\"");
156 if (json == NULL) {
157 fatal("Bad verbatim string");
158 return NULL;
159 }
160
161 while (strncmp(json + 1, "\"\"\"", 3) == 0)
162 ++json;
163
164 json += 3;
165 } else {
166 json = skip_string(json);
167 if (json == NULL)
168 return NULL;
169
170 if (*json == '"') {
171 fatal("Bad string");
172 return NULL;
173 }
174 }
175 break;
176
177 case '[':
178 case '{': {
179 u32 num = 0;
180 char aa = *json;
181 char bb = aa + 2; // Matching brace/bracket.
182
183 while (*json != '\0') {
184 if (*json == aa) {
185 ++json;
186 ++num;
187 } else if (*json == bb) {
188 ++json;
189 if (--num == 0)
190 break;
191 } else if (*json == '"') {
192 json = skip_string(json);
193 if (json == NULL)
194 return NULL;
195
196 if (*json == '"') {
197 json = strstr(json + 1, "\"\"\"");
198 if (json == NULL) {
199 fatal("Bad verbatim string");
200 return NULL;
201 }
202 json += 3;

Callers 3

parse_arrayFunction · 0.70
parse_root_objectFunction · 0.70
parse_objectFunction · 0.70

Calls 5

strncmpFunction · 0.85
strstrFunction · 0.85
skip_commentsFunction · 0.85
fatalFunction · 0.70
skip_stringFunction · 0.70

Tested by

no test coverage detected