diff options
| author | Eli Zaretskii | 2022-12-26 15:26:48 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2022-12-26 15:26:48 +0200 |
| commit | 26b2ec7cb8c81db7d8705cb87579b325901ed303 (patch) | |
| tree | fb6036fa6f0a342c777e0a267ec511125f5d0602 /src | |
| parent | 082fc6e3088354f16ab8293725cc727a9855359b (diff) | |
| download | emacs-26b2ec7cb8c81db7d8705cb87579b325901ed303.tar.gz emacs-26b2ec7cb8c81db7d8705cb87579b325901ed303.zip | |
Simplify last change (bug#60311)
* src/json.c (json_available_p): Use original code. Always return
true for !WINDOWSNT.
(ensure_json_available): Now defined only on WINDOWSNT.
(Fjson_serialize, Fjson_insert, Fjson_parse_string)
(Fjson_parse_buffer): Call ensure_json_available only on
WINDOWSNT.
* lisp/subr.el (json-available-p): Simplify.
Diffstat (limited to 'src')
| -rw-r--r-- | src/json.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/json.c b/src/json.c index d2105bc27b1..621c7d7c15f 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -555,37 +555,39 @@ json_parse_args (ptrdiff_t nargs, | |||
| 555 | } | 555 | } |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | #ifdef WINDOWSNT | ||
| 559 | static bool | 558 | static bool |
| 560 | json_available_p (void) | 559 | json_available_p (void) |
| 561 | { | 560 | { |
| 562 | if (json_initialized) | 561 | #ifdef WINDOWSNT |
| 563 | return true; | 562 | if (!json_initialized) |
| 564 | json_initialized = init_json_functions (); | 563 | { |
| 565 | Lisp_Object status = json_initialized ? Qt : Qnil; | 564 | Lisp_Object status; |
| 566 | Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache); | 565 | json_initialized = init_json_functions (); |
| 566 | status = json_initialized ? Qt : Qnil; | ||
| 567 | Vlibrary_cache = Fcons (Fcons (Qjson, status), Vlibrary_cache); | ||
| 568 | } | ||
| 567 | return json_initialized; | 569 | return json_initialized; |
| 568 | } | 570 | #else /* !WINDOWSNT */ |
| 571 | return true; | ||
| 569 | #endif | 572 | #endif |
| 573 | } | ||
| 570 | 574 | ||
| 575 | #ifdef WINDOWSNT | ||
| 571 | static void | 576 | static void |
| 572 | ensure_json_available (void) | 577 | ensure_json_available (void) |
| 573 | { | 578 | { |
| 574 | #ifdef WINDOWSNT | ||
| 575 | if (!json_available_p ()) | 579 | if (!json_available_p ()) |
| 576 | Fsignal (Qjson_unavailable, | 580 | Fsignal (Qjson_unavailable, |
| 577 | list1 (build_unibyte_string ("jansson library not found"))); | 581 | list1 (build_unibyte_string ("jansson library not found"))); |
| 578 | #endif | ||
| 579 | } | 582 | } |
| 583 | #endif | ||
| 580 | 584 | ||
| 581 | #ifdef WINDOWSNT | ||
| 582 | DEFUN ("json--available-p", Fjson__available_p, Sjson__available_p, 0, 0, NULL, | 585 | DEFUN ("json--available-p", Fjson__available_p, Sjson__available_p, 0, 0, NULL, |
| 583 | doc: /* Whether libjansson is available (internal). */) | 586 | doc: /* Return non-nil if libjansson is available (internal use only). */) |
| 584 | (void) | 587 | (void) |
| 585 | { | 588 | { |
| 586 | return json_available_p () ? Qt : Qnil; | 589 | return json_available_p () ? Qt : Qnil; |
| 587 | } | 590 | } |
| 588 | #endif | ||
| 589 | 591 | ||
| 590 | DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY, | 592 | DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY, |
| 591 | NULL, | 593 | NULL, |
| @@ -617,7 +619,10 @@ usage: (json-serialize OBJECT &rest ARGS) */) | |||
| 617 | (ptrdiff_t nargs, Lisp_Object *args) | 619 | (ptrdiff_t nargs, Lisp_Object *args) |
| 618 | { | 620 | { |
| 619 | specpdl_ref count = SPECPDL_INDEX (); | 621 | specpdl_ref count = SPECPDL_INDEX (); |
| 622 | |||
| 623 | #ifdef WINDOWSNT | ||
| 620 | ensure_json_available (); | 624 | ensure_json_available (); |
| 625 | #endif | ||
| 621 | 626 | ||
| 622 | struct json_configuration conf = | 627 | struct json_configuration conf = |
| 623 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | 628 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; |
| @@ -714,7 +719,10 @@ usage: (json-insert OBJECT &rest ARGS) */) | |||
| 714 | (ptrdiff_t nargs, Lisp_Object *args) | 719 | (ptrdiff_t nargs, Lisp_Object *args) |
| 715 | { | 720 | { |
| 716 | specpdl_ref count = SPECPDL_INDEX (); | 721 | specpdl_ref count = SPECPDL_INDEX (); |
| 722 | |||
| 723 | #ifdef WINDOWSNT | ||
| 717 | ensure_json_available (); | 724 | ensure_json_available (); |
| 725 | #endif | ||
| 718 | 726 | ||
| 719 | struct json_configuration conf = | 727 | struct json_configuration conf = |
| 720 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | 728 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; |
| @@ -959,7 +967,10 @@ usage: (json-parse-string STRING &rest ARGS) */) | |||
| 959 | (ptrdiff_t nargs, Lisp_Object *args) | 967 | (ptrdiff_t nargs, Lisp_Object *args) |
| 960 | { | 968 | { |
| 961 | specpdl_ref count = SPECPDL_INDEX (); | 969 | specpdl_ref count = SPECPDL_INDEX (); |
| 970 | |||
| 971 | #ifdef WINDOWSNT | ||
| 962 | ensure_json_available (); | 972 | ensure_json_available (); |
| 973 | #endif | ||
| 963 | 974 | ||
| 964 | Lisp_Object string = args[0]; | 975 | Lisp_Object string = args[0]; |
| 965 | CHECK_STRING (string); | 976 | CHECK_STRING (string); |
| @@ -1044,7 +1055,10 @@ usage: (json-parse-buffer &rest args) */) | |||
| 1044 | (ptrdiff_t nargs, Lisp_Object *args) | 1055 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1045 | { | 1056 | { |
| 1046 | specpdl_ref count = SPECPDL_INDEX (); | 1057 | specpdl_ref count = SPECPDL_INDEX (); |
| 1058 | |||
| 1059 | #ifdef WINDOWSNT | ||
| 1047 | ensure_json_available (); | 1060 | ensure_json_available (); |
| 1061 | #endif | ||
| 1048 | 1062 | ||
| 1049 | struct json_configuration conf = | 1063 | struct json_configuration conf = |
| 1050 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | 1064 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; |
| @@ -1121,9 +1135,7 @@ syms_of_json (void) | |||
| 1121 | DEFSYM (Qplist, "plist"); | 1135 | DEFSYM (Qplist, "plist"); |
| 1122 | DEFSYM (Qarray, "array"); | 1136 | DEFSYM (Qarray, "array"); |
| 1123 | 1137 | ||
| 1124 | #ifdef WINDOWSNT | ||
| 1125 | defsubr (&Sjson__available_p); | 1138 | defsubr (&Sjson__available_p); |
| 1126 | #endif | ||
| 1127 | defsubr (&Sjson_serialize); | 1139 | defsubr (&Sjson_serialize); |
| 1128 | defsubr (&Sjson_insert); | 1140 | defsubr (&Sjson_insert); |
| 1129 | defsubr (&Sjson_parse_string); | 1141 | defsubr (&Sjson_parse_string); |