diff options
| author | Paul Eggert | 2017-05-21 01:45:34 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-05-21 01:47:31 -0700 |
| commit | 97c7a61d90987e182c1d2ec40fbe0d1d7df844c5 (patch) | |
| tree | b42ee08724ce05511944a620c4934f4572c41b0b /src | |
| parent | b35293dfd0e9dd95a88ac01051655d0d2d105992 (diff) | |
| download | emacs-97c7a61d90987e182c1d2ec40fbe0d1d7df844c5.tar.gz emacs-97c7a61d90987e182c1d2ec40fbe0d1d7df844c5.zip | |
Pacify --enable-gcc-warnings without modules
* src/print.c (print_vectorlike): New function, taken from
part of print_object. This one is indented properly, and
pacifies --enable-gcc-warnings by using a default case
instead of listing all the enum values, sometimes
incompletely.
(print_object): Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 751 |
1 files changed, 367 insertions, 384 deletions
diff --git a/src/print.c b/src/print.c index be2e16a7499..49408bbeb40 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1346,6 +1346,371 @@ print_prune_string_charset (Lisp_Object string) | |||
| 1346 | return string; | 1346 | return string; |
| 1347 | } | 1347 | } |
| 1348 | 1348 | ||
| 1349 | static bool | ||
| 1350 | print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, | ||
| 1351 | char *buf) | ||
| 1352 | { | ||
| 1353 | switch (PSEUDOVECTOR_TYPE (XVECTOR (obj))) | ||
| 1354 | { | ||
| 1355 | case PVEC_PROCESS: | ||
| 1356 | if (escapeflag) | ||
| 1357 | { | ||
| 1358 | print_c_string ("#<process ", printcharfun); | ||
| 1359 | print_string (XPROCESS (obj)->name, printcharfun); | ||
| 1360 | printchar ('>', printcharfun); | ||
| 1361 | } | ||
| 1362 | else | ||
| 1363 | print_string (XPROCESS (obj)->name, printcharfun); | ||
| 1364 | break; | ||
| 1365 | |||
| 1366 | case PVEC_BOOL_VECTOR: | ||
| 1367 | { | ||
| 1368 | EMACS_INT size = bool_vector_size (obj); | ||
| 1369 | ptrdiff_t size_in_chars = bool_vector_bytes (size); | ||
| 1370 | ptrdiff_t real_size_in_chars = size_in_chars; | ||
| 1371 | |||
| 1372 | int len = sprintf (buf, "#&%"pI"d\"", size); | ||
| 1373 | strout (buf, len, len, printcharfun); | ||
| 1374 | |||
| 1375 | /* Don't print more characters than the specified maximum. | ||
| 1376 | Negative values of print-length are invalid. Treat them | ||
| 1377 | like a print-length of nil. */ | ||
| 1378 | if (NATNUMP (Vprint_length) | ||
| 1379 | && XFASTINT (Vprint_length) < size_in_chars) | ||
| 1380 | size_in_chars = XFASTINT (Vprint_length); | ||
| 1381 | |||
| 1382 | for (ptrdiff_t i = 0; i < size_in_chars; i++) | ||
| 1383 | { | ||
| 1384 | maybe_quit (); | ||
| 1385 | unsigned char c = bool_vector_uchar_data (obj)[i]; | ||
| 1386 | if (c == '\n' && print_escape_newlines) | ||
| 1387 | print_c_string ("\\n", printcharfun); | ||
| 1388 | else if (c == '\f' && print_escape_newlines) | ||
| 1389 | print_c_string ("\\f", printcharfun); | ||
| 1390 | else if (c > '\177') | ||
| 1391 | { | ||
| 1392 | /* Use octal escapes to avoid encoding issues. */ | ||
| 1393 | int len = sprintf (buf, "\\%o", c); | ||
| 1394 | strout (buf, len, len, printcharfun); | ||
| 1395 | } | ||
| 1396 | else | ||
| 1397 | { | ||
| 1398 | if (c == '\"' || c == '\\') | ||
| 1399 | printchar ('\\', printcharfun); | ||
| 1400 | printchar (c, printcharfun); | ||
| 1401 | } | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | if (size_in_chars < real_size_in_chars) | ||
| 1405 | print_c_string (" ...", printcharfun); | ||
| 1406 | printchar ('\"', printcharfun); | ||
| 1407 | } | ||
| 1408 | break; | ||
| 1409 | |||
| 1410 | case PVEC_SUBR: | ||
| 1411 | print_c_string ("#<subr ", printcharfun); | ||
| 1412 | print_c_string (XSUBR (obj)->symbol_name, printcharfun); | ||
| 1413 | printchar ('>', printcharfun); | ||
| 1414 | break; | ||
| 1415 | |||
| 1416 | case PVEC_XWIDGET: case PVEC_XWIDGET_VIEW: | ||
| 1417 | print_c_string ("#<xwidget ", printcharfun); | ||
| 1418 | printchar ('>', printcharfun); | ||
| 1419 | break; | ||
| 1420 | |||
| 1421 | case PVEC_WINDOW: | ||
| 1422 | { | ||
| 1423 | int len = sprintf (buf, "#<window %"pI"d", | ||
| 1424 | XWINDOW (obj)->sequence_number); | ||
| 1425 | strout (buf, len, len, printcharfun); | ||
| 1426 | if (BUFFERP (XWINDOW (obj)->contents)) | ||
| 1427 | { | ||
| 1428 | print_c_string (" on ", printcharfun); | ||
| 1429 | print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name), | ||
| 1430 | printcharfun); | ||
| 1431 | } | ||
| 1432 | printchar ('>', printcharfun); | ||
| 1433 | } | ||
| 1434 | break; | ||
| 1435 | |||
| 1436 | case PVEC_TERMINAL: | ||
| 1437 | { | ||
| 1438 | struct terminal *t = XTERMINAL (obj); | ||
| 1439 | int len = sprintf (buf, "#<terminal %d", t->id); | ||
| 1440 | strout (buf, len, len, printcharfun); | ||
| 1441 | if (t->name) | ||
| 1442 | { | ||
| 1443 | print_c_string (" on ", printcharfun); | ||
| 1444 | print_c_string (t->name, printcharfun); | ||
| 1445 | } | ||
| 1446 | printchar ('>', printcharfun); | ||
| 1447 | } | ||
| 1448 | break; | ||
| 1449 | |||
| 1450 | case PVEC_HASH_TABLE: | ||
| 1451 | { | ||
| 1452 | struct Lisp_Hash_Table *h = XHASH_TABLE (obj); | ||
| 1453 | /* Implement a readable output, e.g.: | ||
| 1454 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ | ||
| 1455 | /* Always print the size. */ | ||
| 1456 | int len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); | ||
| 1457 | strout (buf, len, len, printcharfun); | ||
| 1458 | |||
| 1459 | if (!NILP (h->test.name)) | ||
| 1460 | { | ||
| 1461 | print_c_string (" test ", printcharfun); | ||
| 1462 | print_object (h->test.name, printcharfun, escapeflag); | ||
| 1463 | } | ||
| 1464 | |||
| 1465 | if (!NILP (h->weak)) | ||
| 1466 | { | ||
| 1467 | print_c_string (" weakness ", printcharfun); | ||
| 1468 | print_object (h->weak, printcharfun, escapeflag); | ||
| 1469 | } | ||
| 1470 | |||
| 1471 | print_c_string (" rehash-size ", printcharfun); | ||
| 1472 | print_object (Fhash_table_rehash_size (obj), | ||
| 1473 | printcharfun, escapeflag); | ||
| 1474 | |||
| 1475 | print_c_string (" rehash-threshold ", printcharfun); | ||
| 1476 | print_object (Fhash_table_rehash_threshold (obj), | ||
| 1477 | printcharfun, escapeflag); | ||
| 1478 | |||
| 1479 | if (h->pure) | ||
| 1480 | { | ||
| 1481 | print_c_string (" purecopy ", printcharfun); | ||
| 1482 | print_object (h->pure ? Qt : Qnil, printcharfun, escapeflag); | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | print_c_string (" data ", printcharfun); | ||
| 1486 | |||
| 1487 | /* Print the data here as a plist. */ | ||
| 1488 | ptrdiff_t real_size = HASH_TABLE_SIZE (h); | ||
| 1489 | ptrdiff_t size = real_size; | ||
| 1490 | |||
| 1491 | /* Don't print more elements than the specified maximum. */ | ||
| 1492 | if (NATNUMP (Vprint_length) && XFASTINT (Vprint_length) < size) | ||
| 1493 | size = XFASTINT (Vprint_length); | ||
| 1494 | |||
| 1495 | printchar ('(', printcharfun); | ||
| 1496 | for (ptrdiff_t i = 0; i < size; i++) | ||
| 1497 | if (!NILP (HASH_HASH (h, i))) | ||
| 1498 | { | ||
| 1499 | if (i) printchar (' ', printcharfun); | ||
| 1500 | print_object (HASH_KEY (h, i), printcharfun, escapeflag); | ||
| 1501 | printchar (' ', printcharfun); | ||
| 1502 | print_object (HASH_VALUE (h, i), printcharfun, escapeflag); | ||
| 1503 | } | ||
| 1504 | |||
| 1505 | if (size < real_size) | ||
| 1506 | print_c_string (" ...", printcharfun); | ||
| 1507 | |||
| 1508 | print_c_string ("))", printcharfun); | ||
| 1509 | } | ||
| 1510 | break; | ||
| 1511 | |||
| 1512 | case PVEC_BUFFER: | ||
| 1513 | if (!BUFFER_LIVE_P (XBUFFER (obj))) | ||
| 1514 | print_c_string ("#<killed buffer>", printcharfun); | ||
| 1515 | else if (escapeflag) | ||
| 1516 | { | ||
| 1517 | print_c_string ("#<buffer ", printcharfun); | ||
| 1518 | print_string (BVAR (XBUFFER (obj), name), printcharfun); | ||
| 1519 | printchar ('>', printcharfun); | ||
| 1520 | } | ||
| 1521 | else | ||
| 1522 | print_string (BVAR (XBUFFER (obj), name), printcharfun); | ||
| 1523 | break; | ||
| 1524 | |||
| 1525 | case PVEC_WINDOW_CONFIGURATION: | ||
| 1526 | print_c_string ("#<window-configuration>", printcharfun); | ||
| 1527 | break; | ||
| 1528 | |||
| 1529 | case PVEC_FRAME: | ||
| 1530 | { | ||
| 1531 | void *ptr = XFRAME (obj); | ||
| 1532 | Lisp_Object frame_name = XFRAME (obj)->name; | ||
| 1533 | |||
| 1534 | print_c_string ((FRAME_LIVE_P (XFRAME (obj)) | ||
| 1535 | ? "#<frame " | ||
| 1536 | : "#<dead frame "), | ||
| 1537 | printcharfun); | ||
| 1538 | if (!STRINGP (frame_name)) | ||
| 1539 | { | ||
| 1540 | /* A frame could be too young and have no name yet; | ||
| 1541 | don't crash. */ | ||
| 1542 | if (SYMBOLP (frame_name)) | ||
| 1543 | frame_name = Fsymbol_name (frame_name); | ||
| 1544 | else /* can't happen: name should be either nil or string */ | ||
| 1545 | frame_name = build_string ("*INVALID*FRAME*NAME*"); | ||
| 1546 | } | ||
| 1547 | print_string (frame_name, printcharfun); | ||
| 1548 | int len = sprintf (buf, " %p>", ptr); | ||
| 1549 | strout (buf, len, len, printcharfun); | ||
| 1550 | } | ||
| 1551 | break; | ||
| 1552 | |||
| 1553 | case PVEC_FONT: | ||
| 1554 | { | ||
| 1555 | if (! FONT_OBJECT_P (obj)) | ||
| 1556 | { | ||
| 1557 | if (FONT_SPEC_P (obj)) | ||
| 1558 | print_c_string ("#<font-spec", printcharfun); | ||
| 1559 | else | ||
| 1560 | print_c_string ("#<font-entity", printcharfun); | ||
| 1561 | for (int i = 0; i < FONT_SPEC_MAX; i++) | ||
| 1562 | { | ||
| 1563 | printchar (' ', printcharfun); | ||
| 1564 | if (i < FONT_WEIGHT_INDEX || i > FONT_WIDTH_INDEX) | ||
| 1565 | print_object (AREF (obj, i), printcharfun, escapeflag); | ||
| 1566 | else | ||
| 1567 | print_object (font_style_symbolic (obj, i, 0), | ||
| 1568 | printcharfun, escapeflag); | ||
| 1569 | } | ||
| 1570 | } | ||
| 1571 | else | ||
| 1572 | { | ||
| 1573 | print_c_string ("#<font-object ", printcharfun); | ||
| 1574 | print_object (AREF (obj, FONT_NAME_INDEX), printcharfun, | ||
| 1575 | escapeflag); | ||
| 1576 | } | ||
| 1577 | printchar ('>', printcharfun); | ||
| 1578 | } | ||
| 1579 | break; | ||
| 1580 | |||
| 1581 | case PVEC_THREAD: | ||
| 1582 | print_c_string ("#<thread ", printcharfun); | ||
| 1583 | if (STRINGP (XTHREAD (obj)->name)) | ||
| 1584 | print_string (XTHREAD (obj)->name, printcharfun); | ||
| 1585 | else | ||
| 1586 | { | ||
| 1587 | int len = sprintf (buf, "%p", XTHREAD (obj)); | ||
| 1588 | strout (buf, len, len, printcharfun); | ||
| 1589 | } | ||
| 1590 | printchar ('>', printcharfun); | ||
| 1591 | break; | ||
| 1592 | |||
| 1593 | case PVEC_MUTEX: | ||
| 1594 | print_c_string ("#<mutex ", printcharfun); | ||
| 1595 | if (STRINGP (XMUTEX (obj)->name)) | ||
| 1596 | print_string (XMUTEX (obj)->name, printcharfun); | ||
| 1597 | else | ||
| 1598 | { | ||
| 1599 | int len = sprintf (buf, "%p", XMUTEX (obj)); | ||
| 1600 | strout (buf, len, len, printcharfun); | ||
| 1601 | } | ||
| 1602 | printchar ('>', printcharfun); | ||
| 1603 | break; | ||
| 1604 | |||
| 1605 | case PVEC_CONDVAR: | ||
| 1606 | print_c_string ("#<condvar ", printcharfun); | ||
| 1607 | if (STRINGP (XCONDVAR (obj)->name)) | ||
| 1608 | print_string (XCONDVAR (obj)->name, printcharfun); | ||
| 1609 | else | ||
| 1610 | { | ||
| 1611 | int len = sprintf (buf, "%p", XCONDVAR (obj)); | ||
| 1612 | strout (buf, len, len, printcharfun); | ||
| 1613 | } | ||
| 1614 | printchar ('>', printcharfun); | ||
| 1615 | break; | ||
| 1616 | |||
| 1617 | case PVEC_RECORD: | ||
| 1618 | { | ||
| 1619 | ptrdiff_t size = PVSIZE (obj); | ||
| 1620 | |||
| 1621 | /* Don't print more elements than the specified maximum. */ | ||
| 1622 | ptrdiff_t n | ||
| 1623 | = (NATNUMP (Vprint_length) && XFASTINT (Vprint_length) < size | ||
| 1624 | ? XFASTINT (Vprint_length) : size); | ||
| 1625 | |||
| 1626 | print_c_string ("#s(", printcharfun); | ||
| 1627 | for (ptrdiff_t i = 0; i < n; i ++) | ||
| 1628 | { | ||
| 1629 | if (i) printchar (' ', printcharfun); | ||
| 1630 | print_object (AREF (obj, i), printcharfun, escapeflag); | ||
| 1631 | } | ||
| 1632 | if (n < size) | ||
| 1633 | print_c_string (" ...", printcharfun); | ||
| 1634 | printchar (')', printcharfun); | ||
| 1635 | } | ||
| 1636 | break; | ||
| 1637 | |||
| 1638 | case PVEC_SUB_CHAR_TABLE: | ||
| 1639 | case PVEC_COMPILED: | ||
| 1640 | case PVEC_CHAR_TABLE: | ||
| 1641 | case PVEC_NORMAL_VECTOR: | ||
| 1642 | { | ||
| 1643 | ptrdiff_t size = ASIZE (obj); | ||
| 1644 | if (COMPILEDP (obj)) | ||
| 1645 | { | ||
| 1646 | printchar ('#', printcharfun); | ||
| 1647 | size &= PSEUDOVECTOR_SIZE_MASK; | ||
| 1648 | } | ||
| 1649 | if (CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj)) | ||
| 1650 | { | ||
| 1651 | /* Print a char-table as if it were a vector, | ||
| 1652 | lumping the parent and default slots in with the | ||
| 1653 | character slots. But add #^ as a prefix. */ | ||
| 1654 | |||
| 1655 | /* Make each lowest sub_char_table start a new line. | ||
| 1656 | Otherwise we'll make a line extremely long, which | ||
| 1657 | results in slow redisplay. */ | ||
| 1658 | if (SUB_CHAR_TABLE_P (obj) | ||
| 1659 | && XSUB_CHAR_TABLE (obj)->depth == 3) | ||
| 1660 | printchar ('\n', printcharfun); | ||
| 1661 | print_c_string ("#^", printcharfun); | ||
| 1662 | if (SUB_CHAR_TABLE_P (obj)) | ||
| 1663 | printchar ('^', printcharfun); | ||
| 1664 | size &= PSEUDOVECTOR_SIZE_MASK; | ||
| 1665 | } | ||
| 1666 | if (size & PSEUDOVECTOR_FLAG) | ||
| 1667 | return false; | ||
| 1668 | |||
| 1669 | printchar ('[', printcharfun); | ||
| 1670 | |||
| 1671 | int idx = SUB_CHAR_TABLE_P (obj) ? SUB_CHAR_TABLE_OFFSET : 0; | ||
| 1672 | Lisp_Object tem; | ||
| 1673 | ptrdiff_t real_size = size; | ||
| 1674 | |||
| 1675 | /* For a sub char-table, print heading non-Lisp data first. */ | ||
| 1676 | if (SUB_CHAR_TABLE_P (obj)) | ||
| 1677 | { | ||
| 1678 | int i = sprintf (buf, "%d %d", XSUB_CHAR_TABLE (obj)->depth, | ||
| 1679 | XSUB_CHAR_TABLE (obj)->min_char); | ||
| 1680 | strout (buf, i, i, printcharfun); | ||
| 1681 | } | ||
| 1682 | |||
| 1683 | /* Don't print more elements than the specified maximum. */ | ||
| 1684 | if (NATNUMP (Vprint_length) | ||
| 1685 | && XFASTINT (Vprint_length) < size) | ||
| 1686 | size = XFASTINT (Vprint_length); | ||
| 1687 | |||
| 1688 | for (int i = idx; i < size; i++) | ||
| 1689 | { | ||
| 1690 | if (i) printchar (' ', printcharfun); | ||
| 1691 | tem = AREF (obj, i); | ||
| 1692 | print_object (tem, printcharfun, escapeflag); | ||
| 1693 | } | ||
| 1694 | if (size < real_size) | ||
| 1695 | print_c_string (" ...", printcharfun); | ||
| 1696 | printchar (']', printcharfun); | ||
| 1697 | } | ||
| 1698 | break; | ||
| 1699 | |||
| 1700 | #ifdef HAVE_MODULES | ||
| 1701 | case PVEC_MODULE_FUNCTION: | ||
| 1702 | print_string (module_format_fun_env (XMODULE_FUNCTION (obj)), | ||
| 1703 | printcharfun); | ||
| 1704 | break; | ||
| 1705 | #endif | ||
| 1706 | |||
| 1707 | default: | ||
| 1708 | emacs_abort (); | ||
| 1709 | } | ||
| 1710 | |||
| 1711 | return true; | ||
| 1712 | } | ||
| 1713 | |||
| 1349 | static void | 1714 | static void |
| 1350 | print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | 1715 | print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) |
| 1351 | { | 1716 | { |
| @@ -1678,390 +2043,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 1678 | break; | 2043 | break; |
| 1679 | 2044 | ||
| 1680 | case Lisp_Vectorlike: | 2045 | case Lisp_Vectorlike: |
| 1681 | switch (PSEUDOVECTOR_TYPE (XVECTOR (obj))) { | 2046 | if (! print_vectorlike (obj, printcharfun, escapeflag, buf)) |
| 1682 | case PVEC_PROCESS: | 2047 | goto badtype; |
| 1683 | { | ||
| 1684 | if (escapeflag) | ||
| 1685 | { | ||
| 1686 | print_c_string ("#<process ", printcharfun); | ||
| 1687 | print_string (XPROCESS (obj)->name, printcharfun); | ||
| 1688 | printchar ('>', printcharfun); | ||
| 1689 | } | ||
| 1690 | else | ||
| 1691 | print_string (XPROCESS (obj)->name, printcharfun); | ||
| 1692 | } | ||
| 1693 | break; | ||
| 1694 | |||
| 1695 | case PVEC_BOOL_VECTOR: | ||
| 1696 | { | ||
| 1697 | ptrdiff_t i; | ||
| 1698 | unsigned char c; | ||
| 1699 | EMACS_INT size = bool_vector_size (obj); | ||
| 1700 | ptrdiff_t size_in_chars = bool_vector_bytes (size); | ||
| 1701 | ptrdiff_t real_size_in_chars = size_in_chars; | ||
| 1702 | |||
| 1703 | int len = sprintf (buf, "#&%"pI"d\"", size); | ||
| 1704 | strout (buf, len, len, printcharfun); | ||
| 1705 | |||
| 1706 | /* Don't print more characters than the specified maximum. | ||
| 1707 | Negative values of print-length are invalid. Treat them | ||
| 1708 | like a print-length of nil. */ | ||
| 1709 | if (NATNUMP (Vprint_length) | ||
| 1710 | && XFASTINT (Vprint_length) < size_in_chars) | ||
| 1711 | size_in_chars = XFASTINT (Vprint_length); | ||
| 1712 | |||
| 1713 | for (i = 0; i < size_in_chars; i++) | ||
| 1714 | { | ||
| 1715 | maybe_quit (); | ||
| 1716 | c = bool_vector_uchar_data (obj)[i]; | ||
| 1717 | if (c == '\n' && print_escape_newlines) | ||
| 1718 | print_c_string ("\\n", printcharfun); | ||
| 1719 | else if (c == '\f' && print_escape_newlines) | ||
| 1720 | print_c_string ("\\f", printcharfun); | ||
| 1721 | else if (c > '\177') | ||
| 1722 | { | ||
| 1723 | /* Use octal escapes to avoid encoding issues. */ | ||
| 1724 | len = sprintf (buf, "\\%o", c); | ||
| 1725 | strout (buf, len, len, printcharfun); | ||
| 1726 | } | ||
| 1727 | else | ||
| 1728 | { | ||
| 1729 | if (c == '\"' || c == '\\') | ||
| 1730 | printchar ('\\', printcharfun); | ||
| 1731 | printchar (c, printcharfun); | ||
| 1732 | } | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | if (size_in_chars < real_size_in_chars) | ||
| 1736 | print_c_string (" ...", printcharfun); | ||
| 1737 | printchar ('\"', printcharfun); | ||
| 1738 | } | ||
| 1739 | break; | ||
| 1740 | |||
| 1741 | case PVEC_SUBR: | ||
| 1742 | { | ||
| 1743 | print_c_string ("#<subr ", printcharfun); | ||
| 1744 | print_c_string (XSUBR (obj)->symbol_name, printcharfun); | ||
| 1745 | printchar ('>', printcharfun); | ||
| 1746 | } | ||
| 1747 | break; | ||
| 1748 | |||
| 1749 | case PVEC_XWIDGET: case PVEC_XWIDGET_VIEW: | ||
| 1750 | { | ||
| 1751 | print_c_string ("#<xwidget ", printcharfun); | ||
| 1752 | printchar ('>', printcharfun); | ||
| 1753 | } | ||
| 1754 | break; | ||
| 1755 | |||
| 1756 | case PVEC_WINDOW: | ||
| 1757 | { | ||
| 1758 | int len = sprintf (buf, "#<window %"pI"d", | ||
| 1759 | XWINDOW (obj)->sequence_number); | ||
| 1760 | strout (buf, len, len, printcharfun); | ||
| 1761 | if (BUFFERP (XWINDOW (obj)->contents)) | ||
| 1762 | { | ||
| 1763 | print_c_string (" on ", printcharfun); | ||
| 1764 | print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name), | ||
| 1765 | printcharfun); | ||
| 1766 | } | ||
| 1767 | printchar ('>', printcharfun); | ||
| 1768 | } | ||
| 1769 | break; | ||
| 1770 | |||
| 1771 | case PVEC_TERMINAL: | ||
| 1772 | { | ||
| 1773 | struct terminal *t = XTERMINAL (obj); | ||
| 1774 | int len = sprintf (buf, "#<terminal %d", t->id); | ||
| 1775 | strout (buf, len, len, printcharfun); | ||
| 1776 | if (t->name) | ||
| 1777 | { | ||
| 1778 | print_c_string (" on ", printcharfun); | ||
| 1779 | print_c_string (t->name, printcharfun); | ||
| 1780 | } | ||
| 1781 | printchar ('>', printcharfun); | ||
| 1782 | } | ||
| 1783 | break; | ||
| 1784 | |||
| 1785 | case PVEC_HASH_TABLE: | ||
| 1786 | { | ||
| 1787 | struct Lisp_Hash_Table *h = XHASH_TABLE (obj); | ||
| 1788 | ptrdiff_t i; | ||
| 1789 | ptrdiff_t real_size, size; | ||
| 1790 | int len; | ||
| 1791 | /* Implement a readable output, e.g.: | ||
| 1792 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ | ||
| 1793 | /* Always print the size. */ | ||
| 1794 | len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); | ||
| 1795 | strout (buf, len, len, printcharfun); | ||
| 1796 | |||
| 1797 | if (!NILP (h->test.name)) | ||
| 1798 | { | ||
| 1799 | print_c_string (" test ", printcharfun); | ||
| 1800 | print_object (h->test.name, printcharfun, escapeflag); | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | if (!NILP (h->weak)) | ||
| 1804 | { | ||
| 1805 | print_c_string (" weakness ", printcharfun); | ||
| 1806 | print_object (h->weak, printcharfun, escapeflag); | ||
| 1807 | } | ||
| 1808 | |||
| 1809 | print_c_string (" rehash-size ", printcharfun); | ||
| 1810 | print_object (Fhash_table_rehash_size (obj), | ||
| 1811 | printcharfun, escapeflag); | ||
| 1812 | |||
| 1813 | print_c_string (" rehash-threshold ", printcharfun); | ||
| 1814 | print_object (Fhash_table_rehash_threshold (obj), | ||
| 1815 | printcharfun, escapeflag); | ||
| 1816 | |||
| 1817 | if (h->pure) | ||
| 1818 | { | ||
| 1819 | print_c_string (" purecopy ", printcharfun); | ||
| 1820 | print_object (h->pure ? Qt : Qnil, printcharfun, escapeflag); | ||
| 1821 | } | ||
| 1822 | |||
| 1823 | print_c_string (" data ", printcharfun); | ||
| 1824 | |||
| 1825 | /* Print the data here as a plist. */ | ||
| 1826 | real_size = HASH_TABLE_SIZE (h); | ||
| 1827 | size = real_size; | ||
| 1828 | |||
| 1829 | /* Don't print more elements than the specified maximum. */ | ||
| 1830 | if (NATNUMP (Vprint_length) | ||
| 1831 | && XFASTINT (Vprint_length) < size) | ||
| 1832 | size = XFASTINT (Vprint_length); | ||
| 1833 | |||
| 1834 | printchar ('(', printcharfun); | ||
| 1835 | for (i = 0; i < size; i++) | ||
| 1836 | if (!NILP (HASH_HASH (h, i))) | ||
| 1837 | { | ||
| 1838 | if (i) printchar (' ', printcharfun); | ||
| 1839 | print_object (HASH_KEY (h, i), printcharfun, escapeflag); | ||
| 1840 | printchar (' ', printcharfun); | ||
| 1841 | print_object (HASH_VALUE (h, i), printcharfun, escapeflag); | ||
| 1842 | } | ||
| 1843 | |||
| 1844 | if (size < real_size) | ||
| 1845 | print_c_string (" ...", printcharfun); | ||
| 1846 | |||
| 1847 | print_c_string ("))", printcharfun); | ||
| 1848 | } | ||
| 1849 | break; | ||
| 1850 | |||
| 1851 | case PVEC_BUFFER: | ||
| 1852 | { | ||
| 1853 | if (!BUFFER_LIVE_P (XBUFFER (obj))) | ||
| 1854 | print_c_string ("#<killed buffer>", printcharfun); | ||
| 1855 | else if (escapeflag) | ||
| 1856 | { | ||
| 1857 | print_c_string ("#<buffer ", printcharfun); | ||
| 1858 | print_string (BVAR (XBUFFER (obj), name), printcharfun); | ||
| 1859 | printchar ('>', printcharfun); | ||
| 1860 | } | ||
| 1861 | else | ||
| 1862 | print_string (BVAR (XBUFFER (obj), name), printcharfun); | ||
| 1863 | } | ||
| 1864 | break; | ||
| 1865 | |||
| 1866 | case PVEC_WINDOW_CONFIGURATION: | ||
| 1867 | print_c_string ("#<window-configuration>", printcharfun); | ||
| 1868 | break; | ||
| 1869 | |||
| 1870 | case PVEC_FRAME: ; | ||
| 1871 | { | ||
| 1872 | int len; | ||
| 1873 | void *ptr = XFRAME (obj); | ||
| 1874 | Lisp_Object frame_name = XFRAME (obj)->name; | ||
| 1875 | |||
| 1876 | print_c_string ((FRAME_LIVE_P (XFRAME (obj)) | ||
| 1877 | ? "#<frame " | ||
| 1878 | : "#<dead frame "), | ||
| 1879 | printcharfun); | ||
| 1880 | if (!STRINGP (frame_name)) | ||
| 1881 | { | ||
| 1882 | /* A frame could be too young and have no name yet; | ||
| 1883 | don't crash. */ | ||
| 1884 | if (SYMBOLP (frame_name)) | ||
| 1885 | frame_name = Fsymbol_name (frame_name); | ||
| 1886 | else /* can't happen: name should be either nil or string */ | ||
| 1887 | frame_name = build_string ("*INVALID*FRAME*NAME*"); | ||
| 1888 | } | ||
| 1889 | print_string (frame_name, printcharfun); | ||
| 1890 | len = sprintf (buf, " %p>", ptr); | ||
| 1891 | strout (buf, len, len, printcharfun); | ||
| 1892 | } | ||
| 1893 | break; | ||
| 1894 | |||
| 1895 | case PVEC_FONT: | ||
| 1896 | { | ||
| 1897 | int i; | ||
| 1898 | |||
| 1899 | if (! FONT_OBJECT_P (obj)) | ||
| 1900 | { | ||
| 1901 | if (FONT_SPEC_P (obj)) | ||
| 1902 | print_c_string ("#<font-spec", printcharfun); | ||
| 1903 | else | ||
| 1904 | print_c_string ("#<font-entity", printcharfun); | ||
| 1905 | for (i = 0; i < FONT_SPEC_MAX; i++) | ||
| 1906 | { | ||
| 1907 | printchar (' ', printcharfun); | ||
| 1908 | if (i < FONT_WEIGHT_INDEX || i > FONT_WIDTH_INDEX) | ||
| 1909 | print_object (AREF (obj, i), printcharfun, escapeflag); | ||
| 1910 | else | ||
| 1911 | print_object (font_style_symbolic (obj, i, 0), | ||
| 1912 | printcharfun, escapeflag); | ||
| 1913 | } | ||
| 1914 | } | ||
| 1915 | else | ||
| 1916 | { | ||
| 1917 | print_c_string ("#<font-object ", printcharfun); | ||
| 1918 | print_object (AREF (obj, FONT_NAME_INDEX), printcharfun, | ||
| 1919 | escapeflag); | ||
| 1920 | } | ||
| 1921 | printchar ('>', printcharfun); | ||
| 1922 | } | ||
| 1923 | break; | ||
| 1924 | |||
| 1925 | case PVEC_THREAD: | ||
| 1926 | { | ||
| 1927 | print_c_string ("#<thread ", printcharfun); | ||
| 1928 | if (STRINGP (XTHREAD (obj)->name)) | ||
| 1929 | print_string (XTHREAD (obj)->name, printcharfun); | ||
| 1930 | else | ||
| 1931 | { | ||
| 1932 | int len = sprintf (buf, "%p", XTHREAD (obj)); | ||
| 1933 | strout (buf, len, len, printcharfun); | ||
| 1934 | } | ||
| 1935 | printchar ('>', printcharfun); | ||
| 1936 | } | ||
| 1937 | break; | ||
| 1938 | |||
| 1939 | case PVEC_MUTEX: | ||
| 1940 | { | ||
| 1941 | print_c_string ("#<mutex ", printcharfun); | ||
| 1942 | if (STRINGP (XMUTEX (obj)->name)) | ||
| 1943 | print_string (XMUTEX (obj)->name, printcharfun); | ||
| 1944 | else | ||
| 1945 | { | ||
| 1946 | int len = sprintf (buf, "%p", XMUTEX (obj)); | ||
| 1947 | strout (buf, len, len, printcharfun); | ||
| 1948 | } | ||
| 1949 | printchar ('>', printcharfun); | ||
| 1950 | } | ||
| 1951 | break; | ||
| 1952 | |||
| 1953 | case PVEC_CONDVAR: | ||
| 1954 | { | ||
| 1955 | print_c_string ("#<condvar ", printcharfun); | ||
| 1956 | if (STRINGP (XCONDVAR (obj)->name)) | ||
| 1957 | print_string (XCONDVAR (obj)->name, printcharfun); | ||
| 1958 | else | ||
| 1959 | { | ||
| 1960 | int len = sprintf (buf, "%p", XCONDVAR (obj)); | ||
| 1961 | strout (buf, len, len, printcharfun); | ||
| 1962 | } | ||
| 1963 | printchar ('>', printcharfun); | ||
| 1964 | } | ||
| 1965 | break; | ||
| 1966 | |||
| 1967 | case PVEC_RECORD: | ||
| 1968 | { | ||
| 1969 | ptrdiff_t n, size = PVSIZE (obj); | ||
| 1970 | int i; | ||
| 1971 | |||
| 1972 | /* Don't print more elements than the specified maximum. */ | ||
| 1973 | if (NATNUMP (Vprint_length) | ||
| 1974 | && XFASTINT (Vprint_length) < size) | ||
| 1975 | n = XFASTINT (Vprint_length); | ||
| 1976 | else | ||
| 1977 | n = size; | ||
| 1978 | |||
| 1979 | print_c_string ("#s(", printcharfun); | ||
| 1980 | for (i = 0; i < n; i ++) | ||
| 1981 | { | ||
| 1982 | if (i) printchar (' ', printcharfun); | ||
| 1983 | print_object (AREF (obj, i), printcharfun, escapeflag); | ||
| 1984 | } | ||
| 1985 | if (n < size) | ||
| 1986 | print_c_string (" ...", printcharfun); | ||
| 1987 | printchar (')', printcharfun); | ||
| 1988 | } | ||
| 1989 | break; | ||
| 1990 | |||
| 1991 | case PVEC_SUB_CHAR_TABLE: | ||
| 1992 | case PVEC_COMPILED: | ||
| 1993 | case PVEC_CHAR_TABLE: | ||
| 1994 | case PVEC_NORMAL_VECTOR: ; | ||
| 1995 | { | ||
| 1996 | ptrdiff_t size = ASIZE (obj); | ||
| 1997 | if (COMPILEDP (obj)) | ||
| 1998 | { | ||
| 1999 | printchar ('#', printcharfun); | ||
| 2000 | size &= PSEUDOVECTOR_SIZE_MASK; | ||
| 2001 | } | ||
| 2002 | if (CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj)) | ||
| 2003 | { | ||
| 2004 | /* We print a char-table as if it were a vector, | ||
| 2005 | lumping the parent and default slots in with the | ||
| 2006 | character slots. But we add #^ as a prefix. */ | ||
| 2007 | |||
| 2008 | /* Make each lowest sub_char_table start a new line. | ||
| 2009 | Otherwise we'll make a line extremely long, which | ||
| 2010 | results in slow redisplay. */ | ||
| 2011 | if (SUB_CHAR_TABLE_P (obj) | ||
| 2012 | && XSUB_CHAR_TABLE (obj)->depth == 3) | ||
| 2013 | printchar ('\n', printcharfun); | ||
| 2014 | print_c_string ("#^", printcharfun); | ||
| 2015 | if (SUB_CHAR_TABLE_P (obj)) | ||
| 2016 | printchar ('^', printcharfun); | ||
| 2017 | size &= PSEUDOVECTOR_SIZE_MASK; | ||
| 2018 | } | ||
| 2019 | if (size & PSEUDOVECTOR_FLAG) | ||
| 2020 | goto badtype; | ||
| 2021 | |||
| 2022 | printchar ('[', printcharfun); | ||
| 2023 | { | ||
| 2024 | int i, idx = SUB_CHAR_TABLE_P (obj) ? SUB_CHAR_TABLE_OFFSET : 0; | ||
| 2025 | Lisp_Object tem; | ||
| 2026 | ptrdiff_t real_size = size; | ||
| 2027 | |||
| 2028 | /* For a sub char-table, print heading non-Lisp data first. */ | ||
| 2029 | if (SUB_CHAR_TABLE_P (obj)) | ||
| 2030 | { | ||
| 2031 | i = sprintf (buf, "%d %d", XSUB_CHAR_TABLE (obj)->depth, | ||
| 2032 | XSUB_CHAR_TABLE (obj)->min_char); | ||
| 2033 | strout (buf, i, i, printcharfun); | ||
| 2034 | } | ||
| 2035 | |||
| 2036 | /* Don't print more elements than the specified maximum. */ | ||
| 2037 | if (NATNUMP (Vprint_length) | ||
| 2038 | && XFASTINT (Vprint_length) < size) | ||
| 2039 | size = XFASTINT (Vprint_length); | ||
| 2040 | |||
| 2041 | for (i = idx; i < size; i++) | ||
| 2042 | { | ||
| 2043 | if (i) printchar (' ', printcharfun); | ||
| 2044 | tem = AREF (obj, i); | ||
| 2045 | print_object (tem, printcharfun, escapeflag); | ||
| 2046 | } | ||
| 2047 | if (size < real_size) | ||
| 2048 | print_c_string (" ...", printcharfun); | ||
| 2049 | } | ||
| 2050 | printchar (']', printcharfun); | ||
| 2051 | } | ||
| 2052 | break; | ||
| 2053 | |||
| 2054 | #ifdef HAVE_MODULES | ||
| 2055 | case PVEC_MODULE_FUNCTION: | ||
| 2056 | print_string (module_format_fun_env (XMODULE_FUNCTION (obj)), | ||
| 2057 | printcharfun); | ||
| 2058 | break; | ||
| 2059 | #endif | ||
| 2060 | |||
| 2061 | case PVEC_OTHER: | ||
| 2062 | case PVEC_FREE: | ||
| 2063 | emacs_abort (); | ||
| 2064 | } | ||
| 2065 | break; | 2048 | break; |
| 2066 | 2049 | ||
| 2067 | case Lisp_Misc: | 2050 | case Lisp_Misc: |