]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix the native JSON support code
authorEli Zaretskii <eliz@gnu.org>
Sat, 30 Mar 2024 16:33:23 +0000 (19:33 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 30 Mar 2024 19:37:39 +0000 (20:37 +0100)
* src/Makefile.in (base_obj): Add the missing json.o.  Without
this, we get link error.
* src/json.c (json_serialize): Don't use too sophisticated C99
features, as they confuse make-docfile.  Initialize all the
members explicitly.

(cherry picked from commit 000f919b3c7779609dc43773fdc49aca9b50d76f)

src/Makefile.in
src/json.c

index f58a3a7761e7dfe17e7b62dea5d57c1fd054811e..9dd88895d27b60393d366915559a4224ce360047 100644 (file)
@@ -472,7 +472,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o     \
        $(XWIDGETS_OBJ)                                                        \
        profiler.o decompress.o                                                \
        thread.o systhread.o sqlite.o  treesit.o                               \
-       itree.o                                                                \
+       itree.o json.o                                                         \
        $(if $(HYBRID_MALLOC),sheap.o)                                         \
        $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ)        \
        $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ)                            \
index 43b2d1cb4f8b1151a746cf00f2794397a66da6a9..5970c539f539fc6d20d0e16c699e0446b11b538f 100644 (file)
@@ -568,13 +568,17 @@ static void
 json_serialize (json_out_t *jo, Lisp_Object object,
                ptrdiff_t nargs, Lisp_Object *args)
 {
-  *jo = (json_out_t) {
-    /* The maximum nesting depth allowed should be sufficient for most
-       uses but could be raised if necessary.  (The default maximum
-       depth for JSON_checker is 20.)  */
-    .maxdepth = 50,
-    .conf = {json_object_hashtable, json_array_array, QCnull, QCfalse}
-  };
+  jo->maxdepth = 50;
+  jo->size = 0;
+  jo->capacity = 0;
+  jo->chars_delta = 0;
+  jo->buf = NULL;
+  jo->ss_table = NULL;
+  jo->conf.object_type = json_object_hashtable;
+  jo->conf.array_type = json_array_array;
+  jo->conf.null_object = QCnull;
+  jo->conf.false_object = QCfalse;
+
   json_parse_args (nargs, args, &jo->conf, false);
   record_unwind_protect_ptr (cleanup_json_out, jo);