aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2006-07-12 13:17:13 +0000
committerKim F. Storm2006-07-12 13:17:13 +0000
commit89662fc36386cc9a89eae0c39ade8510fdf98416 (patch)
treeb9584618fc5a9c90a8328771a8467594ccbc558f /src
parentb7f34213c10aa9354d06d15eb3c1ed1021ce947f (diff)
downloademacs-89662fc36386cc9a89eae0c39ade8510fdf98416.tar.gz
emacs-89662fc36386cc9a89eae0c39ade8510fdf98416.zip
(Flength, Felt, Ffillarray): Remove loop around wrong_type_argument.
(Fcopy_sequence, concat): Cleanup wrong_type_argument use. (concat): Use CHECK_NUMBER. (Felt): Use CHECK_ARRAY. (Fsubstring, substring_both): Use CHECK_VECTOR_OR_STRING. (Fmemq): Use CHECK_LIST. (Fassq, Fassoc, Frassq, Frassoc): Use CAR. (assq_no_quit): Use CAR_SAFE. (Fnthcdr, Fmember, Fdelq, Fdelete, Fnreverse, Fnconc): Use CHECK_LIST_CONS. (Freverse, Fplist_get, Flax_plist_get): Use CHECK_LIST_END.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c131
1 files changed, 35 insertions, 96 deletions
diff --git a/src/fns.c b/src/fns.c
index b31beb22ff4..146d46b69b8 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -147,7 +147,6 @@ To get the number of bytes, use `string-bytes'. */)
147 register Lisp_Object val; 147 register Lisp_Object val;
148 register int i; 148 register int i;
149 149
150 retry:
151 if (STRINGP (sequence)) 150 if (STRINGP (sequence))
152 XSETFASTINT (val, SCHARS (sequence)); 151 XSETFASTINT (val, SCHARS (sequence));
153 else if (VECTORP (sequence)) 152 else if (VECTORP (sequence))
@@ -176,18 +175,15 @@ To get the number of bytes, use `string-bytes'. */)
176 QUIT; 175 QUIT;
177 } 176 }
178 177
179 if (!NILP (sequence)) 178 CHECK_LIST_END (sequence, sequence);
180 wrong_type_argument (Qlistp, sequence);
181 179
182 val = make_number (i); 180 val = make_number (i);
183 } 181 }
184 else if (NILP (sequence)) 182 else if (NILP (sequence))
185 XSETFASTINT (val, 0); 183 XSETFASTINT (val, 0);
186 else 184 else
187 { 185 val = wrong_type_argument (Qsequencep, sequence);
188 sequence = wrong_type_argument (Qsequencep, sequence); 186
189 goto retry;
190 }
191 return val; 187 return val;
192} 188}
193 189
@@ -529,7 +525,8 @@ with the original. */)
529 } 525 }
530 526
531 if (!CONSP (arg) && !VECTORP (arg) && !STRINGP (arg)) 527 if (!CONSP (arg) && !VECTORP (arg) && !STRINGP (arg))
532 arg = wrong_type_argument (Qsequencep, arg); 528 wrong_type_argument (Qsequencep, arg);
529
533 return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0); 530 return concat (1, &arg, CONSP (arg) ? Lisp_Cons : XTYPE (arg), 0);
534} 531}
535 532
@@ -581,15 +578,13 @@ concat (nargs, args, target_type, last_special)
581 else 578 else
582 last_tail = Qnil; 579 last_tail = Qnil;
583 580
584 /* Canonicalize each argument. */ 581 /* Check each argument. */
585 for (argnum = 0; argnum < nargs; argnum++) 582 for (argnum = 0; argnum < nargs; argnum++)
586 { 583 {
587 this = args[argnum]; 584 this = args[argnum];
588 if (!(CONSP (this) || NILP (this) || VECTORP (this) || STRINGP (this) 585 if (!(CONSP (this) || NILP (this) || VECTORP (this) || STRINGP (this)
589 || COMPILEDP (this) || BOOL_VECTOR_P (this))) 586 || COMPILEDP (this) || BOOL_VECTOR_P (this)))
590 { 587 wrong_type_argument (Qsequencep, this);
591 args[argnum] = wrong_type_argument (Qsequencep, this);
592 }
593 } 588 }
594 589
595 /* Compute total length in chars of arguments in RESULT_LEN. 590 /* Compute total length in chars of arguments in RESULT_LEN.
@@ -616,8 +611,7 @@ concat (nargs, args, target_type, last_special)
616 for (i = 0; i < len; i++) 611 for (i = 0; i < len; i++)
617 { 612 {
618 ch = XVECTOR (this)->contents[i]; 613 ch = XVECTOR (this)->contents[i];
619 if (! INTEGERP (ch)) 614 CHECK_NUMBER (ch);
620 wrong_type_argument (Qintegerp, ch);
621 this_len_byte = CHAR_BYTES (XINT (ch)); 615 this_len_byte = CHAR_BYTES (XINT (ch));
622 result_len_byte += this_len_byte; 616 result_len_byte += this_len_byte;
623 if (!SINGLE_BYTE_CHAR_P (XINT (ch))) 617 if (!SINGLE_BYTE_CHAR_P (XINT (ch)))
@@ -629,8 +623,7 @@ concat (nargs, args, target_type, last_special)
629 for (; CONSP (this); this = XCDR (this)) 623 for (; CONSP (this); this = XCDR (this))
630 { 624 {
631 ch = XCAR (this); 625 ch = XCAR (this);
632 if (! INTEGERP (ch)) 626 CHECK_NUMBER (ch);
633 wrong_type_argument (Qintegerp, ch);
634 this_len_byte = CHAR_BYTES (XINT (ch)); 627 this_len_byte = CHAR_BYTES (XINT (ch));
635 result_len_byte += this_len_byte; 628 result_len_byte += this_len_byte;
636 if (!SINGLE_BYTE_CHAR_P (XINT (ch))) 629 if (!SINGLE_BYTE_CHAR_P (XINT (ch)))
@@ -1252,9 +1245,7 @@ This function allows vectors as well as strings. */)
1252 int from_char, to_char; 1245 int from_char, to_char;
1253 int from_byte = 0, to_byte = 0; 1246 int from_byte = 0, to_byte = 0;
1254 1247
1255 if (! (STRINGP (string) || VECTORP (string))) 1248 CHECK_VECTOR_OR_STRING (string);
1256 wrong_type_argument (Qarrayp, string);
1257
1258 CHECK_NUMBER (from); 1249 CHECK_NUMBER (from);
1259 1250
1260 if (STRINGP (string)) 1251 if (STRINGP (string))
@@ -1378,8 +1369,7 @@ substring_both (string, from, from_byte, to, to_byte)
1378 int size; 1369 int size;
1379 int size_byte; 1370 int size_byte;
1380 1371
1381 if (! (STRINGP (string) || VECTORP (string))) 1372 CHECK_VECTOR_OR_STRING (string);
1382 wrong_type_argument (Qarrayp, string);
1383 1373
1384 if (STRINGP (string)) 1374 if (STRINGP (string))
1385 { 1375 {
@@ -1419,8 +1409,7 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
1419 for (i = 0; i < num && !NILP (list); i++) 1409 for (i = 0; i < num && !NILP (list); i++)
1420 { 1410 {
1421 QUIT; 1411 QUIT;
1422 if (! CONSP (list)) 1412 CHECK_LIST_CONS (list, list);
1423 wrong_type_argument (Qlistp, list);
1424 list = XCDR (list); 1413 list = XCDR (list);
1425 } 1414 }
1426 return list; 1415 return list;
@@ -1441,16 +1430,12 @@ DEFUN ("elt", Felt, Selt, 2, 2, 0,
1441 register Lisp_Object sequence, n; 1430 register Lisp_Object sequence, n;
1442{ 1431{
1443 CHECK_NUMBER (n); 1432 CHECK_NUMBER (n);
1444 while (1) 1433 if (CONSP (sequence) || NILP (sequence))
1445 { 1434 return Fcar (Fnthcdr (n, sequence));
1446 if (CONSP (sequence) || NILP (sequence)) 1435
1447 return Fcar (Fnthcdr (n, sequence)); 1436 /* Faref signals a "not array" error, so check here. */
1448 else if (STRINGP (sequence) || VECTORP (sequence) 1437 CHECK_ARRAY (sequence, Qsequencep);
1449 || BOOL_VECTOR_P (sequence) || CHAR_TABLE_P (sequence)) 1438 return Faref (sequence, n);
1450 return Faref (sequence, n);
1451 else
1452 sequence = wrong_type_argument (Qsequencep, sequence);
1453 }
1454} 1439}
1455 1440
1456DEFUN ("member", Fmember, Smember, 2, 2, 0, 1441DEFUN ("member", Fmember, Smember, 2, 2, 0,
@@ -1464,8 +1449,7 @@ The value is actually the tail of LIST whose car is ELT. */)
1464 for (tail = list; !NILP (tail); tail = XCDR (tail)) 1449 for (tail = list; !NILP (tail); tail = XCDR (tail))
1465 { 1450 {
1466 register Lisp_Object tem; 1451 register Lisp_Object tem;
1467 if (! CONSP (tail)) 1452 CHECK_LIST_CONS (tail, list);
1468 wrong_type_argument (Qlistp, list);
1469 tem = XCAR (tail); 1453 tem = XCAR (tail);
1470 if (! NILP (Fequal (elt, tem))) 1454 if (! NILP (Fequal (elt, tem)))
1471 return tail; 1455 return tail;
@@ -1498,9 +1482,7 @@ whose car is ELT. */)
1498 QUIT; 1482 QUIT;
1499 } 1483 }
1500 1484
1501 if (!CONSP (list) && !NILP (list)) 1485 CHECK_LIST (list);
1502 list = wrong_type_argument (Qlistp, list);
1503
1504 return list; 1486 return list;
1505} 1487}
1506 1488
@@ -1511,8 +1493,6 @@ Elements of LIST that are not conses are ignored. */)
1511 (key, list) 1493 (key, list)
1512 Lisp_Object key, list; 1494 Lisp_Object key, list;
1513{ 1495{
1514 Lisp_Object result;
1515
1516 while (1) 1496 while (1)
1517 { 1497 {
1518 if (!CONSP (list) 1498 if (!CONSP (list)
@@ -1536,14 +1516,7 @@ Elements of LIST that are not conses are ignored. */)
1536 QUIT; 1516 QUIT;
1537 } 1517 }
1538 1518
1539 if (CONSP (list)) 1519 return CAR (list);
1540 result = XCAR (list);
1541 else if (NILP (list))
1542 result = Qnil;
1543 else
1544 result = wrong_type_argument (Qlistp, list);
1545
1546 return result;
1547} 1520}
1548 1521
1549/* Like Fassq but never report an error and do not allow quits. 1522/* Like Fassq but never report an error and do not allow quits.
@@ -1558,7 +1531,7 @@ assq_no_quit (key, list)
1558 || !EQ (XCAR (XCAR (list)), key))) 1531 || !EQ (XCAR (XCAR (list)), key)))
1559 list = XCDR (list); 1532 list = XCDR (list);
1560 1533
1561 return CONSP (list) ? XCAR (list) : Qnil; 1534 return CAR_SAFE (list);
1562} 1535}
1563 1536
1564DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0, 1537DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0,
@@ -1567,7 +1540,7 @@ The value is actually the first element of LIST whose car equals KEY. */)
1567 (key, list) 1540 (key, list)
1568 Lisp_Object key, list; 1541 Lisp_Object key, list;
1569{ 1542{
1570 Lisp_Object result, car; 1543 Lisp_Object car;
1571 1544
1572 while (1) 1545 while (1)
1573 { 1546 {
@@ -1595,14 +1568,7 @@ The value is actually the first element of LIST whose car equals KEY. */)
1595 QUIT; 1568 QUIT;
1596 } 1569 }
1597 1570
1598 if (CONSP (list)) 1571 return CAR (list);
1599 result = XCAR (list);
1600 else if (NILP (list))
1601 result = Qnil;
1602 else
1603 result = wrong_type_argument (Qlistp, list);
1604
1605 return result;
1606} 1572}
1607 1573
1608DEFUN ("rassq", Frassq, Srassq, 2, 2, 0, 1574DEFUN ("rassq", Frassq, Srassq, 2, 2, 0,
@@ -1612,8 +1578,6 @@ The value is actually the first element of LIST whose cdr is KEY. */)
1612 register Lisp_Object key; 1578 register Lisp_Object key;
1613 Lisp_Object list; 1579 Lisp_Object list;
1614{ 1580{
1615 Lisp_Object result;
1616
1617 while (1) 1581 while (1)
1618 { 1582 {
1619 if (!CONSP (list) 1583 if (!CONSP (list)
@@ -1637,14 +1601,7 @@ The value is actually the first element of LIST whose cdr is KEY. */)
1637 QUIT; 1601 QUIT;
1638 } 1602 }
1639 1603
1640 if (NILP (list)) 1604 return CAR (list);
1641 result = Qnil;
1642 else if (CONSP (list))
1643 result = XCAR (list);
1644 else
1645 result = wrong_type_argument (Qlistp, list);
1646
1647 return result;
1648} 1605}
1649 1606
1650DEFUN ("rassoc", Frassoc, Srassoc, 2, 2, 0, 1607DEFUN ("rassoc", Frassoc, Srassoc, 2, 2, 0,
@@ -1653,7 +1610,7 @@ The value is actually the first element of LIST whose cdr equals KEY. */)
1653 (key, list) 1610 (key, list)
1654 Lisp_Object key, list; 1611 Lisp_Object key, list;
1655{ 1612{
1656 Lisp_Object result, cdr; 1613 Lisp_Object cdr;
1657 1614
1658 while (1) 1615 while (1)
1659 { 1616 {
@@ -1681,14 +1638,7 @@ The value is actually the first element of LIST whose cdr equals KEY. */)
1681 QUIT; 1638 QUIT;
1682 } 1639 }
1683 1640
1684 if (CONSP (list)) 1641 return CAR (list);
1685 result = XCAR (list);
1686 else if (NILP (list))
1687 result = Qnil;
1688 else
1689 result = wrong_type_argument (Qlistp, list);
1690
1691 return result;
1692} 1642}
1693 1643
1694DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0, 1644DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0,
@@ -1708,8 +1658,7 @@ to be sure of changing the value of `foo'. */)
1708 prev = Qnil; 1658 prev = Qnil;
1709 while (!NILP (tail)) 1659 while (!NILP (tail))
1710 { 1660 {
1711 if (! CONSP (tail)) 1661 CHECK_LIST_CONS (tail, list);
1712 wrong_type_argument (Qlistp, list);
1713 tem = XCAR (tail); 1662 tem = XCAR (tail);
1714 if (EQ (elt, tem)) 1663 if (EQ (elt, tem))
1715 { 1664 {
@@ -1831,8 +1780,7 @@ to be sure of changing the value of `foo'. */)
1831 1780
1832 for (tail = seq, prev = Qnil; !NILP (tail); tail = XCDR (tail)) 1781 for (tail = seq, prev = Qnil; !NILP (tail); tail = XCDR (tail))
1833 { 1782 {
1834 if (!CONSP (tail)) 1783 CHECK_LIST_CONS (tail, seq);
1835 wrong_type_argument (Qlistp, seq);
1836 1784
1837 if (!NILP (Fequal (elt, XCAR (tail)))) 1785 if (!NILP (Fequal (elt, XCAR (tail))))
1838 { 1786 {
@@ -1864,8 +1812,7 @@ Return the reversed list. */)
1864 while (!NILP (tail)) 1812 while (!NILP (tail))
1865 { 1813 {
1866 QUIT; 1814 QUIT;
1867 if (! CONSP (tail)) 1815 CHECK_LIST_CONS (tail, list);
1868 wrong_type_argument (Qlistp, list);
1869 next = XCDR (tail); 1816 next = XCDR (tail);
1870 Fsetcdr (tail, prev); 1817 Fsetcdr (tail, prev);
1871 prev = tail; 1818 prev = tail;
@@ -1887,8 +1834,7 @@ See also the function `nreverse', which is used more often. */)
1887 QUIT; 1834 QUIT;
1888 new = Fcons (XCAR (list), new); 1835 new = Fcons (XCAR (list), new);
1889 } 1836 }
1890 if (!NILP (list)) 1837 CHECK_LIST_END (list, list);
1891 wrong_type_argument (Qconsp, list);
1892 return new; 1838 return new;
1893} 1839}
1894 1840
@@ -2012,8 +1958,7 @@ one of the properties on the list. */)
2012 QUIT; 1958 QUIT;
2013 } 1959 }
2014 1960
2015 if (!NILP (tail)) 1961 CHECK_LIST_END (tail, prop);
2016 wrong_type_argument (Qlistp, prop);
2017 1962
2018 return Qnil; 1963 return Qnil;
2019} 1964}
@@ -2129,8 +2074,7 @@ one of the properties on the list. */)
2129 QUIT; 2074 QUIT;
2130 } 2075 }
2131 2076
2132 if (!NILP (tail)) 2077 CHECK_LIST_END (tail, prop);
2133 wrong_type_argument (Qlistp, prop);
2134 2078
2135 return Qnil; 2079 return Qnil;
2136} 2080}
@@ -2344,7 +2288,6 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2344 Lisp_Object array, item; 2288 Lisp_Object array, item;
2345{ 2289{
2346 register int size, index, charval; 2290 register int size, index, charval;
2347 retry:
2348 if (VECTORP (array)) 2291 if (VECTORP (array))
2349 { 2292 {
2350 register Lisp_Object *p = XVECTOR (array)->contents; 2293 register Lisp_Object *p = XVECTOR (array)->contents;
@@ -2408,10 +2351,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2408 } 2351 }
2409 } 2352 }
2410 else 2353 else
2411 { 2354 wrong_type_argument (Qarrayp, array);
2412 array = wrong_type_argument (Qarrayp, array);
2413 goto retry;
2414 }
2415 return array; 2355 return array;
2416} 2356}
2417 2357
@@ -3042,8 +2982,7 @@ usage: (nconc &rest LISTS) */)
3042 2982
3043 if (argnum + 1 == nargs) break; 2983 if (argnum + 1 == nargs) break;
3044 2984
3045 if (!CONSP (tem)) 2985 CHECK_LIST_CONS (tem, tem);
3046 tem = wrong_type_argument (Qlistp, tem);
3047 2986
3048 while (CONSP (tem)) 2987 while (CONSP (tem))
3049 { 2988 {