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 | |
| 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')
| -rw-r--r-- | src/ChangeLog | 20 | ||||
| -rw-r--r-- | src/ccl.c | 15 | ||||
| -rw-r--r-- | src/character.c | 8 | ||||
| -rw-r--r-- | src/data.c | 15 | ||||
| -rw-r--r-- | src/doprnt.c | 24 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/print.c | 137 | ||||
| -rw-r--r-- | src/term.c | 3 | ||||
| -rw-r--r-- | src/xdisp.c | 4 | ||||
| -rw-r--r-- | src/xfns.c | 8 |
10 files changed, 131 insertions, 105 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index dec5ee328a7..5b3387b8134 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,25 @@ | |||
| 1 | 2012-06-26 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-06-26 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Use sprintf return value instead of invoking strlen on result. | ||
| 4 | In the old days this wasn't portable, since some sprintf | ||
| 5 | implementations returned char *. But they died out years ago and | ||
| 6 | Emacs already assumes sprintf returns int. | ||
| 7 | Similarly for float_to_string. | ||
| 8 | This patch speeds up (number-to-string 1000) by 3% on Fedora 15 x86-64. | ||
| 9 | * ccl.c (ccl_driver): | ||
| 10 | * character.c (string_escape_byte8): | ||
| 11 | * data.c (Fnumber_to_string): | ||
| 12 | * doprnt.c (doprnt): | ||
| 13 | * print.c (print_object): | ||
| 14 | * xdisp.c (message_dolog): | ||
| 15 | * xfns.c (syms_of_xfns): | ||
| 16 | Use sprintf or float_to_string result to avoid need to call strlen. | ||
| 17 | * data.c (Fnumber_to_string): | ||
| 18 | Use make_unibyte_string, since the string must be ASCII. | ||
| 19 | * lisp.h, print.c (float_to_string): Now returns int length. | ||
| 20 | * term.c (produce_glyphless_glyph): | ||
| 21 | Use sprintf result rather than recomputing it. | ||
| 22 | |||
| 3 | Clean out last vestiges of the old HAVE_CONFIG_H stuff. | 23 | Clean out last vestiges of the old HAVE_CONFIG_H stuff. |
| 4 | * Makefile.in (ALL_CFLAGS): | 24 | * Makefile.in (ALL_CFLAGS): |
| 5 | * makefile.w32-in (LOCAL_FLAGS): Remove -DHAVE_CONFIG_H. | 25 | * makefile.w32-in (LOCAL_FLAGS): Remove -DHAVE_CONFIG_H. |
| @@ -1729,14 +1729,14 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size | |||
| 1729 | switch (ccl->status) | 1729 | switch (ccl->status) |
| 1730 | { | 1730 | { |
| 1731 | case CCL_STAT_INVALID_CMD: | 1731 | case CCL_STAT_INVALID_CMD: |
| 1732 | sprintf (msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.", | 1732 | msglen = sprintf (msg, |
| 1733 | code & 0x1F, code, this_ic); | 1733 | "\nCCL: Invalid command %x (ccl_code = %x) at %d.", |
| 1734 | code & 0x1F, code, this_ic); | ||
| 1734 | #ifdef CCL_DEBUG | 1735 | #ifdef CCL_DEBUG |
| 1735 | { | 1736 | { |
| 1736 | int i = ccl_backtrace_idx - 1; | 1737 | int i = ccl_backtrace_idx - 1; |
| 1737 | int j; | 1738 | int j; |
| 1738 | 1739 | ||
| 1739 | msglen = strlen (msg); | ||
| 1740 | if (dst + msglen <= (dst_bytes ? dst_end : src)) | 1740 | if (dst + msglen <= (dst_bytes ? dst_end : src)) |
| 1741 | { | 1741 | { |
| 1742 | memcpy (dst, msg, msglen); | 1742 | memcpy (dst, msg, msglen); |
| @@ -1748,8 +1748,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size | |||
| 1748 | if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1; | 1748 | if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1; |
| 1749 | if (ccl_backtrace_table[i] == 0) | 1749 | if (ccl_backtrace_table[i] == 0) |
| 1750 | break; | 1750 | break; |
| 1751 | sprintf (msg, " %d", ccl_backtrace_table[i]); | 1751 | msglen = sprintf (msg, " %d", ccl_backtrace_table[i]); |
| 1752 | msglen = strlen (msg); | ||
| 1753 | if (dst + msglen > (dst_bytes ? dst_end : src)) | 1752 | if (dst + msglen > (dst_bytes ? dst_end : src)) |
| 1754 | break; | 1753 | break; |
| 1755 | memcpy (dst, msg, msglen); | 1754 | memcpy (dst, msg, msglen); |
| @@ -1761,15 +1760,13 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size | |||
| 1761 | break; | 1760 | break; |
| 1762 | 1761 | ||
| 1763 | case CCL_STAT_QUIT: | 1762 | case CCL_STAT_QUIT: |
| 1764 | if (! ccl->quit_silently) | 1763 | msglen = ccl->quit_silently ? 0 : sprintf (msg, "\nCCL: Quitted."); |
| 1765 | sprintf (msg, "\nCCL: Quitted."); | ||
| 1766 | break; | 1764 | break; |
| 1767 | 1765 | ||
| 1768 | default: | 1766 | default: |
| 1769 | sprintf (msg, "\nCCL: Unknown error type (%d)", ccl->status); | 1767 | msglen = sprintf (msg, "\nCCL: Unknown error type (%d)", ccl->status); |
| 1770 | } | 1768 | } |
| 1771 | 1769 | ||
| 1772 | msglen = strlen (msg); | ||
| 1773 | if (msglen <= dst_end - dst) | 1770 | if (msglen <= dst_end - dst) |
| 1774 | { | 1771 | { |
| 1775 | for (i = 0; i < msglen; i++) | 1772 | for (i = 0; i < msglen; i++) |
diff --git a/src/character.c b/src/character.c index fbd23409d08..da182488033 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -867,8 +867,7 @@ string_escape_byte8 (Lisp_Object string) | |||
| 867 | { | 867 | { |
| 868 | c = STRING_CHAR_ADVANCE (src); | 868 | c = STRING_CHAR_ADVANCE (src); |
| 869 | c = CHAR_TO_BYTE8 (c); | 869 | c = CHAR_TO_BYTE8 (c); |
| 870 | sprintf ((char *) dst, "\\%03o", c); | 870 | dst += sprintf ((char *) dst, "\\%03o", c); |
| 871 | dst += 4; | ||
| 872 | } | 871 | } |
| 873 | else | 872 | else |
| 874 | while (len--) *dst++ = *src++; | 873 | while (len--) *dst++ = *src++; |
| @@ -878,10 +877,7 @@ string_escape_byte8 (Lisp_Object string) | |||
| 878 | { | 877 | { |
| 879 | c = *src++; | 878 | c = *src++; |
| 880 | if (c >= 0x80) | 879 | if (c >= 0x80) |
| 881 | { | 880 | dst += sprintf ((char *) dst, "\\%03o", c); |
| 882 | sprintf ((char *) dst, "\\%03o", c); | ||
| 883 | dst += 4; | ||
| 884 | } | ||
| 885 | else | 881 | else |
| 886 | *dst++ = c; | 882 | *dst++ = c; |
| 887 | } | 883 | } |
diff --git a/src/data.c b/src/data.c index cd4b14a9f9d..bd757cfdad1 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -2449,20 +2449,17 @@ Uses a minus sign if negative. | |||
| 2449 | NUMBER may be an integer or a floating point number. */) | 2449 | NUMBER may be an integer or a floating point number. */) |
| 2450 | (Lisp_Object number) | 2450 | (Lisp_Object number) |
| 2451 | { | 2451 | { |
| 2452 | char buffer[VALBITS]; | 2452 | char buffer[max (FLOAT_TO_STRING_BUFSIZE, INT_BUFSIZE_BOUND (EMACS_INT))]; |
| 2453 | int len; | ||
| 2453 | 2454 | ||
| 2454 | CHECK_NUMBER_OR_FLOAT (number); | 2455 | CHECK_NUMBER_OR_FLOAT (number); |
| 2455 | 2456 | ||
| 2456 | if (FLOATP (number)) | 2457 | if (FLOATP (number)) |
| 2457 | { | 2458 | len = float_to_string (buffer, XFLOAT_DATA (number)); |
| 2458 | char pigbuf[FLOAT_TO_STRING_BUFSIZE]; | 2459 | else |
| 2459 | 2460 | len = sprintf (buffer, "%"pI"d", XINT (number)); | |
| 2460 | float_to_string (pigbuf, XFLOAT_DATA (number)); | ||
| 2461 | return build_string (pigbuf); | ||
| 2462 | } | ||
| 2463 | 2461 | ||
| 2464 | sprintf (buffer, "%"pI"d", XINT (number)); | 2462 | return make_unibyte_string (buffer, len); |
| 2465 | return build_string (buffer); | ||
| 2466 | } | 2463 | } |
| 2467 | 2464 | ||
| 2468 | DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0, | 2465 | DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0, |
diff --git a/src/doprnt.c b/src/doprnt.c index b106ffb1938..07bbcff7081 100644 --- a/src/doprnt.c +++ b/src/doprnt.c | |||
| @@ -275,32 +275,32 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 275 | case no_modifier: | 275 | case no_modifier: |
| 276 | { | 276 | { |
| 277 | int v = va_arg (ap, int); | 277 | int v = va_arg (ap, int); |
| 278 | sprintf (sprintf_buffer, fmtcpy, v); | 278 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 279 | } | 279 | } |
| 280 | break; | 280 | break; |
| 281 | case long_modifier: | 281 | case long_modifier: |
| 282 | { | 282 | { |
| 283 | long v = va_arg (ap, long); | 283 | long v = va_arg (ap, long); |
| 284 | sprintf (sprintf_buffer, fmtcpy, v); | 284 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 285 | } | 285 | } |
| 286 | break; | 286 | break; |
| 287 | case pD_modifier: | 287 | case pD_modifier: |
| 288 | signed_pD_modifier: | 288 | signed_pD_modifier: |
| 289 | { | 289 | { |
| 290 | ptrdiff_t v = va_arg (ap, ptrdiff_t); | 290 | ptrdiff_t v = va_arg (ap, ptrdiff_t); |
| 291 | sprintf (sprintf_buffer, fmtcpy, v); | 291 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 292 | } | 292 | } |
| 293 | break; | 293 | break; |
| 294 | case pI_modifier: | 294 | case pI_modifier: |
| 295 | { | 295 | { |
| 296 | EMACS_INT v = va_arg (ap, EMACS_INT); | 296 | EMACS_INT v = va_arg (ap, EMACS_INT); |
| 297 | sprintf (sprintf_buffer, fmtcpy, v); | 297 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 298 | } | 298 | } |
| 299 | break; | 299 | break; |
| 300 | case pM_modifier: | 300 | case pM_modifier: |
| 301 | { | 301 | { |
| 302 | intmax_t v = va_arg (ap, intmax_t); | 302 | intmax_t v = va_arg (ap, intmax_t); |
| 303 | sprintf (sprintf_buffer, fmtcpy, v); | 303 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 304 | } | 304 | } |
| 305 | break; | 305 | break; |
| 306 | } | 306 | } |
| @@ -315,13 +315,13 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 315 | case no_modifier: | 315 | case no_modifier: |
| 316 | { | 316 | { |
| 317 | unsigned v = va_arg (ap, unsigned); | 317 | unsigned v = va_arg (ap, unsigned); |
| 318 | sprintf (sprintf_buffer, fmtcpy, v); | 318 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 319 | } | 319 | } |
| 320 | break; | 320 | break; |
| 321 | case long_modifier: | 321 | case long_modifier: |
| 322 | { | 322 | { |
| 323 | unsigned long v = va_arg (ap, unsigned long); | 323 | unsigned long v = va_arg (ap, unsigned long); |
| 324 | sprintf (sprintf_buffer, fmtcpy, v); | 324 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 325 | } | 325 | } |
| 326 | break; | 326 | break; |
| 327 | case pD_modifier: | 327 | case pD_modifier: |
| @@ -329,13 +329,13 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 329 | case pI_modifier: | 329 | case pI_modifier: |
| 330 | { | 330 | { |
| 331 | EMACS_UINT v = va_arg (ap, EMACS_UINT); | 331 | EMACS_UINT v = va_arg (ap, EMACS_UINT); |
| 332 | sprintf (sprintf_buffer, fmtcpy, v); | 332 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 333 | } | 333 | } |
| 334 | break; | 334 | break; |
| 335 | case pM_modifier: | 335 | case pM_modifier: |
| 336 | { | 336 | { |
| 337 | uintmax_t v = va_arg (ap, uintmax_t); | 337 | uintmax_t v = va_arg (ap, uintmax_t); |
| 338 | sprintf (sprintf_buffer, fmtcpy, v); | 338 | tem = sprintf (sprintf_buffer, fmtcpy, v); |
| 339 | } | 339 | } |
| 340 | break; | 340 | break; |
| 341 | } | 341 | } |
| @@ -348,7 +348,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 348 | case 'g': | 348 | case 'g': |
| 349 | { | 349 | { |
| 350 | double d = va_arg (ap, double); | 350 | double d = va_arg (ap, double); |
| 351 | sprintf (sprintf_buffer, fmtcpy, d); | 351 | tem = sprintf (sprintf_buffer, fmtcpy, d); |
| 352 | /* Now copy into final output, truncating as necessary. */ | 352 | /* Now copy into final output, truncating as necessary. */ |
| 353 | string = sprintf_buffer; | 353 | string = sprintf_buffer; |
| 354 | goto doit; | 354 | goto doit; |
| @@ -369,7 +369,6 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 369 | /* Copy string into final output, truncating if no room. */ | 369 | /* Copy string into final output, truncating if no room. */ |
| 370 | doit: | 370 | doit: |
| 371 | /* Coming here means STRING contains ASCII only. */ | 371 | /* Coming here means STRING contains ASCII only. */ |
| 372 | tem = strlen (string); | ||
| 373 | if (STRING_BYTES_BOUND < tem) | 372 | if (STRING_BYTES_BOUND < tem) |
| 374 | error ("Format width or precision too large"); | 373 | error ("Format width or precision too large"); |
| 375 | width = tem; | 374 | width = tem; |
| @@ -413,8 +412,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, | |||
| 413 | bufsize = 0; | 412 | bufsize = 0; |
| 414 | continue; | 413 | continue; |
| 415 | } | 414 | } |
| 416 | else | 415 | memcpy (bufptr, string, tem); |
| 417 | memcpy (bufptr, string, tem); | ||
| 418 | bufptr += tem; | 416 | bufptr += tem; |
| 419 | bufsize -= tem; | 417 | bufsize -= tem; |
| 420 | if (minlen < 0) | 418 | if (minlen < 0) |
diff --git a/src/lisp.h b/src/lisp.h index f7ec612ac5e..d6cc886bae3 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2797,7 +2797,7 @@ extern void print_error_message (Lisp_Object, Lisp_Object, const char *, | |||
| 2797 | extern Lisp_Object internal_with_output_to_temp_buffer | 2797 | extern Lisp_Object internal_with_output_to_temp_buffer |
| 2798 | (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); | 2798 | (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); |
| 2799 | #define FLOAT_TO_STRING_BUFSIZE 350 | 2799 | #define FLOAT_TO_STRING_BUFSIZE 350 |
| 2800 | extern void float_to_string (char *, double); | 2800 | extern int float_to_string (char *, double); |
| 2801 | extern void syms_of_print (void); | 2801 | extern void syms_of_print (void); |
| 2802 | 2802 | ||
| 2803 | /* Defined in doprnt.c */ | 2803 | /* Defined in doprnt.c */ |
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 | } |
diff --git a/src/term.c b/src/term.c index d58dc2ba878..98f5639fb4a 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -1851,8 +1851,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym) | |||
| 1851 | len = 1; | 1851 | len = 1; |
| 1852 | else if (len > 4) | 1852 | else if (len > 4) |
| 1853 | len = 4; | 1853 | len = 4; |
| 1854 | sprintf (buf, "[%.*s]", len, str); | 1854 | len = sprintf (buf, "[%.*s]", len, str); |
| 1855 | len += 2; | ||
| 1856 | str = buf; | 1855 | str = buf; |
| 1857 | } | 1856 | } |
| 1858 | else | 1857 | else |
diff --git a/src/xdisp.c b/src/xdisp.c index 0050d644931..23ecbb5d480 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -9365,12 +9365,10 @@ message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte) | |||
| 9365 | { | 9365 | { |
| 9366 | char dupstr[sizeof " [ times]" | 9366 | char dupstr[sizeof " [ times]" |
| 9367 | + INT_STRLEN_BOUND (printmax_t)]; | 9367 | + INT_STRLEN_BOUND (printmax_t)]; |
| 9368 | int duplen; | ||
| 9369 | 9368 | ||
| 9370 | /* If you change this format, don't forget to also | 9369 | /* If you change this format, don't forget to also |
| 9371 | change message_log_check_duplicate. */ | 9370 | change message_log_check_duplicate. */ |
| 9372 | sprintf (dupstr, " [%"pMd" times]", dups); | 9371 | int duplen = sprintf (dupstr, " [%"pMd" times]", dups); |
| 9373 | duplen = strlen (dupstr); | ||
| 9374 | TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1); | 9372 | TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1); |
| 9375 | insert_1 (dupstr, duplen, 1, 0, 1); | 9373 | insert_1 (dupstr, duplen, 1, 0, 1); |
| 9376 | } | 9374 | } |
diff --git a/src/xfns.c b/src/xfns.c index 575d9434c76..02aefe9d91a 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5956,10 +5956,10 @@ When using Gtk+ tooltips, the tooltip face is not used. */); | |||
| 5956 | DEFVAR_LISP ("gtk-version-string", Vgtk_version_string, | 5956 | DEFVAR_LISP ("gtk-version-string", Vgtk_version_string, |
| 5957 | doc: /* Version info for GTK+. */); | 5957 | doc: /* Version info for GTK+. */); |
| 5958 | { | 5958 | { |
| 5959 | char gtk_version[40]; | 5959 | char gtk_version[sizeof ".." + 3 * INT_STRLEN_BOUND (int)]; |
| 5960 | g_snprintf (gtk_version, sizeof (gtk_version), "%u.%u.%u", | 5960 | int len = sprintf (gtk_version, "%d.%d.%d", |
| 5961 | GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); | 5961 | GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); |
| 5962 | Vgtk_version_string = make_pure_string (gtk_version, strlen (gtk_version), strlen (gtk_version), 0); | 5962 | Vgtk_version_string = make_pure_string (gtk_version, len, len, 0); |
| 5963 | } | 5963 | } |
| 5964 | #endif /* USE_GTK */ | 5964 | #endif /* USE_GTK */ |
| 5965 | 5965 | ||