diff options
| author | Andreas Schwab | 2007-11-16 00:10:45 +0000 |
|---|---|---|
| committer | Andreas Schwab | 2007-11-16 00:10:45 +0000 |
| commit | 023843b23be2d285d7ccce4411bdded310c65155 (patch) | |
| tree | 34b5be58f1b4e7b5f60c2ed20a21bac6d4a50d56 /src | |
| parent | b322c2058fb39e1c3c3bd1576d43cf6e25573002 (diff) | |
| download | emacs-023843b23be2d285d7ccce4411bdded310c65155.tar.gz emacs-023843b23be2d285d7ccce4411bdded310c65155.zip | |
(Fformat): When formatting an integer as float take precision into account.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 1 | ||||
| -rw-r--r-- | src/editfns.c | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c6c2db23f12..96b0d5f5e3f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | 2007-11-15 Andreas Schwab <schwab@suse.de> | 1 | 2007-11-15 Andreas Schwab <schwab@suse.de> |
| 2 | 2 | ||
| 3 | * editfns.c (Fformat): Correctly format EMACS_INT values. | 3 | * editfns.c (Fformat): Correctly format EMACS_INT values. |
| 4 | When formatting an integer as float take precision into account. | ||
| 4 | 5 | ||
| 5 | 2007-11-15 Juanma Barranquero <lekktu@gmail.com> | 6 | 2007-11-15 Juanma Barranquero <lekktu@gmail.com> |
| 6 | 7 | ||
diff --git a/src/editfns.c b/src/editfns.c index deb95198978..c4b8aa073d3 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3596,18 +3596,23 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3596 | /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ | 3596 | /* Would get MPV otherwise, since Lisp_Int's `point' to low memory. */ |
| 3597 | else if (INTEGERP (args[n]) && *format != 's') | 3597 | else if (INTEGERP (args[n]) && *format != 's') |
| 3598 | { | 3598 | { |
| 3599 | thissize = 30; | ||
| 3600 | |||
| 3599 | /* The following loop assumes the Lisp type indicates | 3601 | /* The following loop assumes the Lisp type indicates |
| 3600 | the proper way to pass the argument. | 3602 | the proper way to pass the argument. |
| 3601 | So make sure we have a flonum if the argument should | 3603 | So make sure we have a flonum if the argument should |
| 3602 | be a double. */ | 3604 | be a double. */ |
| 3603 | if (*format == 'e' || *format == 'f' || *format == 'g') | 3605 | if (*format == 'e' || *format == 'f' || *format == 'g') |
| 3604 | args[n] = Ffloat (args[n]); | 3606 | { |
| 3607 | args[n] = Ffloat (args[n]); | ||
| 3608 | if (precision[n] > 0) | ||
| 3609 | thissize += precision[n]; | ||
| 3610 | } | ||
| 3605 | else | 3611 | else |
| 3606 | if (*format != 'd' && *format != 'o' && *format != 'x' | 3612 | if (*format != 'd' && *format != 'o' && *format != 'x' |
| 3607 | && *format != 'i' && *format != 'X' && *format != 'c') | 3613 | && *format != 'i' && *format != 'X' && *format != 'c') |
| 3608 | error ("Invalid format operation %%%c", *format); | 3614 | error ("Invalid format operation %%%c", *format); |
| 3609 | 3615 | ||
| 3610 | thissize = 30; | ||
| 3611 | if (*format == 'c') | 3616 | if (*format == 'c') |
| 3612 | { | 3617 | { |
| 3613 | if (! SINGLE_BYTE_CHAR_P (XINT (args[n])) | 3618 | if (! SINGLE_BYTE_CHAR_P (XINT (args[n])) |