diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-08-27 21:27:50 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-08-27 21:45:23 -0700 |
commit | d77d01d22902acdc45c2c7059de4f1b158ab5806 (patch) | |
tree | 35f2b77594dc43e824852bb29598430945c5e6a4 /src/xdisp.c | |
parent | 9abaf5f3581ecb76f30e8a6e7ee0e9633c133d1c (diff) | |
download | emacs-d77d01d22902acdc45c2c7059de4f1b158ab5806.tar.gz emacs-d77d01d22902acdc45c2c7059de4f1b158ab5806.tar.bz2 emacs-d77d01d22902acdc45c2c7059de4f1b158ab5806.zip |
Improve bignum support for system types
Use bignums when Emacs converts to and from system types like
off_t for file sizes whose values can exceed fixnum range.
Formerly, Emacs sometimes generted floats and sometimes ad-hoc
conses of integers. Emacs still accepts floats and conses for
these system types, in case some stray Lisp code is generating
them, though this usage is obsolescent.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/hash.texi (Defining Hash):
* doc/lispref/nonascii.texi (Character Sets):
* doc/lispref/os.texi (User Identification):
* doc/lispref/processes.texi (System Processes):
* etc/NEWS:
Document changes.
* src/bignum.c (mpz_set_uintmax, make_biguint)
(mpz_set_uintmax_slow, bignum_to_intmax, bignum_to_uintmax):
New functions.
(mpz_set_intmax_slow): Implement via mpz_limbs_write,
to avoid the need for an extra pass through a negative number.
* src/charset.c (Fencode_char):
* src/composite.h (LGLYPH_SET_CODE):
* src/dired.c (file_attributes):
* src/dosfns.c, src/w32.c (list_system_processes)
(system_process_attributes):
* src/editfns.c (init_editfns, Fuser_uid, Fuser_real_uid)
(Fgroup_gid, Fgroup_real_gid, Femacs_pid):
* src/emacs-module.c (check_vec_index):
* src/fns.c (Fsafe_length):
* src/process.c (record_deleted_pid, Fprocess_id):
* src/sysdep.c (list_system_processes, system_process_attributes):
* src/xselect.c (x_own_selection, selection_data_to_lisp_data):
* src/xterm.c (set_wm_state):
* src/inotify.c (inotifyevent_to_event, add_watch)
(inotify_callback):
If an integer is out of fixnum range, use a bignum
instead of converting it to a float or a cons of integers.
* src/coding.c (Fdefine_coding_system_internal):
* src/frame.c (frame_windows_min_size)
(x_set_frame_parameters):
* src/fringe.c (Fdefine_fringe_bitmap):
* src/nsterm.m (mouseDown:):
* src/syntax.c (find_defun_start):
* src/w32fns.c (x_set_undecorated, w32_createwindow)
(w32_wnd_proc, Fx_create_frame, Fx_show_tip)
(w32_console_toggle_lock_key):
* src/w32inevt.c (key_event):
* src/w32proc.c (Fw32_get_locale_info):
Do not mishandle floats by treating their addresses as their
values.
* src/data.c (store_symval_forwarding):
* src/gnutls.c (Fgnutls_error_fatalp, Fgnutls_error_string):
* src/keyboard.c (command_loop_1, make_lispy_event):
* src/lread.c (read_filtered_event, read1)
(substitute_object_recurse):
* src/window.c (Fcoordinates_in_window_p, Fwindow_at)
(window_resize_apply, Fset_window_vscroll):
* src/xdisp.c (handle_single_display_spec, try_scrolling)
(redisplay_window, calc_pixel_width_or_height)
(calc_line_height_property, on_hot_spot_p):
* src/xfaces.c (check_lface_attrs):
* src/xselect.c (x_get_local_selection, cons_to_x_long)
(lisp_data_to_selection_data, clean_local_selection_data)
(x_check_property_data, x_fill_property_data):
(x_send_client_event):
Do not reject bignums.
* src/data.c (INTBIG_TO_LISP, intbig_to_lisp)
(uintbig_to_lisp):
Remove. All uses removed.
* src/data.c (cons_to_unsigned, cons_to_signed):
* src/dbusbind.c (xd_signature, xd_extract_signed)
(xd_extract_unsigned):
* src/dispnew.c (sit_for):
* src/dosfns.c, src/w32.c (system_process_attributes):
* src/editfns.c (Fuser_full_name):
* src/fileio.c (file_offset):
* src/fileio.c (write_region):
* src/font.c (font_unparse_xlfd, font_open_for_lface, Fopen_font):
* src/frame.c (x_set_screen_gamma):
* src/frame.h (NUMVAL, FRAME_PIXEL_X_FROM_CANON_X)
(FRAME_PIXEL_Y_FROM_CANON_Y):
* src/image.c (parse_image_spec, x_edge_detection)
(compute_image_size):
* src/json.c (json_to_lisp):
* src/lcms.c (PARSE_LAB_LIST_FIELD, Flcms_cie_de2000)
(PARSE_XYZ_LIST_FIELD, PARSE_JCH_LIST_FIELD)
(PARSE_JAB_LIST_FIELD, PARSE_VIEW_CONDITION_FLOAT)
(Flcms_temp_to_white_point):
* src/nsimage.m (ns_load_image, setSizeFromSpec):
* src/process.c (Fsignal_process, handle_child_signal):
* src/sysdep.c (system_process_attributes):
* src/xdisp.c (calc_line_height_property):
Handle bignums.
* src/data.c (Fnumber_to_string): Use proper predicate name in
signal if the argument is not a number.
* src/lisp.h (make_uint): New function.
(INT_TO_INTEGER): New macro.
(FIXED_OR_FLOATP, CHECK_FIXNUM_OR_FLOAT)
(CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER, INTEGER_TO_CONS)
(make_fixnum_or_float): Remove; no longer used.
* src/nsfns.m, src/w32fns.c, src/xfns.c (Fx_create_frame):
Reject floating-point min-width or min-height.
* src/process.c (handle_child_signal): Do not worry
about floating-point pids, as they are no longer generated.
Diffstat (limited to 'src/xdisp.c')
-rw-r--r-- | src/xdisp.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 0835ccafd4d..11b14e2cf95 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4978,10 +4978,10 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, Lisp_Object height; height = safe_call1 (it->font_height, face->lface[LFACE_HEIGHT_INDEX]); - if (FIXED_OR_FLOATP (height)) + if (NUMBERP (height)) new_height = XFLOATINT (height); } - else if (FIXED_OR_FLOATP (it->font_height)) + else if (NUMBERP (it->font_height)) { /* Value is a multiple of the canonical char height. */ struct face *f; @@ -5002,7 +5002,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, value = safe_eval (it->font_height); value = unbind_to (count, value); - if (FIXED_OR_FLOATP (value)) + if (NUMBERP (value)) new_height = XFLOATINT (value); } @@ -5025,7 +5025,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, return 0; value = XCAR (XCDR (spec)); - if (FIXED_OR_FLOATP (value) && XFLOATINT (value) > 0) + if (NUMBERP (value) && XFLOATINT (value) > 0) it->space_width = value; } @@ -5074,7 +5074,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, #ifdef HAVE_WINDOW_SYSTEM value = XCAR (XCDR (spec)); - if (FIXED_OR_FLOATP (value)) + if (NUMBERP (value)) { struct face *face = FACE_FROM_ID (it->f, it->face_id); it->voffset = - (XFLOATINT (value) @@ -15729,8 +15729,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, scroll_max = (max (scroll_step, max (arg_scroll_conservatively, temp_scroll_step)) * frame_line_height); - else if (FIXED_OR_FLOATP (BVAR (current_buffer, scroll_down_aggressively)) - || FIXED_OR_FLOATP (BVAR (current_buffer, scroll_up_aggressively))) + else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively)) + || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))) /* We're trying to scroll because of aggressive scrolling but no scroll_step is set. Choose an arbitrary one. */ scroll_max = 10 * frame_line_height; @@ -15830,7 +15830,7 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, { aggressive = BVAR (current_buffer, scroll_up_aggressively); height = WINDOW_BOX_TEXT_HEIGHT (w); - if (FIXED_OR_FLOATP (aggressive)) + if (NUMBERP (aggressive)) { double float_amount = XFLOATINT (aggressive) * height; int aggressive_scroll = float_amount; @@ -15946,7 +15946,7 @@ try_scrolling (Lisp_Object window, bool just_this_one_p, { aggressive = BVAR (current_buffer, scroll_down_aggressively); height = WINDOW_BOX_TEXT_HEIGHT (w); - if (FIXED_OR_FLOATP (aggressive)) + if (NUMBERP (aggressive)) { double float_amount = XFLOATINT (aggressive) * height; int aggressive_scroll = float_amount; @@ -17223,8 +17223,8 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) if ((scroll_conservatively || emacs_scroll_step || temp_scroll_step - || FIXED_OR_FLOATP (BVAR (current_buffer, scroll_up_aggressively)) - || FIXED_OR_FLOATP (BVAR (current_buffer, scroll_down_aggressively))) + || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)) + || NUMBERP (BVAR (current_buffer, scroll_down_aggressively))) && CHARPOS (startp) >= BEGV && CHARPOS (startp) <= ZV) { @@ -17299,13 +17299,13 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) : BVAR (current_buffer, scroll_down_aggressively); if (!MINI_WINDOW_P (w) - && (scroll_conservatively > SCROLL_LIMIT || FIXED_OR_FLOATP (aggressive))) + && (scroll_conservatively > SCROLL_LIMIT || NUMBERP (aggressive))) { int pt_offset = 0; /* Setting scroll-conservatively overrides scroll-*-aggressively. */ - if (!scroll_conservatively && FIXED_OR_FLOATP (aggressive)) + if (!scroll_conservatively && NUMBERP (aggressive)) { double float_amount = XFLOATINT (aggressive); @@ -25520,7 +25520,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, prop = Qnil; } - if (FIXED_OR_FLOATP (prop)) + if (NUMBERP (prop)) { int base_unit = (width_p ? FRAME_COLUMN_WIDTH (it->f) @@ -25584,8 +25584,8 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, } /* '(NUM)': absolute number of pixels. */ - if (FIXED_OR_FLOATP (car)) - { + if (NUMBERP (car)) +{ double fact; int offset = width_p && align_to && *align_to < 0 ? it->lnum_pixel_width : 0; @@ -27852,14 +27852,14 @@ calc_line_height_property (struct it *it, Lisp_Object val, struct font *font, Lisp_Object face_name = Qnil; int ascent, descent, height; - if (NILP (val) || FIXNUMP (val) || (override && EQ (val, Qt))) + if (NILP (val) || INTEGERP (val) || (override && EQ (val, Qt))) return val; if (CONSP (val)) { face_name = XCAR (val); val = XCDR (val); - if (!FIXED_OR_FLOATP (val)) + if (!NUMBERP (val)) val = make_fixnum (1); if (NILP (face_name)) { @@ -27903,10 +27903,13 @@ calc_line_height_property (struct it *it, Lisp_Object val, struct font *font, height = ascent + descent; scale: + /* FIXME: Check for overflow in multiplication or conversion. */ if (FLOATP (val)) height = (int)(XFLOAT_DATA (val) * height); else if (FIXNUMP (val)) height *= XFIXNUM (val); + else + height *= bignum_to_intmax (val); return make_fixnum (height); } @@ -30770,7 +30773,7 @@ on_hot_spot_p (Lisp_Object hot_spot, int x, int y) Lisp_Object lr, lx0, ly0; if (CONSP (circ) && CONSP (XCAR (circ)) - && (lr = XCDR (circ), FIXED_OR_FLOATP (lr)) + && (lr = XCDR (circ), NUMBERP (lr)) && (lx0 = XCAR (XCAR (circ)), FIXNUMP (lx0)) && (ly0 = XCDR (XCAR (circ)), FIXNUMP (ly0))) { |