diff options
| author | Miles Bader | 2007-12-06 09:51:45 +0000 |
|---|---|---|
| committer | Miles Bader | 2007-12-06 09:51:45 +0000 |
| commit | 0bd508417142ff377f34aec8dcec9438d9175c2c (patch) | |
| tree | 4d60fe09e5cebf7d79766b11e9cda8cc1c9dbb9b /src/editfns.c | |
| parent | 98fe991da804a42f53f6a5e84cd5eab18a82e181 (diff) | |
| parent | 9fb1ba8090da3528de56158a79bd3527d31c7f2f (diff) | |
| download | emacs-0bd508417142ff377f34aec8dcec9438d9175c2c.tar.gz emacs-0bd508417142ff377f34aec8dcec9438d9175c2c.zip | |
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/editfns.c b/src/editfns.c index 66e3883494f..fa1b229bfc4 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3673,8 +3673,10 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3673 | precision[n+1] = 10 * precision[n+1] + *format - '0'; | 3673 | precision[n+1] = 10 * precision[n+1] + *format - '0'; |
| 3674 | } | 3674 | } |
| 3675 | 3675 | ||
| 3676 | if (format - this_format_start + 1 > longest_format) | 3676 | /* Extra +1 for 'l' that we may need to insert into the |
| 3677 | longest_format = format - this_format_start + 1; | 3677 | format. */ |
| 3678 | if (format - this_format_start + 2 > longest_format) | ||
| 3679 | longest_format = format - this_format_start + 2; | ||
| 3678 | 3680 | ||
| 3679 | if (format == end) | 3681 | if (format == end) |
| 3680 | error ("Format string ends in middle of format specifier"); | 3682 | error ("Format string ends in middle of format specifier"); |
| @@ -3735,7 +3737,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3735 | && *format != 'i' && *format != 'X' && *format != 'c') | 3737 | && *format != 'i' && *format != 'X' && *format != 'c') |
| 3736 | error ("Invalid format operation %%%c", *format); | 3738 | error ("Invalid format operation %%%c", *format); |
| 3737 | 3739 | ||
| 3738 | thissize = 30; | 3740 | thissize = 30 + (precision[n] > 0 ? precision[n] : 0); |
| 3739 | if (*format == 'c') | 3741 | if (*format == 'c') |
| 3740 | { | 3742 | { |
| 3741 | if (! ASCII_CHAR_P (XINT (args[n])) | 3743 | if (! ASCII_CHAR_P (XINT (args[n])) |
| @@ -3933,23 +3935,40 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3933 | format - this_format_start); | 3935 | format - this_format_start); |
| 3934 | this_format[format - this_format_start] = 0; | 3936 | this_format[format - this_format_start] = 0; |
| 3935 | 3937 | ||
| 3936 | if (INTEGERP (args[n])) | 3938 | if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') |
| 3939 | sprintf (p, this_format, XFLOAT_DATA (args[n])); | ||
| 3940 | else | ||
| 3937 | { | 3941 | { |
| 3938 | if (format[-1] == 'd') | 3942 | if (sizeof (EMACS_INT) > sizeof (int) |
| 3939 | sprintf (p, this_format, XINT (args[n])); | 3943 | && format[-1] != 'c') |
| 3940 | /* Don't sign-extend for octal or hex printing. */ | 3944 | { |
| 3945 | /* Insert 'l' before format spec. */ | ||
| 3946 | this_format[format - this_format_start] | ||
| 3947 | = this_format[format - this_format_start - 1]; | ||
| 3948 | this_format[format - this_format_start - 1] = 'l'; | ||
| 3949 | this_format[format - this_format_start + 1] = 0; | ||
| 3950 | } | ||
| 3951 | |||
| 3952 | if (INTEGERP (args[n])) | ||
| 3953 | { | ||
| 3954 | if (format[-1] == 'c') | ||
| 3955 | sprintf (p, this_format, (int) XINT (args[n])); | ||
| 3956 | else if (format[-1] == 'd') | ||
| 3957 | sprintf (p, this_format, XINT (args[n])); | ||
| 3958 | /* Don't sign-extend for octal or hex printing. */ | ||
| 3959 | else | ||
| 3960 | sprintf (p, this_format, XUINT (args[n])); | ||
| 3961 | } | ||
| 3962 | else if (format[-1] == 'c') | ||
| 3963 | sprintf (p, this_format, (int) XFLOAT_DATA (args[n])); | ||
| 3964 | else if (format[-1] == 'd') | ||
| 3965 | /* Maybe we should use "%1.0f" instead so it also works | ||
| 3966 | for values larger than MAXINT. */ | ||
| 3967 | sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); | ||
| 3941 | else | 3968 | else |
| 3942 | sprintf (p, this_format, XUINT (args[n])); | 3969 | /* Don't sign-extend for octal or hex printing. */ |
| 3970 | sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); | ||
| 3943 | } | 3971 | } |
| 3944 | else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') | ||
| 3945 | sprintf (p, this_format, XFLOAT_DATA (args[n])); | ||
| 3946 | else if (format[-1] == 'd') | ||
| 3947 | /* Maybe we should use "%1.0f" instead so it also works | ||
| 3948 | for values larger than MAXINT. */ | ||
| 3949 | sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); | ||
| 3950 | else | ||
| 3951 | /* Don't sign-extend for octal or hex printing. */ | ||
| 3952 | sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); | ||
| 3953 | 3972 | ||
| 3954 | if (p > buf | 3973 | if (p > buf |
| 3955 | && multibyte | 3974 | && multibyte |