[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 24efda1: Use Jansson's error code support if availa
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master 24efda1: Use Jansson's error code support if available |
Date: |
Tue, 19 Dec 2017 16:48:36 -0500 (EST) |
branch: master
commit 24efda1d28496d4eeadf794033f9d6f52b08f0e1
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Use Jansson's error code support if available
* src/json.c (json_parse_error): Use Jansson's error code support if
available.
---
src/json.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/json.c b/src/json.c
index 47c5b8f..1c9bf6d 100644
--- a/src/json.c
+++ b/src/json.c
@@ -249,15 +249,24 @@ static _Noreturn void
json_parse_error (const json_error_t *error)
{
Lisp_Object symbol;
- /* FIXME: Upstream Jansson should have a way to return error codes
- without parsing the error messages. See
- https://github.com/akheron/jansson/issues/352. */
+#if JANSSON_VERSION_HEX >= 0x020B00
+ switch (json_error_code (error))
+ {
+ case json_error_premature_end_of_input:
+ symbol = Qjson_end_of_file;
+ case json_error_end_of_input_expected:
+ symbol = Qjson_trailing_content;
+ default:
+ symbol = Qjson_parse_error;
+ }
+#else
if (json_has_suffix (error->text, "expected near end of file"))
symbol = Qjson_end_of_file;
else if (json_has_prefix (error->text, "end of file expected"))
symbol = Qjson_trailing_content;
else
symbol = Qjson_parse_error;
+#endif
xsignal (symbol,
list5 (json_build_string (error->text),
json_build_string (error->source), make_natnum (error->line),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 24efda1: Use Jansson's error code support if available,
Philipp Stephani <=