aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.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/editfns.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/editfns.c')
-rw-r--r--src/editfns.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 9ca6f373e04..ad5a26606b4 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -329,7 +329,7 @@ init_editfns (bool dumping)
329 else 329 else
330 { 330 {
331 uid_t euid = geteuid (); 331 uid_t euid = geteuid ();
332 tem = make_fixnum_or_float (euid); 332 tem = INT_TO_INTEGER (euid);
333 } 333 }
334 Vuser_full_name = Fuser_full_name (tem); 334 Vuser_full_name = Fuser_full_name (tem);
335 335
@@ -1338,7 +1338,7 @@ This is based on the effective uid, not the real uid.
1338Also, if the environment variables LOGNAME or USER are set, 1338Also, if the environment variables LOGNAME or USER are set,
1339that determines the value of this function. 1339that determines the value of this function.
1340 1340
1341If optional argument UID is an integer or a float, return the login name 1341If optional argument UID is an integer, return the login name
1342of the user with that uid, or nil if there is no such user. */) 1342of the user with that uid, or nil if there is no such user. */)
1343 (Lisp_Object uid) 1343 (Lisp_Object uid)
1344{ 1344{
@@ -1377,39 +1377,35 @@ This ignores the environment variables LOGNAME and USER, so it differs from
1377} 1377}
1378 1378
1379DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0, 1379DEFUN ("user-uid", Fuser_uid, Suser_uid, 0, 0, 0,
1380 doc: /* Return the effective uid of Emacs. 1380 doc: /* Return the effective uid of Emacs. */)
1381Value is an integer or a float, depending on the value. */)
1382 (void) 1381 (void)
1383{ 1382{
1384 uid_t euid = geteuid (); 1383 uid_t euid = geteuid ();
1385 return make_fixnum_or_float (euid); 1384 return INT_TO_INTEGER (euid);
1386} 1385}
1387 1386
1388DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0, 1387DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0,
1389 doc: /* Return the real uid of Emacs. 1388 doc: /* Return the real uid of Emacs. */)
1390Value is an integer or a float, depending on the value. */)
1391 (void) 1389 (void)
1392{ 1390{
1393 uid_t uid = getuid (); 1391 uid_t uid = getuid ();
1394 return make_fixnum_or_float (uid); 1392 return INT_TO_INTEGER (uid);
1395} 1393}
1396 1394
1397DEFUN ("group-gid", Fgroup_gid, Sgroup_gid, 0, 0, 0, 1395DEFUN ("group-gid", Fgroup_gid, Sgroup_gid, 0, 0, 0,
1398 doc: /* Return the effective gid of Emacs. 1396 doc: /* Return the effective gid of Emacs. */)
1399Value is an integer or a float, depending on the value. */)
1400 (void) 1397 (void)
1401{ 1398{
1402 gid_t egid = getegid (); 1399 gid_t egid = getegid ();
1403 return make_fixnum_or_float (egid); 1400 return INT_TO_INTEGER (egid);
1404} 1401}
1405 1402
1406DEFUN ("group-real-gid", Fgroup_real_gid, Sgroup_real_gid, 0, 0, 0, 1403DEFUN ("group-real-gid", Fgroup_real_gid, Sgroup_real_gid, 0, 0, 0,
1407 doc: /* Return the real gid of Emacs. 1404 doc: /* Return the real gid of Emacs. */)
1408Value is an integer or a float, depending on the value. */)
1409 (void) 1405 (void)
1410{ 1406{
1411 gid_t gid = getgid (); 1407 gid_t gid = getgid ();
1412 return make_fixnum_or_float (gid); 1408 return INT_TO_INTEGER (gid);
1413} 1409}
1414 1410
1415DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0, 1411DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0,
@@ -1417,7 +1413,7 @@ DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0,
1417If the full name corresponding to Emacs's userid is not known, 1413If the full name corresponding to Emacs's userid is not known,
1418return "unknown". 1414return "unknown".
1419 1415
1420If optional argument UID is an integer or float, return the full name 1416If optional argument UID is an integer, return the full name
1421of the user with that uid, or nil if there is no such user. 1417of the user with that uid, or nil if there is no such user.
1422If UID is a string, return the full name of the user with that login 1418If UID is a string, return the full name of the user with that login
1423name, or nil if there is no such user. */) 1419name, or nil if there is no such user. */)
@@ -1429,7 +1425,7 @@ name, or nil if there is no such user. */)
1429 1425
1430 if (NILP (uid)) 1426 if (NILP (uid))
1431 return Vuser_full_name; 1427 return Vuser_full_name;
1432 else if (FIXED_OR_FLOATP (uid)) 1428 else if (NUMBERP (uid))
1433 { 1429 {
1434 uid_t u; 1430 uid_t u;
1435 CONS_TO_INTEGER (uid, uid_t, u); 1431 CONS_TO_INTEGER (uid, uid_t, u);
@@ -1489,7 +1485,7 @@ DEFUN ("emacs-pid", Femacs_pid, Semacs_pid, 0, 0, 0,
1489 (void) 1485 (void)
1490{ 1486{
1491 pid_t pid = getpid (); 1487 pid_t pid = getpid ();
1492 return make_fixnum_or_float (pid); 1488 return INT_TO_INTEGER (pid);
1493} 1489}
1494 1490
1495 1491