aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-01-10 20:10:26 +0000
committerRichard M. Stallman1993-01-10 20:10:26 +0000
commitedb2a7079bd4b4d9583955d96b2ba69ce6eae9bb (patch)
tree3e702f230142f441aaa8fa7c8c7e81ef6b1e2e96
parent51ac6f8388096099244b3e61c9e7b88cbfcb6606 (diff)
downloademacs-edb2a7079bd4b4d9583955d96b2ba69ce6eae9bb.tar.gz
emacs-edb2a7079bd4b4d9583955d96b2ba69ce6eae9bb.zip
(float_to_string): Add `.0' at end if needed.
-rw-r--r--src/print.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/print.c b/src/print.c
index 4255460af9f..0b6139a5c78 100644
--- a/src/print.c
+++ b/src/print.c
@@ -581,11 +581,8 @@ to make it write to the debugging output.\n")
581 581
582#ifdef LISP_FLOAT_TYPE 582#ifdef LISP_FLOAT_TYPE
583 583
584void
585float_to_string (buf, data)
586 char *buf;
587/* 584/*
588 * This buffer should be at least as large as the max string size of the 585 * The buffer should be at least as large as the max string size of the
589 * largest float, printed in the biggest notation. This is undoubtably 586 * largest float, printed in the biggest notation. This is undoubtably
590 * 20d float_output_format, with the negative of the C-constant "HUGE" 587 * 20d float_output_format, with the negative of the C-constant "HUGE"
591 * from <math.h>. 588 * from <math.h>.
@@ -597,6 +594,10 @@ float_to_string (buf, data)
597 * re-writing _doprnt to be more sane)? 594 * re-writing _doprnt to be more sane)?
598 * -wsr 595 * -wsr
599 */ 596 */
597
598void
599float_to_string (buf, data)
600 char *buf;
600 double data; 601 double data;
601{ 602{
602 register unsigned char *cp, c; 603 register unsigned char *cp, c;
@@ -638,6 +639,19 @@ float_to_string (buf, data)
638 639
639 sprintf (buf, XSTRING (Vfloat_output_format)->data, data); 640 sprintf (buf, XSTRING (Vfloat_output_format)->data, data);
640 } 641 }
642
643 /* Make sure there is a decimal point or an exponent,
644 so that the value is readable as a float. */
645 for (cp = buf; *cp; cp++)
646 if (*cp < '0' || *cp > '9')
647 break;
648
649 if (*cp == 0)
650 {
651 *cp++ = '.';
652 *cp++ = '0';
653 *cp++ = 0;
654 }
641} 655}
642#endif /* LISP_FLOAT_TYPE */ 656#endif /* LISP_FLOAT_TYPE */
643 657