diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-07-26 16:55:59 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-07-26 16:55:59 -0400 |
commit | 0f09808e522cd3de6bd9ea1350beed1feddfbda9 (patch) | |
tree | 6831e3a40ff70ab0091cd691bbcdc37d14153d6e /src/json.c | |
parent | 0dc5a85a1c3772a6e78f077719d82f437f626b1e (diff) | |
download | emacs-0f09808e522cd3de6bd9ea1350beed1feddfbda9.tar.gz |
Adjust remaining uses of `NILP (HASH_HASH)`.
* src/json.c (lisp_to_json_toplevel_1):
* src/pdumper.c (dump_hash_table_stable_p, hash_table_contents):
* src/print.c (print, print_vectorlike):
* src/minibuf.c (Ftry_completion, Fall_completions, Ftest_completion):
Use `EQ (HASH_KEY, Qunbound)` instead of `NILP (HASH_HASH)`.
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/json.c b/src/json.c index d05f2c54e2c..5a3d0012f0a 100644 --- a/src/json.c +++ b/src/json.c @@ -361,28 +361,31 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp, count = SPECPDL_INDEX (); record_unwind_protect_ptr (json_release_object, json); for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i) - if (!NILP (HASH_HASH (h, i))) - { - Lisp_Object key = json_encode (HASH_KEY (h, i)); - /* We can't specify the length, so the string must be + { + Lisp_Object key = HASH_KEY (h, i); + if (!EQ (key, Qunbound)) + { + Lisp_Object ekey = json_encode (key); + /* We can't specify the length, so the string must be NUL-terminated. */ - check_string_without_embedded_nuls (key); - const char *key_str = SSDATA (key); - /* Reject duplicate keys. These are possible if the hash + check_string_without_embedded_nuls (ekey); + const char *key_str = SSDATA (ekey); + /* Reject duplicate keys. These are possible if the hash table test is not `equal'. */ - if (json_object_get (json, key_str) != NULL) - wrong_type_argument (Qjson_value_p, lisp); - int status = json_object_set_new (json, key_str, - lisp_to_json (HASH_VALUE (h, i), - conf)); - if (status == -1) - { - /* A failure can be caused either by an invalid key or + if (json_object_get (json, key_str) != NULL) + wrong_type_argument (Qjson_value_p, lisp); + int status + = json_object_set_new (json, key_str, + lisp_to_json (HASH_VALUE (h, i), conf)); + if (status == -1) + { + /* A failure can be caused either by an invalid key or by low memory. */ - json_check_utf8 (key); - json_out_of_memory (); - } - } + json_check_utf8 (ekey); + json_out_of_memory (); + } + } + } } else if (NILP (lisp)) return json_check (json_object ()); |