Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Fixed a C99/C++ism. Added json_new_string_f() (printf-style). |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | json-multitag-test | json |
| Files: | files | file ages | folders |
| SHA1: |
f5cc421dc20b41a3b93fe4408a52b052 |
| User & Date: | stephan 2011-10-19 20:54:32.339 |
Context
|
2011-10-19
| ||
| 21:13 | s/fossil_is_json/fossil_has_json/g. Moved fossil_has_json() (nee fossil_is_json()) decl/docs to json_detail.h. ... (check-in: d2c1ae23a9 user: stephan tags: json-multitag-test, json) | |
| 20:54 | Fixed a C99/C++ism. Added json_new_string_f() (printf-style). ... (check-in: f5cc421dc2 user: stephan tags: json-multitag-test, json) | |
| 20:36 | A number of small doc improvements. ... (check-in: fa17e0980c user: stephan tags: json-multitag-test, json) | |
Changes
Changes to src/json.c.
| ︙ | ︙ | |||
394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
}
cson_value * json_new_string( char const * str ){
return str
? cson_value_new_string(str,strlen(str))
: NULL;
}
cson_value * json_new_int( int v ){
return cson_value_new_integer((cson_int_t)v);
}
/*
** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory
| > > > > > > > > > > > > | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
}
cson_value * json_new_string( char const * str ){
return str
? cson_value_new_string(str,strlen(str))
: NULL;
}
cson_value * json_new_string_f( char const * fmt, ... ){
cson_value * v;
char * zStr;
va_list vargs;
va_start(vargs,fmt);
zStr = vmprintf(fmt,vargs);
va_end(vargs);
v = cson_value_new_string(zStr, strlen(zStr));
free(zStr);
return v;
}
cson_value * json_new_int( int v ){
return cson_value_new_integer((cson_int_t)v);
}
/*
** Gets a POST/POST.payload/GET/COOKIE/ENV value. The returned memory
|
| ︙ | ︙ | |||
881 882 883 884 885 886 887 888 |
cson_array_append(g.json.warnings.a, cson_object_value(obj));
cson_object_set(obj,"code",cson_value_new_integer(code));
if(fmt && *fmt){
/* FIXME: treat NULL fmt as standard warning message for
the code, but we don't have those yet.
*/
va_list vargs;
va_start(vargs,fmt);
| > | | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
cson_array_append(g.json.warnings.a, cson_object_value(obj));
cson_object_set(obj,"code",cson_value_new_integer(code));
if(fmt && *fmt){
/* FIXME: treat NULL fmt as standard warning message for
the code, but we don't have those yet.
*/
va_list vargs;
char * msg;
va_start(vargs,fmt);
msg = vmprintf(fmt,vargs);
va_end(vargs);
cson_object_set(obj,"text", cson_value_new_string(msg,strlen(msg)));
free(msg);
}
}
/*
|
| ︙ | ︙ |
Changes to src/json_detail.h.
| ︙ | ︙ | |||
214 215 216 217 218 219 220 221 | /* ** Convenience wrapper around cson_value_new_string(). ** Returns NULL if str is NULL or on allocation error. */ cson_value * json_new_string( char const * str ); #endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/ | > > > > > > > > > > > > | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | /* ** Convenience wrapper around cson_value_new_string(). ** Returns NULL if str is NULL or on allocation error. */ cson_value * json_new_string( char const * str ); /* ** Similar to json_new_string(), but takes a printf()-style format ** specifiers. Supports the printf extensions supported by fossil's ** mprintf(). Returns NULL if str is NULL or on allocation error. ** ** Maintenance note: json_new_string() is NOT variadic because by the ** time the variadic form was introduced we already had use cases ** which segfaulted via json_new_string() because they contain printf ** markup (e.g. wiki content). Been there, debugged that. */ cson_value * json_new_string_f( char const * fmt, ... ); #endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/ |