diff options
| author | Paul Eggert | 2012-06-25 19:33:51 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-06-25 19:33:51 -0700 |
| commit | 99027bdd81f63ea690394a153ef49a08f55e498d (patch) | |
| tree | b7b7083784549ae09d9e688441168627262d4b6d /src/print.c | |
| parent | cf38a720e81b545f90dc7be81891d94df6ed059a (diff) | |
| download | emacs-99027bdd81f63ea690394a153ef49a08f55e498d.tar.gz emacs-99027bdd81f63ea690394a153ef49a08f55e498d.zip | |
Use sprintf return value instead of invoking strlen on result.
In the old days this wasn't portable, since some sprintf
implementations returned char *. But they died out years ago and
Emacs already assumes sprintf returns int.
Similarly for float_to_string.
This patch speeds up (number-to-string 1000) by 3% on Fedora 15 x86-64.
* ccl.c (ccl_driver):
* character.c (string_escape_byte8):
* data.c (Fnumber_to_string):
* doprnt.c (doprnt):
* print.c (print_object):
* xdisp.c (message_dolog):
* xfns.c (syms_of_xfns):
Use sprintf or float_to_string result to avoid need to call strlen.
* data.c (Fnumber_to_string):
Use make_unibyte_string, since the string must be ASCII.
* lisp.h, print.c (float_to_string): Now returns int length.
* term.c (produce_glyphless_glyph):
Use sprintf result rather than recomputing it.
Diffstat (limited to 'src/print.c')
| -rw-r--r-- | src/print.c | 137 |
1 files changed, 79 insertions, 58 deletions
diff --git a/src/print.c b/src/print.c index a632f45bbeb..68b9c30c564 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -912,7 +912,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 912 | for (; CONSP (tail); tail = XCDR (tail), sep = ", ") | 912 | for (; CONSP (tail); tail = XCDR (tail), sep = ", ") |
| 913 | { | 913 | { |
| 914 | Lisp_Object obj; | 914 | Lisp_Object obj; |
| 915 | 915 | ||
| 916 | if (sep) | 916 | if (sep) |
| 917 | write_string_1 (sep, 2, stream); | 917 | write_string_1 (sep, 2, stream); |
| 918 | obj = XCAR (tail); | 918 | obj = XCAR (tail); |
| @@ -944,43 +944,49 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 944 | * Given the above, the buffer must be least FLOAT_TO_STRING_BUFSIZE bytes. | 944 | * Given the above, the buffer must be least FLOAT_TO_STRING_BUFSIZE bytes. |
| 945 | */ | 945 | */ |
| 946 | 946 | ||
| 947 | void | 947 | int |
| 948 | float_to_string (char *buf, double data) | 948 | float_to_string (char *buf, double data) |
| 949 | { | 949 | { |
| 950 | char *cp; | 950 | char *cp; |
| 951 | int width; | 951 | int width; |
| 952 | int len; | ||
| 952 | 953 | ||
| 953 | /* Check for plus infinity in a way that won't lose | 954 | /* Check for plus infinity in a way that won't lose |
| 954 | if there is no plus infinity. */ | 955 | if there is no plus infinity. */ |
| 955 | if (data == data / 2 && data > 1.0) | 956 | if (data == data / 2 && data > 1.0) |
| 956 | { | 957 | { |
| 957 | strcpy (buf, "1.0e+INF"); | 958 | static char const infinity_string[] = "1.0e+INF"; |
| 958 | return; | 959 | strcpy (buf, infinity_string); |
| 960 | return sizeof infinity_string - 1; | ||
| 959 | } | 961 | } |
| 960 | /* Likewise for minus infinity. */ | 962 | /* Likewise for minus infinity. */ |
| 961 | if (data == data / 2 && data < -1.0) | 963 | if (data == data / 2 && data < -1.0) |
| 962 | { | 964 | { |
| 963 | strcpy (buf, "-1.0e+INF"); | 965 | static char const minus_infinity_string[] = "-1.0e+INF"; |
| 964 | return; | 966 | strcpy (buf, minus_infinity_string); |
| 967 | return sizeof minus_infinity_string - 1; | ||
| 965 | } | 968 | } |
| 966 | /* Check for NaN in a way that won't fail if there are no NaNs. */ | 969 | /* Check for NaN in a way that won't fail if there are no NaNs. */ |
| 967 | if (! (data * 0.0 >= 0.0)) | 970 | if (! (data * 0.0 >= 0.0)) |
| 968 | { | 971 | { |
| 969 | /* Prepend "-" if the NaN's sign bit is negative. | 972 | /* Prepend "-" if the NaN's sign bit is negative. |
| 970 | The sign bit of a double is the bit that is 1 in -0.0. */ | 973 | The sign bit of a double is the bit that is 1 in -0.0. */ |
| 974 | static char const NaN_string[] = "0.0e+NaN"; | ||
| 971 | int i; | 975 | int i; |
| 972 | union { double d; char c[sizeof (double)]; } u_data, u_minus_zero; | 976 | union { double d; char c[sizeof (double)]; } u_data, u_minus_zero; |
| 977 | int negative = 0; | ||
| 973 | u_data.d = data; | 978 | u_data.d = data; |
| 974 | u_minus_zero.d = - 0.0; | 979 | u_minus_zero.d = - 0.0; |
| 975 | for (i = 0; i < sizeof (double); i++) | 980 | for (i = 0; i < sizeof (double); i++) |
| 976 | if (u_data.c[i] & u_minus_zero.c[i]) | 981 | if (u_data.c[i] & u_minus_zero.c[i]) |
| 977 | { | 982 | { |
| 978 | *buf++ = '-'; | 983 | *buf = '-'; |
| 984 | negative = 1; | ||
| 979 | break; | 985 | break; |
| 980 | } | 986 | } |
| 981 | 987 | ||
| 982 | strcpy (buf, "0.0e+NaN"); | 988 | strcpy (buf + negative, NaN_string); |
| 983 | return; | 989 | return negative + sizeof NaN_string - 1; |
| 984 | } | 990 | } |
| 985 | 991 | ||
| 986 | if (NILP (Vfloat_output_format) | 992 | if (NILP (Vfloat_output_format) |
| @@ -989,7 +995,7 @@ float_to_string (char *buf, double data) | |||
| 989 | { | 995 | { |
| 990 | /* Generate the fewest number of digits that represent the | 996 | /* Generate the fewest number of digits that represent the |
| 991 | floating point value without losing information. */ | 997 | floating point value without losing information. */ |
| 992 | dtoastr (buf, FLOAT_TO_STRING_BUFSIZE - 2, 0, 0, data); | 998 | len = dtoastr (buf, FLOAT_TO_STRING_BUFSIZE - 2, 0, 0, data); |
| 993 | /* The decimal point must be printed, or the byte compiler can | 999 | /* The decimal point must be printed, or the byte compiler can |
| 994 | get confused (Bug#8033). */ | 1000 | get confused (Bug#8033). */ |
| 995 | width = 1; | 1001 | width = 1; |
| @@ -1032,7 +1038,7 @@ float_to_string (char *buf, double data) | |||
| 1032 | if (cp[1] != 0) | 1038 | if (cp[1] != 0) |
| 1033 | goto lose; | 1039 | goto lose; |
| 1034 | 1040 | ||
| 1035 | sprintf (buf, SSDATA (Vfloat_output_format), data); | 1041 | len = sprintf (buf, SSDATA (Vfloat_output_format), data); |
| 1036 | } | 1042 | } |
| 1037 | 1043 | ||
| 1038 | /* Make sure there is a decimal point with digit after, or an | 1044 | /* Make sure there is a decimal point with digit after, or an |
| @@ -1049,14 +1055,18 @@ float_to_string (char *buf, double data) | |||
| 1049 | { | 1055 | { |
| 1050 | cp[1] = '0'; | 1056 | cp[1] = '0'; |
| 1051 | cp[2] = 0; | 1057 | cp[2] = 0; |
| 1058 | len++; | ||
| 1052 | } | 1059 | } |
| 1053 | else if (*cp == 0) | 1060 | else if (*cp == 0) |
| 1054 | { | 1061 | { |
| 1055 | *cp++ = '.'; | 1062 | *cp++ = '.'; |
| 1056 | *cp++ = '0'; | 1063 | *cp++ = '0'; |
| 1057 | *cp++ = 0; | 1064 | *cp++ = 0; |
| 1065 | len += 2; | ||
| 1058 | } | 1066 | } |
| 1059 | } | 1067 | } |
| 1068 | |||
| 1069 | return len; | ||
| 1060 | } | 1070 | } |
| 1061 | 1071 | ||
| 1062 | 1072 | ||
| @@ -1332,8 +1342,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1332 | for (i = 0; i < print_depth; i++) | 1342 | for (i = 0; i < print_depth; i++) |
| 1333 | if (EQ (obj, being_printed[i])) | 1343 | if (EQ (obj, being_printed[i])) |
| 1334 | { | 1344 | { |
| 1335 | sprintf (buf, "#%d", i); | 1345 | int len = sprintf (buf, "#%d", i); |
| 1336 | strout (buf, -1, -1, printcharfun); | 1346 | strout (buf, len, len, printcharfun); |
| 1337 | return; | 1347 | return; |
| 1338 | } | 1348 | } |
| 1339 | being_printed[print_depth] = obj; | 1349 | being_printed[print_depth] = obj; |
| @@ -1348,16 +1358,16 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1348 | if (n < 0) | 1358 | if (n < 0) |
| 1349 | { /* Add a prefix #n= if OBJ has not yet been printed; | 1359 | { /* Add a prefix #n= if OBJ has not yet been printed; |
| 1350 | that is, its status field is nil. */ | 1360 | that is, its status field is nil. */ |
| 1351 | sprintf (buf, "#%"pI"d=", -n); | 1361 | int len = sprintf (buf, "#%"pI"d=", -n); |
| 1352 | strout (buf, -1, -1, printcharfun); | 1362 | strout (buf, len, len, printcharfun); |
| 1353 | /* OBJ is going to be printed. Remember that fact. */ | 1363 | /* OBJ is going to be printed. Remember that fact. */ |
| 1354 | Fputhash (obj, make_number (- n), Vprint_number_table); | 1364 | Fputhash (obj, make_number (- n), Vprint_number_table); |
| 1355 | } | 1365 | } |
| 1356 | else | 1366 | else |
| 1357 | { | 1367 | { |
| 1358 | /* Just print #n# if OBJ has already been printed. */ | 1368 | /* Just print #n# if OBJ has already been printed. */ |
| 1359 | sprintf (buf, "#%"pI"d#", n); | 1369 | int len = sprintf (buf, "#%"pI"d#", n); |
| 1360 | strout (buf, -1, -1, printcharfun); | 1370 | strout (buf, len, len, printcharfun); |
| 1361 | return; | 1371 | return; |
| 1362 | } | 1372 | } |
| 1363 | } | 1373 | } |
| @@ -1368,16 +1378,17 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1368 | switch (XTYPE (obj)) | 1378 | switch (XTYPE (obj)) |
| 1369 | { | 1379 | { |
| 1370 | case_Lisp_Int: | 1380 | case_Lisp_Int: |
| 1371 | sprintf (buf, "%"pI"d", XINT (obj)); | 1381 | { |
| 1372 | strout (buf, -1, -1, printcharfun); | 1382 | int len = sprintf (buf, "%"pI"d", XINT (obj)); |
| 1383 | strout (buf, len, len, printcharfun); | ||
| 1384 | } | ||
| 1373 | break; | 1385 | break; |
| 1374 | 1386 | ||
| 1375 | case Lisp_Float: | 1387 | case Lisp_Float: |
| 1376 | { | 1388 | { |
| 1377 | char pigbuf[FLOAT_TO_STRING_BUFSIZE]; | 1389 | char pigbuf[FLOAT_TO_STRING_BUFSIZE]; |
| 1378 | 1390 | int len = float_to_string (pigbuf, XFLOAT_DATA (obj)); | |
| 1379 | float_to_string (pigbuf, XFLOAT_DATA (obj)); | 1391 | strout (pigbuf, len, len, printcharfun); |
| 1380 | strout (pigbuf, -1, -1, printcharfun); | ||
| 1381 | } | 1392 | } |
| 1382 | break; | 1393 | break; |
| 1383 | 1394 | ||
| @@ -1447,15 +1458,16 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1447 | when found in a multibyte string, always use a hex escape | 1458 | when found in a multibyte string, always use a hex escape |
| 1448 | so it reads back as multibyte. */ | 1459 | so it reads back as multibyte. */ |
| 1449 | char outbuf[50]; | 1460 | char outbuf[50]; |
| 1461 | int len; | ||
| 1450 | 1462 | ||
| 1451 | if (CHAR_BYTE8_P (c)) | 1463 | if (CHAR_BYTE8_P (c)) |
| 1452 | sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c)); | 1464 | len = sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c)); |
| 1453 | else | 1465 | else |
| 1454 | { | 1466 | { |
| 1455 | sprintf (outbuf, "\\x%04x", c); | 1467 | len = sprintf (outbuf, "\\x%04x", c); |
| 1456 | need_nonhex = 1; | 1468 | need_nonhex = 1; |
| 1457 | } | 1469 | } |
| 1458 | strout (outbuf, -1, -1, printcharfun); | 1470 | strout (outbuf, len, len, printcharfun); |
| 1459 | } | 1471 | } |
| 1460 | else if (! multibyte | 1472 | else if (! multibyte |
| 1461 | && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) | 1473 | && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) |
| @@ -1466,8 +1478,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1466 | print single-byte non-ASCII string chars | 1478 | print single-byte non-ASCII string chars |
| 1467 | using octal escapes. */ | 1479 | using octal escapes. */ |
| 1468 | char outbuf[5]; | 1480 | char outbuf[5]; |
| 1469 | sprintf (outbuf, "\\%03o", c); | 1481 | int len = sprintf (outbuf, "\\%03o", c); |
| 1470 | strout (outbuf, -1, -1, printcharfun); | 1482 | strout (outbuf, len, len, printcharfun); |
| 1471 | } | 1483 | } |
| 1472 | else | 1484 | else |
| 1473 | { | 1485 | { |
| @@ -1632,8 +1644,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1632 | /* Simple but incomplete way. */ | 1644 | /* Simple but incomplete way. */ |
| 1633 | if (i != 0 && EQ (obj, halftail)) | 1645 | if (i != 0 && EQ (obj, halftail)) |
| 1634 | { | 1646 | { |
| 1635 | sprintf (buf, " . #%"pMd, i / 2); | 1647 | int len = sprintf (buf, " . #%"pMd, i / 2); |
| 1636 | strout (buf, -1, -1, printcharfun); | 1648 | strout (buf, len, len, printcharfun); |
| 1637 | goto end_of_list; | 1649 | goto end_of_list; |
| 1638 | } | 1650 | } |
| 1639 | } | 1651 | } |
| @@ -1697,7 +1709,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1697 | else if (BOOL_VECTOR_P (obj)) | 1709 | else if (BOOL_VECTOR_P (obj)) |
| 1698 | { | 1710 | { |
| 1699 | ptrdiff_t i; | 1711 | ptrdiff_t i; |
| 1700 | register unsigned char c; | 1712 | int len; |
| 1713 | unsigned char c; | ||
| 1701 | struct gcpro gcpro1; | 1714 | struct gcpro gcpro1; |
| 1702 | ptrdiff_t size_in_chars | 1715 | ptrdiff_t size_in_chars |
| 1703 | = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) | 1716 | = ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) |
| @@ -1707,8 +1720,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1707 | 1720 | ||
| 1708 | PRINTCHAR ('#'); | 1721 | PRINTCHAR ('#'); |
| 1709 | PRINTCHAR ('&'); | 1722 | PRINTCHAR ('&'); |
| 1710 | sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size); | 1723 | len = sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size); |
| 1711 | strout (buf, -1, -1, printcharfun); | 1724 | strout (buf, len, len, printcharfun); |
| 1712 | PRINTCHAR ('\"'); | 1725 | PRINTCHAR ('\"'); |
| 1713 | 1726 | ||
| 1714 | /* Don't print more characters than the specified maximum. | 1727 | /* Don't print more characters than the specified maximum. |
| @@ -1759,9 +1772,11 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1759 | } | 1772 | } |
| 1760 | else if (WINDOWP (obj)) | 1773 | else if (WINDOWP (obj)) |
| 1761 | { | 1774 | { |
| 1775 | int len; | ||
| 1762 | strout ("#<window ", -1, -1, printcharfun); | 1776 | strout ("#<window ", -1, -1, printcharfun); |
| 1763 | sprintf (buf, "%"pI"d", XFASTINT (XWINDOW (obj)->sequence_number)); | 1777 | len = sprintf (buf, "%"pI"d", |
| 1764 | strout (buf, -1, -1, printcharfun); | 1778 | XFASTINT (XWINDOW (obj)->sequence_number)); |
| 1779 | strout (buf, len, len, printcharfun); | ||
| 1765 | if (!NILP (XWINDOW (obj)->buffer)) | 1780 | if (!NILP (XWINDOW (obj)->buffer)) |
| 1766 | { | 1781 | { |
| 1767 | strout (" on ", -1, -1, printcharfun); | 1782 | strout (" on ", -1, -1, printcharfun); |
| @@ -1771,10 +1786,11 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1771 | } | 1786 | } |
| 1772 | else if (TERMINALP (obj)) | 1787 | else if (TERMINALP (obj)) |
| 1773 | { | 1788 | { |
| 1789 | int len; | ||
| 1774 | struct terminal *t = XTERMINAL (obj); | 1790 | struct terminal *t = XTERMINAL (obj); |
| 1775 | strout ("#<terminal ", -1, -1, printcharfun); | 1791 | strout ("#<terminal ", -1, -1, printcharfun); |
| 1776 | sprintf (buf, "%d", t->id); | 1792 | len = sprintf (buf, "%d", t->id); |
| 1777 | strout (buf, -1, -1, printcharfun); | 1793 | strout (buf, len, len, printcharfun); |
| 1778 | if (t->name) | 1794 | if (t->name) |
| 1779 | { | 1795 | { |
| 1780 | strout (" on ", -1, -1, printcharfun); | 1796 | strout (" on ", -1, -1, printcharfun); |
| @@ -1787,6 +1803,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1787 | struct Lisp_Hash_Table *h = XHASH_TABLE (obj); | 1803 | struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
| 1788 | ptrdiff_t i; | 1804 | ptrdiff_t i; |
| 1789 | ptrdiff_t real_size, size; | 1805 | ptrdiff_t real_size, size; |
| 1806 | int len; | ||
| 1790 | #if 0 | 1807 | #if 0 |
| 1791 | strout ("#<hash-table", -1, -1, printcharfun); | 1808 | strout ("#<hash-table", -1, -1, printcharfun); |
| 1792 | if (SYMBOLP (h->test)) | 1809 | if (SYMBOLP (h->test)) |
| @@ -1797,18 +1814,18 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1797 | PRINTCHAR (' '); | 1814 | PRINTCHAR (' '); |
| 1798 | strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun); | 1815 | strout (SDATA (SYMBOL_NAME (h->weak)), -1, -1, printcharfun); |
| 1799 | PRINTCHAR (' '); | 1816 | PRINTCHAR (' '); |
| 1800 | sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next)); | 1817 | len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next)); |
| 1801 | strout (buf, -1, -1, printcharfun); | 1818 | strout (buf, len, len, printcharfun); |
| 1802 | } | 1819 | } |
| 1803 | sprintf (buf, " %p", h); | 1820 | len = sprintf (buf, " %p", h); |
| 1804 | strout (buf, -1, -1, printcharfun); | 1821 | strout (buf, len, len, printcharfun); |
| 1805 | PRINTCHAR ('>'); | 1822 | PRINTCHAR ('>'); |
| 1806 | #endif | 1823 | #endif |
| 1807 | /* Implement a readable output, e.g.: | 1824 | /* Implement a readable output, e.g.: |
| 1808 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ | 1825 | #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */ |
| 1809 | /* Always print the size. */ | 1826 | /* Always print the size. */ |
| 1810 | sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); | 1827 | len = sprintf (buf, "#s(hash-table size %"pD"d", ASIZE (h->next)); |
| 1811 | strout (buf, -1, -1, printcharfun); | 1828 | strout (buf, len, len, printcharfun); |
| 1812 | 1829 | ||
| 1813 | if (!NILP (h->test)) | 1830 | if (!NILP (h->test)) |
| 1814 | { | 1831 | { |
| @@ -1881,12 +1898,13 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1881 | } | 1898 | } |
| 1882 | else if (FRAMEP (obj)) | 1899 | else if (FRAMEP (obj)) |
| 1883 | { | 1900 | { |
| 1901 | int len; | ||
| 1884 | strout ((FRAME_LIVE_P (XFRAME (obj)) | 1902 | strout ((FRAME_LIVE_P (XFRAME (obj)) |
| 1885 | ? "#<frame " : "#<dead frame "), | 1903 | ? "#<frame " : "#<dead frame "), |
| 1886 | -1, -1, printcharfun); | 1904 | -1, -1, printcharfun); |
| 1887 | print_string (XFRAME (obj)->name, printcharfun); | 1905 | print_string (XFRAME (obj)->name, printcharfun); |
| 1888 | sprintf (buf, " %p", XFRAME (obj)); | 1906 | len = sprintf (buf, " %p", XFRAME (obj)); |
| 1889 | strout (buf, -1, -1, printcharfun); | 1907 | strout (buf, len, len, printcharfun); |
| 1890 | PRINTCHAR ('>'); | 1908 | PRINTCHAR ('>'); |
| 1891 | } | 1909 | } |
| 1892 | else if (FONTP (obj)) | 1910 | else if (FONTP (obj)) |
| @@ -1982,8 +2000,8 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1982 | strout ("in no buffer", -1, -1, printcharfun); | 2000 | strout ("in no buffer", -1, -1, printcharfun); |
| 1983 | else | 2001 | else |
| 1984 | { | 2002 | { |
| 1985 | sprintf (buf, "at %"pD"d", marker_position (obj)); | 2003 | int len = sprintf (buf, "at %"pD"d", marker_position (obj)); |
| 1986 | strout (buf, -1, -1, printcharfun); | 2004 | strout (buf, len, len, printcharfun); |
| 1987 | strout (" in ", -1, -1, printcharfun); | 2005 | strout (" in ", -1, -1, printcharfun); |
| 1988 | print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun); | 2006 | print_string (BVAR (XMARKER (obj)->buffer, name), printcharfun); |
| 1989 | } | 2007 | } |
| @@ -1996,10 +2014,10 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1996 | strout ("in no buffer", -1, -1, printcharfun); | 2014 | strout ("in no buffer", -1, -1, printcharfun); |
| 1997 | else | 2015 | else |
| 1998 | { | 2016 | { |
| 1999 | sprintf (buf, "from %"pD"d to %"pD"d in ", | 2017 | int len = sprintf (buf, "from %"pD"d to %"pD"d in ", |
| 2000 | marker_position (OVERLAY_START (obj)), | 2018 | marker_position (OVERLAY_START (obj)), |
| 2001 | marker_position (OVERLAY_END (obj))); | 2019 | marker_position (OVERLAY_END (obj))); |
| 2002 | strout (buf, -1, -1, printcharfun); | 2020 | strout (buf, len, len, printcharfun); |
| 2003 | print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name), | 2021 | print_string (BVAR (XMARKER (OVERLAY_START (obj))->buffer, name), |
| 2004 | printcharfun); | 2022 | printcharfun); |
| 2005 | } | 2023 | } |
| @@ -2014,10 +2032,12 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 2014 | 2032 | ||
| 2015 | case Lisp_Misc_Save_Value: | 2033 | case Lisp_Misc_Save_Value: |
| 2016 | strout ("#<save_value ", -1, -1, printcharfun); | 2034 | strout ("#<save_value ", -1, -1, printcharfun); |
| 2017 | sprintf (buf, "ptr=%p int=%"pD"d", | 2035 | { |
| 2018 | XSAVE_VALUE (obj)->pointer, | 2036 | int len = sprintf (buf, "ptr=%p int=%"pD"d", |
| 2019 | XSAVE_VALUE (obj)->integer); | 2037 | XSAVE_VALUE (obj)->pointer, |
| 2020 | strout (buf, -1, -1, printcharfun); | 2038 | XSAVE_VALUE (obj)->integer); |
| 2039 | strout (buf, len, len, printcharfun); | ||
| 2040 | } | ||
| 2021 | PRINTCHAR ('>'); | 2041 | PRINTCHAR ('>'); |
| 2022 | break; | 2042 | break; |
| 2023 | 2043 | ||
| @@ -2029,16 +2049,17 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 2029 | default: | 2049 | default: |
| 2030 | badtype: | 2050 | badtype: |
| 2031 | { | 2051 | { |
| 2052 | int len; | ||
| 2032 | /* We're in trouble if this happens! | 2053 | /* We're in trouble if this happens! |
| 2033 | Probably should just abort () */ | 2054 | Probably should just abort () */ |
| 2034 | strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); | 2055 | strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun); |
| 2035 | if (MISCP (obj)) | 2056 | if (MISCP (obj)) |
| 2036 | sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); | 2057 | len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); |
| 2037 | else if (VECTORLIKEP (obj)) | 2058 | else if (VECTORLIKEP (obj)) |
| 2038 | sprintf (buf, "(PVEC 0x%08"pD"x)", ASIZE (obj)); | 2059 | len = sprintf (buf, "(PVEC 0x%08"pD"x)", ASIZE (obj)); |
| 2039 | else | 2060 | else |
| 2040 | sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); | 2061 | len = sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); |
| 2041 | strout (buf, -1, -1, printcharfun); | 2062 | strout (buf, len, len, printcharfun); |
| 2042 | strout (" Save your buffers immediately and please report this bug>", | 2063 | strout (" Save your buffers immediately and please report this bug>", |
| 2043 | -1, -1, printcharfun); | 2064 | -1, -1, printcharfun); |
| 2044 | } | 2065 | } |