diff options
| author | Joakim Verona | 2011-09-05 10:37:16 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-09-05 10:37:16 +0200 |
| commit | 687faaf59cdf4029b5e8da16965b257592059e37 (patch) | |
| tree | c19fc758dc421ec1e6619de88d7cd70258927b47 /src/print.c | |
| parent | d47f8c5baeaa804548a73675077c8e37cdfe5142 (diff) | |
| parent | f62bd846552a090f3ba5e136d6d9cdb4c07ed7be (diff) | |
| download | emacs-687faaf59cdf4029b5e8da16965b257592059e37.tar.gz emacs-687faaf59cdf4029b5e8da16965b257592059e37.zip | |
upstream
Diffstat (limited to 'src/print.c')
| -rw-r--r-- | src/print.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/print.c b/src/print.c index 15650d1bb6e..d15590a8880 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1018,12 +1018,15 @@ float_to_string (char *buf, double data) | |||
| 1018 | { | 1018 | { |
| 1019 | width = 0; | 1019 | width = 0; |
| 1020 | do | 1020 | do |
| 1021 | width = (width * 10) + (*cp++ - '0'); | 1021 | { |
| 1022 | width = (width * 10) + (*cp++ - '0'); | ||
| 1023 | if (DBL_DIG < width) | ||
| 1024 | goto lose; | ||
| 1025 | } | ||
| 1022 | while (*cp >= '0' && *cp <= '9'); | 1026 | while (*cp >= '0' && *cp <= '9'); |
| 1023 | 1027 | ||
| 1024 | /* A precision of zero is valid only for %f. */ | 1028 | /* A precision of zero is valid only for %f. */ |
| 1025 | if (width > DBL_DIG | 1029 | if (width == 0 && *cp != 'f') |
| 1026 | || (width == 0 && *cp != 'f')) | ||
| 1027 | goto lose; | 1030 | goto lose; |
| 1028 | } | 1031 | } |
| 1029 | 1032 | ||
| @@ -1316,7 +1319,9 @@ print_prune_string_charset (Lisp_Object string) | |||
| 1316 | static void | 1319 | static void |
| 1317 | print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag) | 1320 | print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag) |
| 1318 | { | 1321 | { |
| 1319 | char buf[40]; | 1322 | char buf[max (sizeof "from..to..in " + 2 * INT_STRLEN_BOUND (EMACS_INT), |
| 1323 | max (sizeof " . #" + INT_STRLEN_BOUND (printmax_t), | ||
| 1324 | 40))]; | ||
| 1320 | 1325 | ||
| 1321 | QUIT; | 1326 | QUIT; |
| 1322 | 1327 | ||
| @@ -1616,8 +1621,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1616 | PRINTCHAR ('('); | 1621 | PRINTCHAR ('('); |
| 1617 | 1622 | ||
| 1618 | { | 1623 | { |
| 1619 | EMACS_INT print_length; | 1624 | printmax_t i, print_length; |
| 1620 | int i; | ||
| 1621 | Lisp_Object halftail = obj; | 1625 | Lisp_Object halftail = obj; |
| 1622 | 1626 | ||
| 1623 | /* Negative values of print-length are invalid in CL. | 1627 | /* Negative values of print-length are invalid in CL. |
| @@ -1625,7 +1629,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1625 | if (NATNUMP (Vprint_length)) | 1629 | if (NATNUMP (Vprint_length)) |
| 1626 | print_length = XFASTINT (Vprint_length); | 1630 | print_length = XFASTINT (Vprint_length); |
| 1627 | else | 1631 | else |
| 1628 | print_length = 0; | 1632 | print_length = TYPE_MAXIMUM (printmax_t); |
| 1629 | 1633 | ||
| 1630 | i = 0; | 1634 | i = 0; |
| 1631 | while (CONSP (obj)) | 1635 | while (CONSP (obj)) |
| @@ -1636,7 +1640,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1636 | /* Simple but imcomplete way. */ | 1640 | /* Simple but imcomplete way. */ |
| 1637 | if (i != 0 && EQ (obj, halftail)) | 1641 | if (i != 0 && EQ (obj, halftail)) |
| 1638 | { | 1642 | { |
| 1639 | sprintf (buf, " . #%d", i / 2); | 1643 | sprintf (buf, " . #%"pMd, i / 2); |
| 1640 | strout (buf, -1, -1, printcharfun); | 1644 | strout (buf, -1, -1, printcharfun); |
| 1641 | goto end_of_list; | 1645 | goto end_of_list; |
| 1642 | } | 1646 | } |
| @@ -1656,15 +1660,16 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1656 | } | 1660 | } |
| 1657 | } | 1661 | } |
| 1658 | 1662 | ||
| 1659 | if (i++) | 1663 | if (i) |
| 1660 | PRINTCHAR (' '); | 1664 | PRINTCHAR (' '); |
| 1661 | 1665 | ||
| 1662 | if (print_length && i > print_length) | 1666 | if (print_length <= i) |
| 1663 | { | 1667 | { |
| 1664 | strout ("...", 3, 3, printcharfun); | 1668 | strout ("...", 3, 3, printcharfun); |
| 1665 | goto end_of_list; | 1669 | goto end_of_list; |
| 1666 | } | 1670 | } |
| 1667 | 1671 | ||
| 1672 | i++; | ||
| 1668 | print_object (XCAR (obj), printcharfun, escapeflag); | 1673 | print_object (XCAR (obj), printcharfun, escapeflag); |
| 1669 | 1674 | ||
| 1670 | obj = XCDR (obj); | 1675 | obj = XCDR (obj); |
| @@ -1699,7 +1704,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1699 | } | 1704 | } |
| 1700 | else if (BOOL_VECTOR_P (obj)) | 1705 | else if (BOOL_VECTOR_P (obj)) |
| 1701 | { | 1706 | { |
| 1702 | register int i; | 1707 | ptrdiff_t i; |
| 1703 | register unsigned char c; | 1708 | register unsigned char c; |
| 1704 | struct gcpro gcpro1; | 1709 | struct gcpro gcpro1; |
| 1705 | EMACS_INT size_in_chars | 1710 | EMACS_INT size_in_chars |
| @@ -1807,19 +1812,17 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1807 | PRINTCHAR (' '); | 1812 | PRINTCHAR (' '); |
| 1808 | strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun); | 1813 | strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun); |
| 1809 | PRINTCHAR (' '); | 1814 | PRINTCHAR (' '); |
| 1810 | sprintf (buf, "%ld/%ld", (long) h->count, | 1815 | sprintf (buf, "%"pI"d/%"pI"d", h->count, ASIZE (h->next)); |
| 1811 | (long) ASIZE (h->next)); | ||
| 1812 | strout (buf, -1, -1, printcharfun); | 1816 | strout (buf, -1, -1, printcharfun); |
| 1813 | } | 1817 | } |
| 1814 | sprintf (buf, " 0x%lx", (unsigned long) h); | 1818 | sprintf (buf, " %p", h); |
| 1815 | strout (buf, -1, -1, printcharfun); | 1819 | strout (buf, -1, -1, printcharfun); |
| 1816 | PRINTCHAR ('>'); | 1820 | PRINTCHAR ('>'); |
| 1817 | #endif | 1821 | #endif |
| 1818 | /* Implement a readable output, e.g.: | 1822 | /* Implement a readable output, e.g.: |
| 1819 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ | 1823 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ |
| 1820 | /* Always print the size. */ | 1824 | /* Always print the size. */ |
| 1821 | sprintf (buf, "#s(hash-table size %ld", | 1825 | sprintf (buf, "#s(hash-table size %"pI"d", ASIZE (h->next)); |
| 1822 | (long) ASIZE (h->next)); | ||
| 1823 | strout (buf, -1, -1, printcharfun); | 1826 | strout (buf, -1, -1, printcharfun); |
| 1824 | 1827 | ||
| 1825 | if (!NILP (h->test)) | 1828 | if (!NILP (h->test)) |
| @@ -2047,7 +2050,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 2047 | if (MISCP (obj)) | 2050 | if (MISCP (obj)) |
| 2048 | sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); | 2051 | sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); |
| 2049 | else if (VECTORLIKEP (obj)) | 2052 | else if (VECTORLIKEP (obj)) |
| 2050 | sprintf (buf, "(PVEC 0x%08lx)", (unsigned long) ASIZE (obj)); | 2053 | sprintf (buf, "(PVEC 0x%08"pI"x)", ASIZE (obj)); |
| 2051 | else | 2054 | else |
| 2052 | sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); | 2055 | sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); |
| 2053 | strout (buf, -1, -1, printcharfun); | 2056 | strout (buf, -1, -1, printcharfun); |