From 6e8e6bf2535c24b8e8127cc3768d07b528db6d87 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 9 Jan 2011 00:21:21 -0800 Subject: [PATCH] Give a name FLOAT_TO_STRING_BUFSIZE to the constant 350. * lisp.h (FLOAT_TO_STRING_BUFSIZE): New macro. * data.c (Fnumber_to_string): Use it. * print.c (float_to_string, print_object): Likewise. --- src/ChangeLog | 5 +++++ src/data.c | 2 +- src/lisp.h | 1 + src/print.c | 8 ++++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7374c4d878d..353f9c2d64a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-01-09 Paul Eggert + Give a name FLOAT_TO_STRING_BUFSIZE to the constant 350. + * lisp.h (FLOAT_TO_STRING_BUFSIZE): New macro. + * data.c (Fnumber_to_string): Use it. + * print.c (float_to_string, print_object): Likewise. + Include unilaterally. * alloc.c, atimer.c, buffer.c, callproc.c, dired.c, dispnew.c, doc.c: * doprnt.c, editfns.c, emacs.c, fileio.c, filelock.c, fns.c: diff --git a/src/data.c b/src/data.c index 8816d7201f3..31cf0fcde51 100644 --- a/src/data.c +++ b/src/data.c @@ -2375,7 +2375,7 @@ NUMBER may be an integer or a floating point number. */) if (FLOATP (number)) { - char pigbuf[350]; /* see comments in float_to_string */ + char pigbuf[FLOAT_TO_STRING_BUFSIZE]; float_to_string (pigbuf, XFLOAT_DATA (number)); return build_string (pigbuf); diff --git a/src/lisp.h b/src/lisp.h index eadbbacbff4..1f507123d83 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2781,6 +2781,7 @@ extern void print_error_message (Lisp_Object, Lisp_Object, const char *, Lisp_Object); extern Lisp_Object internal_with_output_to_temp_buffer (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); +#define FLOAT_TO_STRING_BUFSIZE 350 extern void float_to_string (unsigned char *, double); extern void syms_of_print (void); diff --git a/src/print.c b/src/print.c index 993b17b668d..961400f4726 100644 --- a/src/print.c +++ b/src/print.c @@ -1054,6 +1054,7 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, * case of -1e307 in 20d float_output_format. What is one to do (short of * re-writing _doprnt to be more sane)? * -wsr + * Given the above, the buffer must be least FLOAT_TO_STRING_BUFSIZE bytes. */ void @@ -1100,9 +1101,8 @@ float_to_string (unsigned char *buf, double data) lose: { /* Generate the fewest number of digits that represent the - floating point value without losing information. - The 350 is by convention, e.g., this file's pigbuf. */ - dtoastr (buf, 350, 0, 0, data); + floating point value without losing information. */ + dtoastr (buf, FLOAT_TO_STRING_BUFSIZE, 0, 0, data); } else /* oink oink */ { @@ -1493,7 +1493,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag case Lisp_Float: { - char pigbuf[350]; /* see comments in float_to_string */ + char pigbuf[FLOAT_TO_STRING_BUFSIZE]; float_to_string (pigbuf, XFLOAT_DATA (obj)); strout (pigbuf, -1, -1, printcharfun, 0); -- 2.39.5