From bfea37532aef763ad3ebe1b2c74edfbebbadaf14 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 30 Mar 2024 19:33:23 +0300 Subject: [PATCH] Fix the native JSON support code * 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 | 2 +- src/json.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Makefile.in b/src/Makefile.in index f58a3a7761e..9dd88895d27 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -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) \ diff --git a/src/json.c b/src/json.c index 43b2d1cb4f8..5970c539f53 100644 --- a/src/json.c +++ b/src/json.c @@ -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); -- 2.39.5