# HG changeset patch # User aidan # Date 1196171470 0 # Node ID 89e64783d0682b00e03ec2612d4de6967eacef15 # Parent 691b934b7b834b3364695dbc1ca6155fbb51e78e [xemacs-hg @ 2007-11-27 13:51:03 by aidan] Merge a bugfix to some previously merged SXEmacs code; thank you Sebastian Freundt for the code, and Hans de Graaff for the report. diff -r 691b934b7b83 -r 89e64783d068 src/ChangeLog --- a/src/ChangeLog Mon Nov 26 22:51:07 2007 +0000 +++ b/src/ChangeLog Tue Nov 27 13:51:10 2007 +0000 @@ -1,3 +1,12 @@ +2007-11-26 Aidan Kehoe + + * doprnt.c: + Default to a buffer size of 350 for the sprintf call, but increase + it if the precision and minwidth indicate that it should be + bigger. Issue reported by Hans de Graaff; bug originally fixed by + Sebastian Freundt in SXEmacs following the change I merged on + 2006-11-28. Forks have their disadvantages. + 2007-11-11 Mats Lidell * events.h: Based on SXEmacs patch. Support for mouse button 6 to diff -r 691b934b7b83 -r 89e64783d068 src/doprnt.c --- a/src/doprnt.c Mon Nov 26 22:51:07 2007 +0000 +++ b/src/doprnt.c Tue Nov 27 13:51:10 2007 +0000 @@ -776,9 +776,21 @@ #endif /* HAVE_BIGFLOAT */ else { - Ascbyte *text_to_print = alloca_array (char, 350); + Ascbyte *text_to_print; Ascbyte constructed_spec[100]; Ascbyte *p = constructed_spec; + int alloca_sz = 350; + int min = spec->minwidth, prec = spec->precision; + + if (prec < 0) + prec = 0; + if (min < 0) + min = 0; + + if (32+min+prec > alloca_sz) + alloca_sz = 32 + min + prec; + + text_to_print = alloca_array(char, alloca_sz); /* Mostly reconstruct the spec and use sprintf() to format the string. */ diff -r 691b934b7b83 -r 89e64783d068 tests/ChangeLog --- a/tests/ChangeLog Mon Nov 26 22:51:07 2007 +0000 +++ b/tests/ChangeLog Tue Nov 27 13:51:10 2007 +0000 @@ -1,3 +1,9 @@ +2007-11-26 Aidan Kehoe + + * automated/lisp-tests.el: + Check that a couple of previously problematic calls to #'format + succeed. + 2007-09-30 Stephen J. Turnbull * automated/os-tests.el: Suppress `executable-find' lossage. diff -r 691b934b7b83 -r 89e64783d068 tests/automated/lisp-tests.el --- a/tests/automated/lisp-tests.el Mon Nov 26 22:51:07 2007 +0000 +++ b/tests/automated/lisp-tests.el Tue Nov 27 13:51:10 2007 +0000 @@ -1279,6 +1279,10 @@ (Assert (= (read (format "%d" most-negative-fixnum)) most-negative-fixnum)) (Assert (= (read (format "%ld" most-negative-fixnum)) most-negative-fixnum)) +;; These used to crash. +(Assert (eql (read (format "%f" 1.2e+302)) 1.2e+302)) +(Assert (eql (read (format "%.1000d" 1)) 1)) + ;;; "%u" is undocumented, and Emacs Lisp has no unsigned type. ;;; What to do if "%u" is used with a negative number? ;;; For non-bignum XEmacsen, the most reasonable thing seems to be to print an