aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-07-26 16:55:59 -0400
committerStefan Monnier2019-07-26 16:55:59 -0400
commit0f09808e522cd3de6bd9ea1350beed1feddfbda9 (patch)
tree6831e3a40ff70ab0091cd691bbcdc37d14153d6e
parent0dc5a85a1c3772a6e78f077719d82f437f626b1e (diff)
downloademacs-0f09808e522cd3de6bd9ea1350beed1feddfbda9.tar.gz
emacs-0f09808e522cd3de6bd9ea1350beed1feddfbda9.zip
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)`.
-rw-r--r--src/json.c41
-rw-r--r--src/minibuf.c6
-rw-r--r--src/pdumper.c33
-rw-r--r--src/print.c26
4 files changed, 60 insertions, 46 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,
361 count = SPECPDL_INDEX (); 361 count = SPECPDL_INDEX ();
362 record_unwind_protect_ptr (json_release_object, json); 362 record_unwind_protect_ptr (json_release_object, json);
363 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i) 363 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
364 if (!NILP (HASH_HASH (h, i))) 364 {
365 { 365 Lisp_Object key = HASH_KEY (h, i);
366 Lisp_Object key = json_encode (HASH_KEY (h, i)); 366 if (!EQ (key, Qunbound))
367 /* We can't specify the length, so the string must be 367 {
368 Lisp_Object ekey = json_encode (key);
369 /* We can't specify the length, so the string must be
368 NUL-terminated. */ 370 NUL-terminated. */
369 check_string_without_embedded_nuls (key); 371 check_string_without_embedded_nuls (ekey);
370 const char *key_str = SSDATA (key); 372 const char *key_str = SSDATA (ekey);
371 /* Reject duplicate keys. These are possible if the hash 373 /* Reject duplicate keys. These are possible if the hash
372 table test is not `equal'. */ 374 table test is not `equal'. */
373 if (json_object_get (json, key_str) != NULL) 375 if (json_object_get (json, key_str) != NULL)
374 wrong_type_argument (Qjson_value_p, lisp); 376 wrong_type_argument (Qjson_value_p, lisp);
375 int status = json_object_set_new (json, key_str, 377 int status
376 lisp_to_json (HASH_VALUE (h, i), 378 = json_object_set_new (json, key_str,
377 conf)); 379 lisp_to_json (HASH_VALUE (h, i), conf));
378 if (status == -1) 380 if (status == -1)
379 { 381 {
380 /* A failure can be caused either by an invalid key or 382 /* A failure can be caused either by an invalid key or
381 by low memory. */ 383 by low memory. */
382 json_check_utf8 (key); 384 json_check_utf8 (ekey);
383 json_out_of_memory (); 385 json_out_of_memory ();
384 } 386 }
385 } 387 }
388 }
386 } 389 }
387 else if (NILP (lisp)) 390 else if (NILP (lisp))
388 return json_check (json_object ()); 391 return json_check (json_object ());
diff --git a/src/minibuf.c b/src/minibuf.c
index 8920f37827d..14a0dbe762c 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1245,7 +1245,7 @@ is used to further constrain the set of candidates. */)
1245 else /* if (type == hash_table) */ 1245 else /* if (type == hash_table) */
1246 { 1246 {
1247 while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection)) 1247 while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
1248 && NILP (HASH_HASH (XHASH_TABLE (collection), idx))) 1248 && EQ (HASH_KEY (XHASH_TABLE (collection), idx), Qunbound))
1249 idx++; 1249 idx++;
1250 if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection))) 1250 if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
1251 break; 1251 break;
@@ -1497,7 +1497,7 @@ with a space are ignored unless STRING itself starts with a space. */)
1497 else /* if (type == 3) */ 1497 else /* if (type == 3) */
1498 { 1498 {
1499 while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection)) 1499 while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
1500 && NILP (HASH_HASH (XHASH_TABLE (collection), idx))) 1500 && EQ (HASH_KEY (XHASH_TABLE (collection), idx), Qunbound))
1501 idx++; 1501 idx++;
1502 if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection))) 1502 if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
1503 break; 1503 break;
@@ -1724,8 +1724,8 @@ the values STRING, PREDICATE and `lambda'. */)
1724 else 1724 else
1725 for (i = 0; i < HASH_TABLE_SIZE (h); ++i) 1725 for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
1726 { 1726 {
1727 if (NILP (HASH_HASH (h, i))) continue;
1728 tem = HASH_KEY (h, i); 1727 tem = HASH_KEY (h, i);
1728 if (EQ (tem, Qunbound)) continue;
1729 Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem); 1729 Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem);
1730 if (!STRINGP (strkey)) continue; 1730 if (!STRINGP (strkey)) continue;
1731 if (EQ (Fcompare_strings (string, Qnil, Qnil, 1731 if (EQ (Fcompare_strings (string, Qnil, Qnil,
diff --git a/src/pdumper.c b/src/pdumper.c
index 1a5d1f32ba5..31f4f33adf3 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2629,18 +2629,20 @@ dump_hash_table_stable_p (const struct Lisp_Hash_Table *hash)
2629 bool is_equal = hash->test.hashfn == hashfn_equal; 2629 bool is_equal = hash->test.hashfn == hashfn_equal;
2630 ptrdiff_t size = HASH_TABLE_SIZE (hash); 2630 ptrdiff_t size = HASH_TABLE_SIZE (hash);
2631 for (ptrdiff_t i = 0; i < size; ++i) 2631 for (ptrdiff_t i = 0; i < size; ++i)
2632 if (!NILP (HASH_HASH (hash, i))) 2632 {
2633 { 2633 Lisp_Object key = HASH_KEY (hash, i);
2634 Lisp_Object key = HASH_KEY (hash, i); 2634 if (!EQ (key, Qunbound))
2635 bool key_stable = (dump_builtin_symbol_p (key) 2635 {
2636 || FIXNUMP (key) 2636 bool key_stable = (dump_builtin_symbol_p (key)
2637 || (is_equal 2637 || FIXNUMP (key)
2638 && (STRINGP (key) || BOOL_VECTOR_P (key))) 2638 || (is_equal
2639 || ((is_equal || is_eql) 2639 && (STRINGP (key) || BOOL_VECTOR_P (key)))
2640 && (FLOATP (key) || BIGNUMP (key)))); 2640 || ((is_equal || is_eql)
2641 if (!key_stable) 2641 && (FLOATP (key) || BIGNUMP (key))));
2642 return false; 2642 if (!key_stable)
2643 } 2643 return false;
2644 }
2645 }
2644 2646
2645 return true; 2647 return true;
2646} 2648}
@@ -2652,8 +2654,11 @@ hash_table_contents (Lisp_Object table)
2652 Lisp_Object contents = Qnil; 2654 Lisp_Object contents = Qnil;
2653 struct Lisp_Hash_Table *h = XHASH_TABLE (table); 2655 struct Lisp_Hash_Table *h = XHASH_TABLE (table);
2654 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i) 2656 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
2655 if (!NILP (HASH_HASH (h, i))) 2657 {
2656 dump_push (&contents, Fcons (HASH_KEY (h, i), HASH_VALUE (h, i))); 2658 Lisp_Object key = HASH_KEY (h, i);
2659 if (!EQ (key, Qunbound))
2660 dump_push (&contents, Fcons (key, HASH_VALUE (h, i)));
2661 }
2657 return Fnreverse (contents); 2662 return Fnreverse (contents);
2658} 2663}
2659 2664
diff --git a/src/print.c b/src/print.c
index cb340905142..7c3da68fc98 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1135,9 +1135,12 @@ print (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1135 ptrdiff_t i; 1135 ptrdiff_t i;
1136 1136
1137 for (i = 0; i < HASH_TABLE_SIZE (h); ++i) 1137 for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
1138 if (!NILP (HASH_HASH (h, i)) 1138 {
1139 && EQ (HASH_VALUE (h, i), Qt)) 1139 Lisp_Object key = HASH_KEY (h, i);
1140 Fremhash (HASH_KEY (h, i), Vprint_number_table); 1140 if (!EQ (key, Qunbound)
1141 && EQ (HASH_VALUE (h, i), Qt))
1142 Fremhash (key, Vprint_number_table);
1143 }
1141 } 1144 }
1142 } 1145 }
1143 1146
@@ -1593,13 +1596,16 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag,
1593 1596
1594 printchar ('(', printcharfun); 1597 printchar ('(', printcharfun);
1595 for (ptrdiff_t i = 0; i < size; i++) 1598 for (ptrdiff_t i = 0; i < size; i++)
1596 if (!NILP (HASH_HASH (h, i))) 1599 {
1597 { 1600 Lisp_Object key = HASH_KEY (h, i);
1598 if (i) printchar (' ', printcharfun); 1601 if (!EQ (key, Qunbound))
1599 print_object (HASH_KEY (h, i), printcharfun, escapeflag); 1602 {
1600 printchar (' ', printcharfun); 1603 if (i) printchar (' ', printcharfun);
1601 print_object (HASH_VALUE (h, i), printcharfun, escapeflag); 1604 print_object (key, printcharfun, escapeflag);
1602 } 1605 printchar (' ', printcharfun);
1606 print_object (HASH_VALUE (h, i), printcharfun, escapeflag);
1607 }
1608 }
1603 1609
1604 if (size < real_size) 1610 if (size < real_size)
1605 print_c_string (" ...", printcharfun); 1611 print_c_string (" ...", printcharfun);