Thank you Hans!
APPROVE COMMIT
NOTE: This patch has been committed.
src/ChangeLog addition:
2007-11-26  Aidan Kehoe  <kehoea(a)parhasard.net>
	* 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. 
tests/ChangeLog addition:
2007-11-26  Aidan Kehoe  <kehoea(a)parhasard.net>
	* automated/lisp-tests.el:
	Check that a couple of previously problematic calls to #'format
	succeed.
XEmacs Trunk source patch:
Diff command:   cvs -q diff -u
Files affected: tests/automated/lisp-tests.el
===================================================================
RCS src/doprnt.c
===================================================================
RCS
Index: src/doprnt.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/doprnt.c,v
retrieving revision 1.32
diff -u -r1.32 doprnt.c
--- src/doprnt.c	2006/11/28 16:09:47	1.32
+++ src/doprnt.c	2007/11/27 13:49:06
@@ -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. */
Index: tests/automated/lisp-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/lisp-tests.el,v
retrieving revision 1.7
diff -u -r1.7 lisp-tests.el
--- tests/automated/lisp-tests.el	2004/05/13 15:33:18	1.7
+++ tests/automated/lisp-tests.el	2007/11/27 13:49:06
@@ -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
-- 
¿Dónde estará ahora mi sobrino Yoghurtu Nghé, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches