aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorJoakim Verona2012-07-27 02:22:03 +0200
committerJoakim Verona2012-07-27 02:22:03 +0200
commit5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f (patch)
tree5c55f1096a656a9759f0b53a0b5d1a2289bd366f /src/print.c
parent0c5c85cf2b350c965bb1ffa5b2d77c2adebc406b (diff)
parent562157c814037dcba58a20cd6908a95992c22283 (diff)
downloademacs-5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f.tar.gz
emacs-5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f.zip
upstream
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c158
1 files changed, 94 insertions, 64 deletions
diff --git a/src/print.c b/src/print.c
index c282c64aa89..5b8e80dcf51 100644
--- a/src/print.c
+++ b/src/print.c
@@ -159,7 +159,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1;
159 else \ 159 else \
160 { \ 160 { \
161 int new_size = 1000; \ 161 int new_size = 1000; \
162 print_buffer = (char *) xmalloc (new_size); \ 162 print_buffer = xmalloc (new_size); \
163 print_buffer_size = new_size; \ 163 print_buffer_size = new_size; \
164 free_print_buffer = 1; \ 164 free_print_buffer = 1; \
165 } \ 165 } \
@@ -175,8 +175,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1;
175 if (print_buffer_pos != print_buffer_pos_byte \ 175 if (print_buffer_pos != print_buffer_pos_byte \
176 && NILP (BVAR (current_buffer, enable_multibyte_characters))) \ 176 && NILP (BVAR (current_buffer, enable_multibyte_characters))) \
177 { \ 177 { \
178 unsigned char *temp \ 178 unsigned char *temp = alloca (print_buffer_pos + 1); \
179 = (unsigned char *) alloca (print_buffer_pos + 1); \
180 copy_text ((unsigned char *) print_buffer, temp, \ 179 copy_text ((unsigned char *) print_buffer, temp, \
181 print_buffer_pos_byte, 1, 0); \ 180 print_buffer_pos_byte, 1, 0); \
182 insert_1_both ((char *) temp, print_buffer_pos, \ 181 insert_1_both ((char *) temp, print_buffer_pos, \
@@ -914,7 +913,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
914 for (; CONSP (tail); tail = XCDR (tail), sep = ", ") 913 for (; CONSP (tail); tail = XCDR (tail), sep = ", ")
915 { 914 {
916 Lisp_Object obj; 915 Lisp_Object obj;
917 916
918 if (sep) 917 if (sep)
919 write_string_1 (sep, 2, stream); 918 write_string_1 (sep, 2, stream);
920 obj = XCAR (tail); 919 obj = XCAR (tail);
@@ -946,43 +945,49 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context,
946 * Given the above, the buffer must be least FLOAT_TO_STRING_BUFSIZE bytes. 945 * Given the above, the buffer must be least FLOAT_TO_STRING_BUFSIZE bytes.
947 */ 946 */
948 947
949void 948int
950float_to_string (char *buf, double data) 949float_to_string (char *buf, double data)
951{ 950{
952 char *cp; 951 char *cp;
953 int width; 952 int width;
953 int len;
954 954
955 /* Check for plus infinity in a way that won't lose 955 /* Check for plus infinity in a way that won't lose
956 if there is no plus infinity. */ 956 if there is no plus infinity. */
957 if (data == data / 2 && data > 1.0) 957 if (data == data / 2 && data > 1.0)
958 { 958 {
959 strcpy (buf, "1.0e+INF"); 959 static char const infinity_string[] = "1.0e+INF";
960 return; 960 strcpy (buf, infinity_string);
961 return sizeof infinity_string - 1;
961 } 962 }
962 /* Likewise for minus infinity. */ 963 /* Likewise for minus infinity. */
963 if (data == data / 2 && data < -1.0) 964 if (data == data / 2 && data < -1.0)
964 { 965 {
965 strcpy (buf, "-1.0e+INF"); 966 static char const minus_infinity_string[] = "-1.0e+INF";
966 return; 967 strcpy (buf, minus_infinity_string);
968 return sizeof minus_infinity_string - 1;
967 } 969 }
968 /* Check for NaN in a way that won't fail if there are no NaNs. */ 970 /* Check for NaN in a way that won't fail if there are no NaNs. */
969 if (! (data * 0.0 >= 0.0)) 971 if (! (data * 0.0 >= 0.0))
970 { 972 {
971 /* Prepend "-" if the NaN's sign bit is negative. 973 /* Prepend "-" if the NaN's sign bit is negative.
972 The sign bit of a double is the bit that is 1 in -0.0. */ 974 The sign bit of a double is the bit that is 1 in -0.0. */
975 static char const NaN_string[] = "0.0e+NaN";
973 int i; 976 int i;
974 union { double d; char c[sizeof (double)]; } u_data, u_minus_zero; 977 union { double d; char c[sizeof (double)]; } u_data, u_minus_zero;
978 int negative = 0;
975 u_data.d = data; 979 u_data.d = data;
976 u_minus_zero.d = - 0.0; 980 u_minus_zero.d = - 0.0;
977 for (i = 0; i < sizeof (double); i++) 981 for (i = 0; i < sizeof (double); i++)
978 if (u_data.c[i] & u_minus_zero.c[i]) 982 if (u_data.c[i] & u_minus_zero.c[i])
979 { 983 {
980 *buf++ = '-'; 984 *buf = '-';
985 negative = 1;
981 break; 986 break;
982 } 987 }
983 988
984 strcpy (buf, "0.0e+NaN"); 989 strcpy (buf + negative, NaN_string);
985 return; 990 return negative + sizeof NaN_string - 1;
986 } 991 }
987 992
988 if (NILP (Vfloat_output_format) 993 if (NILP (Vfloat_output_format)
@@ -991,7 +996,7 @@ float_to_string (char *buf, double data)
991 { 996 {
992 /* Generate the fewest number of digits that represent the 997 /* Generate the fewest number of digits that represent the
993 floating point value without losing information. */ 998 floating point value without losing information. */
994 dtoastr (buf, FLOAT_TO_STRING_BUFSIZE - 2, 0, 0, data); 999 len = dtoastr (buf, FLOAT_TO_STRING_BUFSIZE - 2, 0, 0, data);
995 /* The decimal point must be printed, or the byte compiler can 1000 /* The decimal point must be printed, or the byte compiler can
996 get confused (Bug#8033). */ 1001 get confused (Bug#8033). */
997 width = 1; 1002 width = 1;
@@ -1034,7 +1039,7 @@ float_to_string (char *buf, double data)
1034 if (cp[1] != 0) 1039 if (cp[1] != 0)
1035 goto lose; 1040 goto lose;
1036 1041
1037 sprintf (buf, SSDATA (Vfloat_output_format), data); 1042 len = sprintf (buf, SSDATA (Vfloat_output_format), data);
1038 } 1043 }
1039 1044
1040 /* Make sure there is a decimal point with digit after, or an 1045 /* Make sure there is a decimal point with digit after, or an
@@ -1051,14 +1056,18 @@ float_to_string (char *buf, double data)
1051 { 1056 {
1052 cp[1] = '0'; 1057 cp[1] = '0';
1053 cp[2] = 0; 1058 cp[2] = 0;
1059 len++;
1054 } 1060 }
1055 else if (*cp == 0) 1061 else if (*cp == 0)
1056 { 1062 {
1057 *cp++ = '.'; 1063 *cp++ = '.';
1058 *cp++ = '0'; 1064 *cp++ = '0';
1059 *cp++ = 0; 1065 *cp++ = 0;
1066 len += 2;
1060 } 1067 }
1061 } 1068 }
1069
1070 return len;
1062} 1071}
1063 1072
1064 1073
@@ -1210,7 +1219,7 @@ print_preprocess (Lisp_Object obj)
1210 if (size & PSEUDOVECTOR_FLAG) 1219 if (size & PSEUDOVECTOR_FLAG)
1211 size &= PSEUDOVECTOR_SIZE_MASK; 1220 size &= PSEUDOVECTOR_SIZE_MASK;
1212 for (i = 0; i < size; i++) 1221 for (i = 0; i < size; i++)
1213 print_preprocess (XVECTOR (obj)->contents[i]); 1222 print_preprocess (AREF (obj, i));
1214 if (HASH_TABLE_P (obj)) 1223 if (HASH_TABLE_P (obj))
1215 { /* For hash tables, the key_and_value slot is past 1224 { /* For hash tables, the key_and_value slot is past
1216 `size' because it needs to be marked specially in case 1225 `size' because it needs to be marked specially in case
@@ -1334,8 +1343,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1334 for (i = 0; i < print_depth; i++) 1343 for (i = 0; i < print_depth; i++)
1335 if (EQ (obj, being_printed[i])) 1344 if (EQ (obj, being_printed[i]))
1336 { 1345 {
1337 sprintf (buf, "#%d", i); 1346 int len = sprintf (buf, "#%d", i);
1338 strout (buf, -1, -1, printcharfun); 1347 strout (buf, len, len, printcharfun);
1339 return; 1348 return;
1340 } 1349 }
1341 being_printed[print_depth] = obj; 1350 being_printed[print_depth] = obj;
@@ -1350,16 +1359,16 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1350 if (n < 0) 1359 if (n < 0)
1351 { /* Add a prefix #n= if OBJ has not yet been printed; 1360 { /* Add a prefix #n= if OBJ has not yet been printed;
1352 that is, its status field is nil. */ 1361 that is, its status field is nil. */
1353 sprintf (buf, "#%"pI"d=", -n); 1362 int len = sprintf (buf, "#%"pI"d=", -n);
1354 strout (buf, -1, -1, printcharfun); 1363 strout (buf, len, len, printcharfun);
1355 /* OBJ is going to be printed. Remember that fact. */ 1364 /* OBJ is going to be printed. Remember that fact. */
1356 Fputhash (obj, make_number (- n), Vprint_number_table); 1365 Fputhash (obj, make_number (- n), Vprint_number_table);
1357 } 1366 }
1358 else 1367 else
1359 { 1368 {
1360 /* Just print #n# if OBJ has already been printed. */ 1369 /* Just print #n# if OBJ has already been printed. */
1361 sprintf (buf, "#%"pI"d#", n); 1370 int len = sprintf (buf, "#%"pI"d#", n);
1362 strout (buf, -1, -1, printcharfun); 1371 strout (buf, len, len, printcharfun);
1363 return; 1372 return;
1364 } 1373 }
1365 } 1374 }
@@ -1370,16 +1379,17 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1370 switch (XTYPE (obj)) 1379 switch (XTYPE (obj))
1371 { 1380 {
1372 case_Lisp_Int: 1381 case_Lisp_Int:
1373 sprintf (buf, "%"pI"d", XINT (obj)); 1382 {
1374 strout (buf, -1, -1, printcharfun); 1383 int len = sprintf (buf, "%"pI"d", XINT (obj));
1384 strout (buf, len, len, printcharfun);
1385 }
1375 break; 1386 break;
1376 1387
1377 case Lisp_Float: 1388 case Lisp_Float:
1378 { 1389 {
1379 char pigbuf[FLOAT_TO_STRING_BUFSIZE]; 1390 char pigbuf[FLOAT_TO_STRING_BUFSIZE];
1380 1391 int len = float_to_string (pigbuf, XFLOAT_DATA (obj));
1381 float_to_string (pigbuf, XFLOAT_DATA (obj)); 1392 strout (pigbuf, len, len, printcharfun);
1382 strout (pigbuf, -1, -1, printcharfun);
1383 } 1393 }
1384 break; 1394 break;
1385 1395
@@ -1449,15 +1459,16 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1449 when found in a multibyte string, always use a hex escape 1459 when found in a multibyte string, always use a hex escape
1450 so it reads back as multibyte. */ 1460 so it reads back as multibyte. */
1451 char outbuf[50]; 1461 char outbuf[50];
1462 int len;
1452 1463
1453 if (CHAR_BYTE8_P (c)) 1464 if (CHAR_BYTE8_P (c))
1454 sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c)); 1465 len = sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c));
1455 else 1466 else
1456 { 1467 {
1457 sprintf (outbuf, "\\x%04x", c); 1468 len = sprintf (outbuf, "\\x%04x", c);
1458 need_nonhex = 1; 1469 need_nonhex = 1;
1459 } 1470 }
1460 strout (outbuf, -1, -1, printcharfun); 1471 strout (outbuf, len, len, printcharfun);
1461 } 1472 }
1462 else if (! multibyte 1473 else if (! multibyte
1463 && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) 1474 && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c)
@@ -1468,8 +1479,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1468 print single-byte non-ASCII string chars 1479 print single-byte non-ASCII string chars
1469 using octal escapes. */ 1480 using octal escapes. */
1470 char outbuf[5]; 1481 char outbuf[5];
1471 sprintf (outbuf, "\\%03o", c); 1482 int len = sprintf (outbuf, "\\%03o", c);
1472 strout (outbuf, -1, -1, printcharfun); 1483 strout (outbuf, len, len, printcharfun);
1473 } 1484 }
1474 else 1485 else
1475 { 1486 {
@@ -1634,8 +1645,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1634 /* Simple but incomplete way. */ 1645 /* Simple but incomplete way. */
1635 if (i != 0 && EQ (obj, halftail)) 1646 if (i != 0 && EQ (obj, halftail))
1636 { 1647 {
1637 sprintf (buf, " . #%"pMd, i / 2); 1648 int len = sprintf (buf, " . #%"pMd, i / 2);
1638 strout (buf, -1, -1, printcharfun); 1649 strout (buf, len, len, printcharfun);
1639 goto end_of_list; 1650 goto end_of_list;
1640 } 1651 }
1641 } 1652 }
@@ -1699,7 +1710,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1699 else if (BOOL_VECTOR_P (obj)) 1710 else if (BOOL_VECTOR_P (obj))
1700 { 1711 {
1701 ptrdiff_t i; 1712 ptrdiff_t i;
1702 register unsigned char c; 1713 int len;
1714 unsigned char c;
1703 struct gcpro gcpro1; 1715 struct gcpro gcpro1;
1704 ptrdiff_t size_in_chars 1716 ptrdiff_t size_in_chars
1705 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) 1717 = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
@@ -1709,8 +1721,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1709 1721
1710 PRINTCHAR ('#'); 1722 PRINTCHAR ('#');
1711 PRINTCHAR ('&'); 1723 PRINTCHAR ('&');
1712 sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size); 1724 len = sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size);
1713 strout (buf, -1, -1, printcharfun); 1725 strout (buf, len, len, printcharfun);
1714 PRINTCHAR ('\"'); 1726 PRINTCHAR ('\"');
1715 1727
1716 /* Don't print more characters than the specified maximum. 1728 /* Don't print more characters than the specified maximum.
@@ -1768,9 +1780,10 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1768#endif 1780#endif
1769 else if (WINDOWP (obj)) 1781 else if (WINDOWP (obj))
1770 { 1782 {
1783 int len;
1771 strout ("#<window ", -1, -1, printcharfun); 1784 strout ("#<window ", -1, -1, printcharfun);
1772 sprintf (buf, "%"pI"d", XFASTINT (XWINDOW (obj)->sequence_number)); 1785 len = sprintf (buf, "%d", XWINDOW (obj)->sequence_number);
1773 strout (buf, -1, -1, printcharfun); 1786 strout (buf, len, len, printcharfun);
1774 if (!NILP (XWINDOW (obj)->buffer)) 1787 if (!NILP (XWINDOW (obj)->buffer))
1775 { 1788 {
1776 strout (" on ", -1, -1, printcharfun); 1789 strout (" on ", -1, -1, printcharfun);
@@ -1780,10 +1793,11 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1780 } 1793 }
1781 else if (TERMINALP (obj)) 1794 else if (TERMINALP (obj))
1782 { 1795 {
1796 int len;
1783 struct terminal *t = XTERMINAL (obj); 1797 struct terminal *t = XTERMINAL (obj);
1784 strout ("#<terminal ", -1, -1, printcharfun); 1798 strout ("#<terminal ", -1, -1, printcharfun);
1785 sprintf (buf, "%d", t->id); 1799 len = sprintf (buf, "%d", t->id);
1786 strout (buf, -1, -1, printcharfun); 1800 strout (buf, len, len, printcharfun);
1787 if (t->name) 1801 if (t->name)
1788 { 1802 {
1789 strout (" on ", -1, -1, printcharfun); 1803 strout (" on ", -1, -1, printcharfun);
@@ -1796,6 +1810,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1796 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); 1810 struct Lisp_Hash_Table *h = XHASH_TABLE (obj);
1797 ptrdiff_t i; 1811 ptrdiff_t i;
1798 ptrdiff_t real_size, size; 1812 ptrdiff_t real_size, size;
1813 int len;
1799#if 0 1814#if 0
1800 strout ("#<hash-table", -1, -1, printcharfun); 1815 strout ("#<hash-table", -1, -1, printcharfun);
1801 if (SYMBOLP (h->test)) 1816 if (SYMBOLP (h->test))
@@ -1806,18 +1821,18 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1806 PRINTCHAR (' '); 1821 PRINTCHAR (' ');
1807 strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun); 1822 strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun);
1808 PRINTCHAR (' '); 1823 PRINTCHAR (' ');
1809 sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next)); 1824 len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next));
1810 strout (buf, -1, -1, printcharfun); 1825 strout (buf, len, len, printcharfun);
1811 } 1826 }
1812 sprintf (buf, " %p", h); 1827 len = sprintf (buf, " %p", h);
1813 strout (buf, -1, -1, printcharfun); 1828 strout (buf, len, len, printcharfun);
1814 PRINTCHAR ('>'); 1829 PRINTCHAR ('>');
1815#endif 1830#endif
1816 /* Implement a readable output, e.g.: 1831 /* Implement a readable output, e.g.:
1817 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ 1832 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
1818 /* Always print the size. */ 1833 /* Always print the size. */
1819 sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); 1834 len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next));
1820 strout (buf, -1, -1, printcharfun); 1835 strout (buf, len, len, printcharfun);
1821 1836
1822 if (!NILP (h->test)) 1837 if (!NILP (h->test))
1823 { 1838 {
@@ -1890,12 +1905,24 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1890 } 1905 }
1891 else if (FRAMEP (obj)) 1906 else if (FRAMEP (obj))
1892 { 1907 {
1908 int len;
1909 Lisp_Object frame_name = XFRAME (obj)->name;
1910
1893 strout ((FRAME_LIVE_P (XFRAME (obj)) 1911 strout ((FRAME_LIVE_P (XFRAME (obj))
1894 ? "#<frame " : "#<dead frame "), 1912 ? "#<frame " : "#<dead frame "),
1895 -1, -1, printcharfun); 1913 -1, -1, printcharfun);
1896 print_string (XFRAME (obj)->name, printcharfun); 1914 if (!STRINGP (frame_name))
1897 sprintf (buf, " %p", XFRAME (obj)); 1915 {
1898 strout (buf, -1, -1, printcharfun); 1916 /* A frame could be too young and have no name yet;
1917 don't crash. */
1918 if (SYMBOLP (frame_name))
1919 frame_name = Fsymbol_name (frame_name);
1920 else /* can't happen: name should be either nil or string */
1921 frame_name = build_string ("*INVALID*FRAME*NAME*");
1922 }
1923 print_string (frame_name, printcharfun);
1924 len = sprintf (buf, " %p", XFRAME (obj));
1925 strout (buf, len, len, printcharfun);
1899 PRINTCHAR ('>'); 1926 PRINTCHAR ('>');
1900 } 1927 }
1901 else if (FONTP (obj)) 1928 else if (FONTP (obj))
@@ -1969,7 +1996,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1969 for (i = 0; i < size; i++) 1996 for (i = 0; i < size; i++)
1970 { 1997 {
1971 if (i) PRINTCHAR (' '); 1998 if (i) PRINTCHAR (' ');
1972 tem = XVECTOR (obj)->contents[i]; 1999 tem = AREF (obj, i);
1973 print_object (tem, printcharfun, escapeflag); 2000 print_object (tem, printcharfun, escapeflag);
1974 } 2001 }
1975 if (size < real_size) 2002 if (size < real_size)
@@ -1991,8 +2018,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
1991 strout ("in no buffer", -1, -1, printcharfun); 2018 strout ("in no buffer", -1, -1, printcharfun);
1992 else 2019 else
1993 { 2020 {
1994 sprintf (buf, "at %"pD"d", marker_position (obj)); 2021 int len = sprintf (buf, "at %"pD"d", marker_position (obj));
1995 strout (buf, -1, -1, printcharfun); 2022 strout (buf, len, len, printcharfun);
1996 strout (" in ", -1, -1, printcharfun); 2023 strout (" in ", -1, -1, printcharfun);
1997 print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun); 2024 print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun);
1998 } 2025 }
@@ -2005,10 +2032,10 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2005 strout ("in no buffer", -1, -1, printcharfun); 2032 strout ("in no buffer", -1, -1, printcharfun);
2006 else 2033 else
2007 { 2034 {
2008 sprintf (buf, "from %"pD"d to %"pD"d in ", 2035 int len = sprintf (buf, "from %"pD"d to %"pD"d in ",
2009 marker_position (OVERLAY_START (obj)), 2036 marker_position (OVERLAY_START (obj)),
2010 marker_position (OVERLAY_END (obj))); 2037 marker_position (OVERLAY_END (obj)));
2011 strout (buf, -1, -1, printcharfun); 2038 strout (buf, len, len, printcharfun);
2012 print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name), 2039 print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name),
2013 printcharfun); 2040 printcharfun);
2014 } 2041 }
@@ -2023,10 +2050,12 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2023 2050
2024 case Lisp_Misc_Save_Value: 2051 case Lisp_Misc_Save_Value:
2025 strout ("#<save_value ", -1, -1, printcharfun); 2052 strout ("#<save_value ", -1, -1, printcharfun);
2026 sprintf (buf, "ptr=%p int=%"pD"d", 2053 {
2027 XSAVE_VALUE (obj)->pointer, 2054 int len = sprintf (buf, "ptr=%p int=%"pD"d",
2028 XSAVE_VALUE (obj)->integer); 2055 XSAVE_VALUE (obj)->pointer,
2029 strout (buf, -1, -1, printcharfun); 2056 XSAVE_VALUE (obj)->integer);
2057 strout (buf, len, len, printcharfun);
2058 }
2030 PRINTCHAR ('>'); 2059 PRINTCHAR ('>');
2031 break; 2060 break;
2032 2061
@@ -2038,16 +2067,17 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
2038 default: 2067 default:
2039 badtype: 2068 badtype:
2040 { 2069 {
2070 int len;
2041 /* We're in trouble if this happens! 2071 /* We're in trouble if this happens!
2042 Probably should just abort () */ 2072 Probably should just abort () */
2043 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); 2073 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun);
2044 if (MISCP (obj)) 2074 if (MISCP (obj))
2045 sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); 2075 len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj));
2046 else if (VECTORLIKEP (obj)) 2076 else if (VECTORLIKEP (obj))
2047 sprintf (buf, "(PVEC 0x%08"pD"x)", ASIZE (obj)); 2077 len = sprintf (buf, "(PVEC 0x%08"pD"x)", ASIZE (obj));
2048 else 2078 else
2049 sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); 2079 len = sprintf (buf, "(0x%02x)", (int) XTYPE (obj));
2050 strout (buf, -1, -1, printcharfun); 2080 strout (buf, len, len, printcharfun);
2051 strout (" Save your buffers immediately and please report this bug>", 2081 strout (" Save your buffers immediately and please report this bug>",
2052 -1, -1, printcharfun); 2082 -1, -1, printcharfun);
2053 } 2083 }