Mercurial > emacs
comparison src/print.c @ 28743:cd4858a8d658
(print_object): Treat print-length < 0 as nil.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 27 Apr 2000 19:09:17 +0000 |
parents | e5694cf2ac01 |
children | f8b0ac62f238 |
comparison
equal
deleted
inserted
replaced
28742:4b2207602eef | 28743:cd4858a8d658 |
---|---|
1485 } | 1485 } |
1486 else | 1486 else |
1487 { | 1487 { |
1488 PRINTCHAR ('('); | 1488 PRINTCHAR ('('); |
1489 { | 1489 { |
1490 register int i = 0; | 1490 int print_length, i; |
1491 register int print_length = 0; | |
1492 Lisp_Object halftail = obj; | 1491 Lisp_Object halftail = obj; |
1493 | 1492 |
1494 if (INTEGERP (Vprint_length)) | 1493 /* Negative values of print-length are illegal in CL. |
1495 print_length = XINT (Vprint_length); | 1494 Treat them like nil, as CMUCL does. */ |
1495 if (NATNUMP (Vprint_length)) | |
1496 print_length = XFASTINT (Vprint_length); | |
1497 else | |
1498 print_length = 0; | |
1499 | |
1500 i = 0; | |
1496 while (CONSP (obj)) | 1501 while (CONSP (obj)) |
1497 { | 1502 { |
1498 /* Detect circular list. */ | 1503 /* Detect circular list. */ |
1499 if (NILP (Vprint_circle)) | 1504 if (NILP (Vprint_circle)) |
1500 { | 1505 { |
1511 /* With the print-circle feature. */ | 1516 /* With the print-circle feature. */ |
1512 if (i != 0) | 1517 if (i != 0) |
1513 { | 1518 { |
1514 int i; | 1519 int i; |
1515 for (i = 0; i < print_number_index; i++) | 1520 for (i = 0; i < print_number_index; i++) |
1516 if (EQ (PRINT_NUMBER_OBJECT (Vprint_number_table, i), obj)) | 1521 if (EQ (PRINT_NUMBER_OBJECT (Vprint_number_table, i), |
1522 obj)) | |
1517 { | 1523 { |
1518 if (NILP (PRINT_NUMBER_STATUS (Vprint_number_table, i))) | 1524 if (NILP (PRINT_NUMBER_STATUS (Vprint_number_table, i))) |
1519 { | 1525 { |
1520 strout (" . ", 3, 3, printcharfun, 0); | 1526 strout (" . ", 3, 3, printcharfun, 0); |
1521 print_object (obj, printcharfun, escapeflag); | 1527 print_object (obj, printcharfun, escapeflag); |
1527 } | 1533 } |
1528 goto end_of_list; | 1534 goto end_of_list; |
1529 } | 1535 } |
1530 } | 1536 } |
1531 } | 1537 } |
1538 | |
1532 if (i++) | 1539 if (i++) |
1533 PRINTCHAR (' '); | 1540 PRINTCHAR (' '); |
1541 | |
1534 if (print_length && i > print_length) | 1542 if (print_length && i > print_length) |
1535 { | 1543 { |
1536 strout ("...", 3, 3, printcharfun, 0); | 1544 strout ("...", 3, 3, printcharfun, 0); |
1537 goto end_of_list; | 1545 goto end_of_list; |
1538 } | 1546 } |
1547 | |
1539 print_object (XCAR (obj), printcharfun, escapeflag); | 1548 print_object (XCAR (obj), printcharfun, escapeflag); |
1549 | |
1540 obj = XCDR (obj); | 1550 obj = XCDR (obj); |
1541 if (!(i & 1)) | 1551 if (!(i & 1)) |
1542 halftail = XCDR (halftail); | 1552 halftail = XCDR (halftail); |
1543 } | 1553 } |
1544 } | 1554 } |
1555 | |
1556 /* OBJ non-nil here means it's the end of a dotted list. */ | |
1545 if (!NILP (obj)) | 1557 if (!NILP (obj)) |
1546 { | 1558 { |
1547 strout (" . ", 3, 3, printcharfun, 0); | 1559 strout (" . ", 3, 3, printcharfun, 0); |
1548 print_object (obj, printcharfun, escapeflag); | 1560 print_object (obj, printcharfun, escapeflag); |
1549 } | 1561 } |
1562 | |
1550 end_of_list: | 1563 end_of_list: |
1551 PRINTCHAR (')'); | 1564 PRINTCHAR (')'); |
1552 } | 1565 } |
1553 break; | 1566 break; |
1554 | 1567 |
1578 PRINTCHAR ('&'); | 1591 PRINTCHAR ('&'); |
1579 sprintf (buf, "%d", XBOOL_VECTOR (obj)->size); | 1592 sprintf (buf, "%d", XBOOL_VECTOR (obj)->size); |
1580 strout (buf, -1, -1, printcharfun, 0); | 1593 strout (buf, -1, -1, printcharfun, 0); |
1581 PRINTCHAR ('\"'); | 1594 PRINTCHAR ('\"'); |
1582 | 1595 |
1583 /* Don't print more characters than the specified maximum. */ | 1596 /* Don't print more characters than the specified maximum. |
1584 if (INTEGERP (Vprint_length) | 1597 Negative values of print-length are illegal. Treat them |
1585 && XINT (Vprint_length) < size_in_chars) | 1598 like a print-length of nil. */ |
1586 size_in_chars = XINT (Vprint_length); | 1599 if (NATNUMP (Vprint_length) |
1600 && XFASTINT (Vprint_length) < size_in_chars) | |
1601 size_in_chars = XFASTINT (Vprint_length); | |
1587 | 1602 |
1588 for (i = 0; i < size_in_chars; i++) | 1603 for (i = 0; i < size_in_chars; i++) |
1589 { | 1604 { |
1590 QUIT; | 1605 QUIT; |
1591 c = XBOOL_VECTOR (obj)->data[i]; | 1606 c = XBOOL_VECTOR (obj)->data[i]; |
1701 { | 1716 { |
1702 register int i; | 1717 register int i; |
1703 register Lisp_Object tem; | 1718 register Lisp_Object tem; |
1704 | 1719 |
1705 /* Don't print more elements than the specified maximum. */ | 1720 /* Don't print more elements than the specified maximum. */ |
1706 if (INTEGERP (Vprint_length) | 1721 if (NATNUMP (Vprint_length) |
1707 && XINT (Vprint_length) < size) | 1722 && XFASTINT (Vprint_length) < size) |
1708 size = XINT (Vprint_length); | 1723 size = XFASTINT (Vprint_length); |
1709 | 1724 |
1710 for (i = 0; i < size; i++) | 1725 for (i = 0; i < size; i++) |
1711 { | 1726 { |
1712 if (i) PRINTCHAR (' '); | 1727 if (i) PRINTCHAR (' '); |
1713 tem = XVECTOR (obj)->contents[i]; | 1728 tem = XVECTOR (obj)->contents[i]; |