aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.c
diff options
context:
space:
mode:
authorPaul Eggert2018-08-27 21:27:50 -0700
committerPaul Eggert2018-08-27 21:45:23 -0700
commitd77d01d22902acdc45c2c7059de4f1b158ab5806 (patch)
tree35f2b77594dc43e824852bb29598430945c5e6a4 /src/font.c
parent9abaf5f3581ecb76f30e8a6e7ee0e9633c133d1c (diff)
downloademacs-d77d01d22902acdc45c2c7059de4f1b158ab5806.tar.gz
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/font.c')
-rw-r--r--src/font.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/font.c b/src/font.c
index 920ec1e02b1..4a63700f790 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1283,19 +1283,20 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
1283 } 1283 }
1284 1284
1285 val = AREF (font, FONT_SIZE_INDEX); 1285 val = AREF (font, FONT_SIZE_INDEX);
1286 eassert (FIXED_OR_FLOATP (val) || NILP (val)); 1286 eassert (NUMBERP (val) || NILP (val));
1287 char font_size_index_buf[sizeof "-*" 1287 char font_size_index_buf[sizeof "-*"
1288 + max (INT_STRLEN_BOUND (EMACS_INT), 1288 + max (INT_STRLEN_BOUND (EMACS_INT),
1289 1 + DBL_MAX_10_EXP + 1)]; 1289 1 + DBL_MAX_10_EXP + 1)];
1290 if (FIXNUMP (val)) 1290 if (INTEGERP (val))
1291 { 1291 {
1292 EMACS_INT v = XFIXNUM (val); 1292 intmax_t v = FIXNUMP (val) ? XFIXNUM (val) : bignum_to_intmax (val);
1293 if (v <= 0) 1293 if (! (0 <= v && v <= TYPE_MAXIMUM (uprintmax_t)))
1294 v = pixel_size; 1294 v = pixel_size;
1295 if (v > 0) 1295 if (v > 0)
1296 { 1296 {
1297 uprintmax_t u = v;
1297 f[XLFD_PIXEL_INDEX] = p = font_size_index_buf; 1298 f[XLFD_PIXEL_INDEX] = p = font_size_index_buf;
1298 sprintf (p, "%"pI"d-*", v); 1299 sprintf (p, "%"pMu"-*", u);
1299 } 1300 }
1300 else 1301 else
1301 f[XLFD_PIXEL_INDEX] = "*-*"; 1302 f[XLFD_PIXEL_INDEX] = "*-*";
@@ -3324,8 +3325,9 @@ font_open_for_lface (struct frame *f, Lisp_Object entity, Lisp_Object *attrs, Li
3324 if (size == 0) 3325 if (size == 0)
3325 { 3326 {
3326 Lisp_Object ffsize = get_frame_param (f, Qfontsize); 3327 Lisp_Object ffsize = get_frame_param (f, Qfontsize);
3327 size = (FIXED_OR_FLOATP (ffsize) 3328 size = (NUMBERP (ffsize)
3328 ? POINT_TO_PIXEL (XFIXNUM (ffsize), FRAME_RES_Y (f)) : 0); 3329 ? POINT_TO_PIXEL (XFLOATINT (ffsize), FRAME_RES_Y (f))
3330 : 0);
3329 } 3331 }
3330#endif 3332#endif
3331 } 3333 }
@@ -4503,7 +4505,7 @@ where
4503 if (variations[i]) 4505 if (variations[i])
4504 { 4506 {
4505 int vs = (i < 16 ? 0xFE00 + i : 0xE0100 + (i - 16)); 4507 int vs = (i < 16 ? 0xFE00 + i : 0xE0100 + (i - 16));
4506 Lisp_Object code = INTEGER_TO_CONS (variations[i]); 4508 Lisp_Object code = INT_TO_INTEGER (variations[i]);
4507 val = Fcons (Fcons (make_fixnum (vs), code), val); 4509 val = Fcons (Fcons (make_fixnum (vs), code), val);
4508 } 4510 }
4509 return val; 4511 return val;
@@ -4606,7 +4608,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
4606 return Qnil; 4608 return Qnil;
4607 Lisp_Object font_object; 4609 Lisp_Object font_object;
4608 XSETFONT (font_object, face->font); 4610 XSETFONT (font_object, face->font);
4609 return Fcons (font_object, INTEGER_TO_CONS (code)); 4611 return Fcons (font_object, INT_TO_INTEGER (code));
4610} 4612}
4611 4613
4612#if 0 4614#if 0
@@ -4735,7 +4737,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4735 doc: /* Open FONT-ENTITY. */) 4737 doc: /* Open FONT-ENTITY. */)
4736 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame) 4738 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame)
4737{ 4739{
4738 EMACS_INT isize; 4740 intmax_t isize;
4739 struct frame *f = decode_live_frame (frame); 4741 struct frame *f = decode_live_frame (frame);
4740 4742
4741 CHECK_FONT_ENTITY (font_entity); 4743 CHECK_FONT_ENTITY (font_entity);
@@ -4744,11 +4746,17 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4744 isize = XFIXNUM (AREF (font_entity, FONT_SIZE_INDEX)); 4746 isize = XFIXNUM (AREF (font_entity, FONT_SIZE_INDEX));
4745 else 4747 else
4746 { 4748 {
4747 CHECK_FIXNUM_OR_FLOAT (size); 4749 CHECK_NUMBER (size);
4748 if (FLOATP (size)) 4750 if (BIGNUMP (size))
4749 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), FRAME_RES_Y (f)); 4751 {
4752 isize = bignum_to_intmax (size);
4753 if (isize == 0)
4754 args_out_of_range (font_entity, size);
4755 }
4750 else 4756 else
4751 isize = XFIXNUM (size); 4757 isize = (FLOATP (size)
4758 ? POINT_TO_PIXEL (XFLOAT_DATA (size), FRAME_RES_Y (f))
4759 : XFIXNUM (size));
4752 if (! (INT_MIN <= isize && isize <= INT_MAX)) 4760 if (! (INT_MIN <= isize && isize <= INT_MAX))
4753 args_out_of_range (font_entity, size); 4761 args_out_of_range (font_entity, size);
4754 if (isize == 0) 4762 if (isize == 0)