diff options
| author | Paul Eggert | 2017-03-02 13:48:47 -0800 |
|---|---|---|
| committer | Paul Eggert | 2017-03-02 13:50:03 -0800 |
| commit | 56aaaf9bbaf9772ea714b16aa7ed2a9693ac92e3 (patch) | |
| tree | 00d5a4ce84331590cbb4b11b532f054585922219 /src/floatfns.c | |
| parent | dacafa8c30cdae92f934512664fd2d322d91432b (diff) | |
| download | emacs-56aaaf9bbaf9772ea714b16aa7ed2a9693ac92e3.tar.gz emacs-56aaaf9bbaf9772ea714b16aa7ed2a9693ac92e3.zip | |
Restore XFLOATINT but with restricted args
Turn instances of extract_float into XFLOAT_DATA when possible,
and to a resurrected XFLOATINT when the arg is a number.
The resurrected XFLOATINT is more like XFLOAT and XINT in
that is valid only if its arg is a number. This clarifies
the ways in which floats can be extracted at the C level.
* src/editfns.c (styled_format):
* src/floatfns.c (extract_float, Fexpt):
Use XFLOATINT rather than open-coding it.
* src/fns.c (internal_equal):
* src/image.c (imagemagick_load_image):
* src/xdisp.c (resize_mini_window):
Prefer XFLOAT_DATA to extract_float on values known to be floats.
* src/frame.c (x_set_screen_gamma):
* src/frame.h (NUMVAL):
* src/image.c (x_edge_detection, compute_image_size):
* src/lread.c (read_filtered_event):
* src/window.c (Fset_window_vscroll):
* src/xdisp.c (handle_single_display_spec, try_scrolling)
(redisplay_window, calc_pixel_width_or_height, x_produce_glyphs)
(on_hot_spot_p):
Prefer XFLOATINT to extract_float on values known to be numbers.
* src/lisp.h (XFLOATINT): Bring back this function, except
it now assumes its argument is a number.
Diffstat (limited to 'src/floatfns.c')
| -rw-r--r-- | src/floatfns.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/floatfns.c b/src/floatfns.c index 737fb22091e..dda03698093 100644 --- a/src/floatfns.c +++ b/src/floatfns.c | |||
| @@ -67,10 +67,7 @@ double | |||
| 67 | extract_float (Lisp_Object num) | 67 | extract_float (Lisp_Object num) |
| 68 | { | 68 | { |
| 69 | CHECK_NUMBER_OR_FLOAT (num); | 69 | CHECK_NUMBER_OR_FLOAT (num); |
| 70 | 70 | return XFLOATINT (num); | |
| 71 | if (FLOATP (num)) | ||
| 72 | return XFLOAT_DATA (num); | ||
| 73 | return (double) XINT (num); | ||
| 74 | } | 71 | } |
| 75 | 72 | ||
| 76 | /* Trig functions. */ | 73 | /* Trig functions. */ |
| @@ -207,8 +204,6 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, | |||
| 207 | doc: /* Return the exponential ARG1 ** ARG2. */) | 204 | doc: /* Return the exponential ARG1 ** ARG2. */) |
| 208 | (Lisp_Object arg1, Lisp_Object arg2) | 205 | (Lisp_Object arg1, Lisp_Object arg2) |
| 209 | { | 206 | { |
| 210 | double f1, f2, f3; | ||
| 211 | |||
| 212 | CHECK_NUMBER_OR_FLOAT (arg1); | 207 | CHECK_NUMBER_OR_FLOAT (arg1); |
| 213 | CHECK_NUMBER_OR_FLOAT (arg2); | 208 | CHECK_NUMBER_OR_FLOAT (arg2); |
| 214 | if (INTEGERP (arg1) /* common lisp spec */ | 209 | if (INTEGERP (arg1) /* common lisp spec */ |
| @@ -232,10 +227,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, | |||
| 232 | XSETINT (val, acc); | 227 | XSETINT (val, acc); |
| 233 | return val; | 228 | return val; |
| 234 | } | 229 | } |
| 235 | f1 = FLOATP (arg1) ? XFLOAT_DATA (arg1) : XINT (arg1); | 230 | return make_float (pow (XFLOATINT (arg1), XFLOATINT (arg2))); |
| 236 | f2 = FLOATP (arg2) ? XFLOAT_DATA (arg2) : XINT (arg2); | ||
| 237 | f3 = pow (f1, f2); | ||
| 238 | return make_float (f3); | ||
| 239 | } | 231 | } |
| 240 | 232 | ||
| 241 | DEFUN ("log", Flog, Slog, 1, 2, 0, | 233 | DEFUN ("log", Flog, Slog, 1, 2, 0, |