unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/2] Use Jansson's error code support if available
@ 2017-12-18 23:17 Philipp Stephani
  2017-12-18 23:17 ` [PATCH 2/2] JSON serialization: reject duplicate keys in hashtables Philipp Stephani
  2017-12-19 17:11 ` [PATCH 1/2] Use Jansson's error code support if available Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Philipp Stephani @ 2017-12-18 23:17 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

* 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 29e4400fc9..b996cad5a6 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),
-- 
2.15.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-12-24 12:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-18 23:17 [PATCH 1/2] Use Jansson's error code support if available Philipp Stephani
2017-12-18 23:17 ` [PATCH 2/2] JSON serialization: reject duplicate keys in hashtables Philipp Stephani
2017-12-24 12:53   ` Philipp Stephani
2017-12-19 17:11 ` [PATCH 1/2] Use Jansson's error code support if available Eli Zaretskii
2017-12-19 17:35   ` Philipp Stephani
2017-12-19 19:54     ` Eli Zaretskii
2017-12-19 21:49       ` Philipp Stephani

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).