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 ());
else /* if (type == hash_table) */
{
while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
- && NILP (HASH_HASH (XHASH_TABLE (collection), idx)))
+ && EQ (HASH_KEY (XHASH_TABLE (collection), idx), Qunbound))
idx++;
if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
break;
else /* if (type == 3) */
{
while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
- && NILP (HASH_HASH (XHASH_TABLE (collection), idx)))
+ && EQ (HASH_KEY (XHASH_TABLE (collection), idx), Qunbound))
idx++;
if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
break;
else
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
{
- if (NILP (HASH_HASH (h, i))) continue;
tem = HASH_KEY (h, i);
+ if (EQ (tem, Qunbound)) continue;
Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem);
if (!STRINGP (strkey)) continue;
if (EQ (Fcompare_strings (string, Qnil, Qnil,
bool is_equal = hash->test.hashfn == hashfn_equal;
ptrdiff_t size = HASH_TABLE_SIZE (hash);
for (ptrdiff_t i = 0; i < size; ++i)
- if (!NILP (HASH_HASH (hash, i)))
- {
- Lisp_Object key = HASH_KEY (hash, i);
- bool key_stable = (dump_builtin_symbol_p (key)
- || FIXNUMP (key)
- || (is_equal
- && (STRINGP (key) || BOOL_VECTOR_P (key)))
- || ((is_equal || is_eql)
- && (FLOATP (key) || BIGNUMP (key))));
- if (!key_stable)
- return false;
- }
+ {
+ Lisp_Object key = HASH_KEY (hash, i);
+ if (!EQ (key, Qunbound))
+ {
+ bool key_stable = (dump_builtin_symbol_p (key)
+ || FIXNUMP (key)
+ || (is_equal
+ && (STRINGP (key) || BOOL_VECTOR_P (key)))
+ || ((is_equal || is_eql)
+ && (FLOATP (key) || BIGNUMP (key))));
+ if (!key_stable)
+ return false;
+ }
+ }
return true;
}
Lisp_Object contents = Qnil;
struct Lisp_Hash_Table *h = XHASH_TABLE (table);
for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
- if (!NILP (HASH_HASH (h, i)))
- dump_push (&contents, Fcons (HASH_KEY (h, i), HASH_VALUE (h, i)));
+ {
+ Lisp_Object key = HASH_KEY (h, i);
+ if (!EQ (key, Qunbound))
+ dump_push (&contents, Fcons (key, HASH_VALUE (h, i)));
+ }
return Fnreverse (contents);
}
ptrdiff_t i;
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
- if (!NILP (HASH_HASH (h, i))
- && EQ (HASH_VALUE (h, i), Qt))
- Fremhash (HASH_KEY (h, i), Vprint_number_table);
+ {
+ Lisp_Object key = HASH_KEY (h, i);
+ if (!EQ (key, Qunbound)
+ && EQ (HASH_VALUE (h, i), Qt))
+ Fremhash (key, Vprint_number_table);
+ }
}
}
printchar ('(', printcharfun);
for (ptrdiff_t i = 0; i < size; i++)
- if (!NILP (HASH_HASH (h, i)))
- {
- if (i) printchar (' ', printcharfun);
- print_object (HASH_KEY (h, i), printcharfun, escapeflag);
- printchar (' ', printcharfun);
- print_object (HASH_VALUE (h, i), printcharfun, escapeflag);
- }
+ {
+ Lisp_Object key = HASH_KEY (h, i);
+ if (!EQ (key, Qunbound))
+ {
+ if (i) printchar (' ', printcharfun);
+ print_object (key, printcharfun, escapeflag);
+ printchar (' ', printcharfun);
+ print_object (HASH_VALUE (h, i), printcharfun, escapeflag);
+ }
+ }
if (size < real_size)
print_c_string (" ...", printcharfun);