aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2017-12-22 02:02:24 +0100
committerPhilipp Stephani2017-12-22 02:02:24 +0100
commitc99f0312129a189768d7139ecef93ddbdfa3622b (patch)
tree57a22cb6df2f2bf0706681b9916cad9823b1da0d /src
parent1498ed3705a9b7c3340e5b42186736bf5ce5f8bb (diff)
downloademacs-c99f0312129a189768d7139ecef93ddbdfa3622b.tar.gz
emacs-c99f0312129a189768d7139ecef93ddbdfa3622b.zip
JSON: improve some comments
* src/json.c (json_make_string, json_build_string): Document why these functions are OK as-is.
Diffstat (limited to 'src')
-rw-r--r--src/json.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/json.c b/src/json.c
index 48cf96a62b9..689f6ac510e 100644
--- a/src/json.c
+++ b/src/json.c
@@ -208,25 +208,28 @@ json_has_suffix (const char *string, const char *suffix)
208 208
209/* Create a multibyte Lisp string from the UTF-8 string in 209/* Create a multibyte Lisp string from the UTF-8 string in
210 [DATA, DATA + SIZE). If the range [DATA, DATA + SIZE) does not 210 [DATA, DATA + SIZE). If the range [DATA, DATA + SIZE) does not
211 contain a valid UTF-8 string, an unspecified string is 211 contain a valid UTF-8 string, an unspecified string is returned.
212 returned. */ 212 Note that all callers below either pass only value UTF-8 strings or
213 use this function for formatting error messages; in the latter case
214 correctness isn't critical. */
213 215
214static Lisp_Object 216static Lisp_Object
215json_make_string (const char *data, ptrdiff_t size) 217json_make_string (const char *data, ptrdiff_t size)
216{ 218{
217 /* FIXME: Raise an error if DATA is not a UTF-8 string. */
218 return code_convert_string (make_specified_string (data, -1, size, false), 219 return code_convert_string (make_specified_string (data, -1, size, false),
219 Qutf_8_unix, Qt, false, true, true); 220 Qutf_8_unix, Qt, false, true, true);
220} 221}
221 222
222/* Create a multibyte Lisp string from the null-terminated UTF-8 223/* Create a multibyte Lisp string from the null-terminated UTF-8
223 string beginning at DATA. If the string is not a valid UTF-8 224 string beginning at DATA. If the string is not a valid UTF-8
224 string, an unspecified string is returned. */ 225 string, an unspecified string is returned. Note that all callers
226 below either pass only value UTF-8 strings or use this function for
227 formatting error messages; in the latter case correctness isn't
228 critical. */
225 229
226static Lisp_Object 230static Lisp_Object
227json_build_string (const char *data) 231json_build_string (const char *data)
228{ 232{
229 /* FIXME: Raise an error if DATA is not a UTF-8 string. */
230 return json_make_string (data, strlen (data)); 233 return json_make_string (data, strlen (data));
231} 234}
232 235