# HG changeset patch # User martinb # Date 991383792 0 # Node ID 1c880911c386fac77435691aef64e9739e1e833f # Parent b9f1a2e84ead1be7ad234976bd3db231d8469211 [xemacs-hg @ 2001-06-01 08:23:09 by martinb] Fix a bunch of 128-bit bugs diff -r b9f1a2e84ead -r 1c880911c386 src/ChangeLog --- a/src/ChangeLog Fri Jun 01 08:17:05 2001 +0000 +++ b/src/ChangeLog Fri Jun 01 08:23:12 2001 +0000 @@ -1,3 +1,13 @@ +2001-06-01 Martin Buchholz + + * lisp.h (DECIMAL_PRINT_SIZE): New. + * data.c (Fnumber_to_string): Use DECIMAL_PRINT_SIZE + * print.c (print_internal): Likewise. + * redisplay.c (window_line_number): Likewise. + * redisplay.c (decode_mode_spec): Likewise. + * tooltalk.c (tt_message_arg_ival_string): Likewise. + Fix a bunch of 128-bit bugs; make code more readable && efficient. + 2001-05-30 Ben Wing * s\cygwin32.h: diff -r b9f1a2e84ead -r 1c880911c386 src/data.c --- a/src/data.c Fri Jun 01 08:17:05 2001 +0000 +++ b/src/data.c Fri Jun 01 08:23:12 2001 +0000 @@ -1013,8 +1013,6 @@ */ (number)) { - char buffer[VALBITS]; - CHECK_INT_OR_FLOAT (number); #ifdef LISP_FLOAT_TYPE @@ -1027,8 +1025,12 @@ } #endif /* LISP_FLOAT_TYPE */ - long_to_string (buffer, XINT (number)); - return build_string (buffer); + { + char buffer[DECIMAL_PRINT_SIZE (long)]; + + long_to_string (buffer, XINT (number)); + return build_string (buffer); + } } static int diff -r b9f1a2e84ead -r 1c880911c386 src/lisp.h --- a/src/lisp.h Fri Jun 01 08:17:05 2001 +0000 +++ b/src/lisp.h Fri Jun 01 08:23:12 2001 +0000 @@ -2839,7 +2839,15 @@ void print_cons (Lisp_Object, Lisp_Object, int); void print_vector (Lisp_Object, Lisp_Object, int); void print_string (Lisp_Object, Lisp_Object, int); + +/* The number of bytes required to store the decimal printed + representation of an integral type. Add a few bytes for truncation, + optional sign prefix, and null byte terminator. + 2.40824 == log (256) / log (10). */ +#define DECIMAL_PRINT_SIZE(integral_type) \ +((size_t) (2.40824 * sizeof (integral_type)) + 3) void long_to_string (char *, long); + void print_internal (Lisp_Object, Lisp_Object, int); void print_symbol (Lisp_Object, Lisp_Object, int); void print_float (Lisp_Object, Lisp_Object, int); diff -r b9f1a2e84ead -r 1c880911c386 src/print.c --- a/src/print.c Fri Jun 01 08:17:05 2001 +0000 +++ b/src/print.c Fri Jun 01 08:23:12 2001 +0000 @@ -1288,7 +1288,7 @@ for (i = 0; i < print_depth; i++) if (EQ (obj, being_printed[i])) { - char buf[32]; + char buf[DECIMAL_PRINT_SIZE (long) + 1]; *buf = '#'; long_to_string (buf + 1, i); write_c_string (buf, printcharfun); @@ -1307,9 +1307,7 @@ case Lisp_Type_Int_Even: case Lisp_Type_Int_Odd: { - /* ASCII Decimal representation uses 2.4 times as many bits as - machine binary. */ - char buf[3 * sizeof (EMACS_INT) + 5]; + char buf[DECIMAL_PRINT_SIZE (EMACS_INT)]; long_to_string (buf, XINT (obj)); write_c_string (buf, printcharfun); break; diff -r b9f1a2e84ead -r 1c880911c386 src/redisplay.c --- a/src/redisplay.c Fri Jun 01 08:17:05 2001 +0000 +++ b/src/redisplay.c Fri Jun 01 08:23:12 2001 +0000 @@ -6626,8 +6626,6 @@ } -static char window_line_number_buf[32]; - /* Efficiently determine the window line number, and return a pointer to its printed representation. Do this regardless of whether line-number-mode is on. The first line in the buffer is counted as @@ -6652,9 +6650,13 @@ line = buffer_line_number (b, pos, 1); - long_to_string (window_line_number_buf, line + 1); - - return window_line_number_buf; + { + static char window_line_number_buf[DECIMAL_PRINT_SIZE (long)]; + + long_to_string (window_line_number_buf, line + 1); + + return window_line_number_buf; + } } @@ -6698,7 +6700,7 @@ ? BUF_PT (b) : marker_position (w->pointm[type]); int col = column_at_point (b, pt, 1) + !!column_number_start_at_one; - char buf[32]; + char buf[DECIMAL_PRINT_SIZE (long)]; long_to_string (buf, col); diff -r b9f1a2e84ead -r 1c880911c386 src/tooltalk.c --- a/src/tooltalk.c Fri Jun 01 08:17:05 2001 +0000 +++ b/src/tooltalk.c Fri Jun 01 08:23:12 2001 +0000 @@ -520,7 +520,7 @@ static Lisp_Object tt_message_arg_ival_string (Tt_message m, int n) { - char buf[32]; + char buf[DECIMAL_PRINT_SIZE (long)]; int value; check_status (tt_message_arg_ival (m, n, &value));