summaryrefslogtreecommitdiff
path: root/src/filelock.c
Commit message (Collapse)AuthorAge
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-01
|
* Protect against the host name containing an alpha characterLars Ingebrigtsen2022-04-25
| | | | | | * src/filelock.c (lock_file_1, current_lock_owner): Protect against the unlikely case that the host name contains an alpha character (bug#14250).
* * src/filelock.c (Fcreate_lockfiles): Doc string fix.Paul Eggert2022-04-17
|
* Merge from origin/emacs-28Paul Eggert2022-04-17
|\ | | | | | | 4641bc1c55 Fix GC bug in filelock.c
| * Fix GC bug in filelock.cPaul Eggert2022-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a bug where if GC occurred at the wrong moment when locking a file, the lock file’s name was trashed so file locking did not work. This bug was introduced in Emacs 28.1. The bug sometimes caused filelock-tests-detect-external-change test failures on Fedora 35 x86-64 in an en_US.utf8 locale. * src/filelock.c (lock_file_1, current_lock_owner, lock_if_free) (lock_file, unlock_file, Ffile_locked_p): Use Lisp_Object, not char *, for string, so that GC doesn’t trash string contents. (make_lock_file_name): Return the encoded name, not the original. All callers changed.
* | Remove lock file in --no-build-details, tooLars Ingebrigtsen2022-03-07
| | | | | | | | | | * src/filelock.c (current_lock_owner): Make file writes work when using --no-build-details (bug#54294).
* | Fix error after mergePo Lu2022-01-29
| | | | | | | | * src/filelock.c (lock_file): Fix test against I_OWN_IT.
* | Merge from origin/emacs-28Po Lu2022-01-29
|\| | | | | | | | | | | | | | | 611736f3bc Remove debug logging ddba3c3dba Fix error in filelock.c # Conflicts: # src/filelock.c
| * Fix error in filelock.cMichael Albinus2022-01-29
| | | | | | | | | | | | | | | | * src/filelock.c (lock_file): Move call of file name handler to `Flock_file'. Determine lock_filename only in case create_lockfiles is non-nil. Adapt the rest of the function accordingly. (Flock_file): Do not check for create_lockfiles. Call file name handler if appropriate. (Bug#53207)
* | Clean up filelock code related to errnoPaul Eggert2022-01-11
| | | | | | | | | | | | | | | | | | | | | | | | | | Reduce dependency on Haiku internals, by not assuming that Haiku errno values (which are negative) are neither -1 nor -2. This removes an #ifdef HAIKU while still maintaining portability to Haiku. * src/filelock.c (NEGATIVE_ERRNO, ANOTHER_OWNS_IT, I_OWN_IT): New constants, which should work regardless of whether we are on Haiku or B_USE_POSITIVE_POSIX_ERRORS is defined. (current_lock_owner, lock_if_free, lock_file, unlock_file) (Ffile_locked_p): Use them, without assuming anything about errno value sign.
* | * src/filelock.c (lock_if_free): Fix Haiku positive errno check.Po Lu2022-01-11
| |
* | ; * src/filelock.c (lock_if_free): Fix comment wording.Eli Zaretskii2022-01-09
| |
* | Fix filelock.c for HaikuPo Lu2022-01-09
| | | | | | | | | | | | | | | | | | This was found during the investigation surrounding bug#53136, but is not directly related. * src/filelock.c (lock_if_free): Explictly test err against -1 or -2, and reverse sign of system errors on Haiku. (No Haiku error occupies -1 or -2.)
* | Merge from origin/emacs-28Eli Zaretskii2022-01-01
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year. 86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year ebe8772f65 ; Minor fixes related to copyright years 23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye... 8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t. 19dcb237b5 ; Add 2022 to copyright years. # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex # lib/cdefs.h # lisp/erc/erc-dcc.el # lisp/erc/erc-imenu.el # lisp/erc/erc-replace.el # lisp/image-dired.el # lisp/progmodes/xref.el # m4/alloca.m4 # m4/byteswap.m4 # m4/errno_h.m4 # m4/getopt.m4 # m4/gnulib-common.m4 # m4/inttypes.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/sys_socket_h.m4
| * ; Add 2022 to copyright years.Eli Zaretskii2022-01-01
| |
* | Add support for the Haiku operating system and its window systemPo Lu2021-11-20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .gitignore: Add binaries specific to Haiku. * Makefie.in (HAVE_BE_APP): New variable. (install-arch-dep): Install Emacs and Emacs.pdmp when using Haiku. * configure.ac: Detect and configure for Haiku and various related configurations. (be-app, be-freetype, be-cairo): New options. (HAVE_BE_APP, HAIKU_OBJ, HAIKU_CXX_OBJ) (HAIKU_LIBS, HAIKU_CFLAGS): New variables. (HAIKU, HAVE_TINY_SPEED_T): New define. (emacs_config_features): Add BE_APP. * doc/emacs/Makefile.in (EMACSSOURCES): Add Haiku appendix. * doc/emacs/emacs.texi: Add Haiku appendix to menus and include it. * doc/emacs/haiku.texi: New Haiku appendix. * doc/lispref/display.texi (Defining Faces, Window Systems): Explain meaning of `haiku' as a window system identifier. (haiku-use-system-tooltips): Explain meaning of system tooltips on Haiku. * doc/lispref/frames.texi (Multiple Terminals): Explain meaning of haiku as a display type. (Frame Layout): Clarify section for Haiku frames. (Size Parameters): Explain limitations of fullwidth and fullheight on Haiku. (Management Parameters): Explain limitations of inhibiting double buffering on builds with Cairo, and the inability of frames with no-accept-focus to receive keyboard input on Haiku. (Font and Color Parameters): Explain the different font backends available on Haiku. (Raising and Lowering): Explain that lowering and restacking frames doesn't work on Haiku. (Child Frames): Explain oddities of child frame visibility on Haiku. * doc/lispref/os.texi (System Environment): Explain meaning of haiku. * etc/MACHINES: Add appropriate notices for Haiku. * etc/NEWS: Document changes. * etc/PROBLEMS: Document font spacing bug on Haiku. * lib-src/Makefile.in: Build be-resources binary on Haiku. (CXX, CXXFLAGS, NON_CXX_FLAGS, ALL_CXXFLAGS) (HAVE_BE_APP, HAIKU_LIBS, HAIKU_CFLAGS): New variables. (DONT_INSTALL): Add be-resources binary if on Haiku. (be-resources): New target. * lib-src/be_resources: Add helper binary for setting resources on the Emacs application. * lib-src/emacsclient.c (decode_options): Set alt_display to "be" on Haiku. * lisp/cus-edit.el (custom-button, custom-button-mouse) (custom-button-unraised, custom-button-pressed): Update face definitions for Haiku. * lisp/cus-start.el: Add haiku-debug-on-fatal-error and haiku-use-system-tooltips. * lisp/faces.el (face-valid-attribute-values): Clarify attribute comment for Haiku. (tool-bar): Add appropriate toolbar color for Haiku. * lisp/frame.el (haiku-frame-geometry) (haiku-mouse-absolute-pixel-position) (haiku-set-mouse-absolute-pixel-position) (haiku-frame-edges) (haiku-frame-list-z-order): New function declarations. (frame-geometry, frame-edges) (mouse-absolute-pixel-position) (set-mouse-absolute-pixel-position) (frame-list-z-order): Call appropriate window system functions on Haiku. (display-mouse-p, display-graphic-p) (display-images-p, display-pixel-height) (display-pixel-width, display-mm-height) (display-mm-width, display-backing-store) (display-save-under, display-planes) (display-color-cells, display-visual-class): Update type tests for Haiku. * lisp/international/mule-cmds.el (set-coding-system-map): Also prevent set-terminal-coding-system from appearing in the menu bar on Haiku. * lisp/loadup.el: Load Haiku-specific files when built with Haiku, and don't rename newly built Emacs on Haiku as BFS doesn't support hard links. * lisp/menu-bar.el (menu-bar-open): Add for Haiku. * lisp/mwheel.el (mouse-wheel-down-event): Expect wheel-up on Haiku. (mouse-wheel-up-event): Expect wheel-down on Haiku. (mouse-wheel-left-event): Expect wheel-left on Haiku. (mouse-wheel-right-event): Expect wheel-right on Haiku. * lisp/net/browse-url.el (browse-url--browser-defcustom-type): Add option for WebPositive. (browse-url-webpositive-program): New variable. (browse-url-default-program): Search for WebPositive. (browse-url-webpositive): New function. * lisp/net/eww.el (eww-form-submit, eww-form-file) (eww-form-checkbox, eww-form-select): Define faces appropriately for Haiku. * lisp/term/haiku-win.el: New file. * lisp/tooltip.el (menu-or-popup-active-p): New function declaration. (tooltip-show-help): Don't use tooltips on Haiku when a menu is active. * lisp/version.el (haiku-get-version-string): New function declaration. (emacs-version): Add Haiku version string if appropriate. * src/Makefile.in: Also produce binary named "Emacs" with Haiku resources set. (CXX, HAIKU_OBJ, HAIKU_CXX_OBJ, HAIKU_LIBS) (HAIKU_CFLAGS, HAVE_BE_APP, NON_CXX_FLAGS) (ALL_CXX_FLAGS): New variables. (.SUFFIXES): Add .cc. (.cc.o): New target. (base_obj): Add Haiku C objects. (doc_obj, obj): Split objects that should scanned for documentation into doc_obj. (SOME_MACHINE_OBJECTS): Add appropriate Haiku C objects. (all): Depend on Emacs and Emacs.pdmp on Haiku. (LIBES): Add Haiku libraries. (gl-stamp) ($(etc)/DOC): Scan doc_obj instead of obj (temacs$(EXEEXT): Use C++ linker on Haiku. (ctagsfiles3): New variable. (TAGS): Scan C++ files. * src/alloc.c (garbage_collect): Mark Haiku display. * src/dispextern.h (HAVE_NATIVE_TRANSFORMS): Also enable on Haiku. (struct image): Add fields for Haiku transforms. (RGB_PIXEL_COLOR): Define to unsigned long on Haiku as well. (sit_for): Also check USABLE_SIGPOLL. (init_display_interactive): Set initial window system to Haiku on Haiku builds. * src/emacs.c (main): Define Haiku syms and init haiku clipboard. (shut_down_emacs): Quit BApplication on Haiku and trigger debug on aborts if haiku_debug_on_fatal_error. (Vsystem_type): Update docstring. * src/fileio.c (next-read-file-uses-dialog-p): Enable on Haiku. * src/filelock.c (WTMP_FILE): Only define if BOOT_TIME is also defined. * src/floatfns.c (double_integer_scale): Work around Haiku libroot brain damage. * src/font.c (syms_of_font): Define appropriate font driver symbols for Haiku builds with various options. * src/font.h: Also enable ftcrfont on Haiku builds with Cairo. (font_data_structures_may_be_ill_formed): Also enable on Haiku builds that have Cairo. * src/frame.c (Fframep): Update doc-string for Haiku builds and return haiku if appropriate. (syms_of_frame): New symbol `haiku'. * src/frame.h (struct frame): Add output data for Haiku. (FRAME_HAIKU_P): New macro. (FRAME_WINDOW_P): Test for Haiku frames as well. * src/ftcrfont.c (RED_FROM_ULONG, GREEN_FROM_ULONG) (BLUE_FROM_ULONG): New macros. (ftcrfont_draw): Add haiku specific code for Haiku builds with Cairo. * src/ftfont.c (ftfont_open): Set face. (ftfont_has_char, ftfont_text_extents): Work around crash. (syms_of_ftfont): New symbol `mono'. * src/ftfont.h (struct font_info): Enable Cairo-specific fields for Cairo builds on Haiku. * src/haiku_draw_support.cc: * src/haiku_font_support.cc: * src/haiku_io.c: * src/haiku_select.cc: * src/haiku_support.cc: * src/haiku_support.h: * src/haikufns.c: * src/haikufont.c: * src/haikugui.h: * src/haikuimage.c: * src/haikumenu.c: * src/haikuselect.c: * src/haikuselect.h: * src/haikuterm.c: * src/haikuterm.h: Add new files for Haiku windowing support. * src/haiku.c: Add new files for Haiku operating system support. * src/image.c: Implement image transforms and native XPM support on Haiku. (GET_PIXEL, PUT_PIXEL, NO_PIXMAP) (PIX_MASK_RETAIN, PIX_MASK_DRAW) (RGB_TO_ULONG, RED_FROM_ULONG, GREEN_FROM_ULONG) (BLUE_FROM_ULONG, RED16_FROM_ULONG, GREEN16_FROM_ULONG) (BLUE16_FROM_ULONG): Define to appropriate values on Haiku. (image_create_bitmap_from_data): Add Haiku support. (image_create_bitmap_from_file): Add TODO on Haiku. (free_bitmap_record): Free bitmap on Haiku. (image_size_in_bytes): Implement for Haiku bitmaps. (image_set_transform): Implement on Haiku. (image_create_x_image_and_pixmap_1): Implement on Haiku, 24-bit or 1-bit only. (image_destroy_x_image, image_get_x_image): Use correct img and pixmap values on Haiku. (lookup_rgb_color): Use correct macro on Haiku. (image_to_emacs_colors): Implement on Haiku. (image_disable_image): Disable on Haiku. (image_can_use_native_api): Test for translator presence on Haiku. (native_image_load): Use translator on Haiku. (imagemagick_load_image): Add Haiku-specific quirks. (Fimage_transforms_p): Allow rotate90 on Haiku. (image_types): Enable native XPM support on Haiku. (syms_of_image): Enable XPM images on Haiku. * src/keyboard.c (kbd_buffer_get_event) (handle_async_input, handle_input_available_signal) (handle_user_signal, Fset_input_interrupt_mode) (init_keyboard): Check for USABLE_SIGPOLL along with USABLE_SIGIO. * src/lisp.h (pD): Work around broken Haiku headers. (HAVE_EXT_MENU_BAR): Define on Haiku. (handle_input_available_signal): Enable if we just have SIGPOLL as well. * src/menu.c (have_boxes): Return true on Haiku. (single_menu_item): Enable toolkit menus on Haiku. (find_and_call_menu_selection): Also enable on Haiku. * src/process.c (keyboard_bit_set): Enable with only usable SIGPOLL. (wait_reading_process_output): Test for SIGPOLL as well as SIGIO availability. * src/sound.c (sound_perror, vox_open) (vox_configure, vox_close): Enable for usable SIGPOLL as well. * src/sysdep.c (sys_subshell): Enable for usable SIGPOLL. (reset_sigio): Make conditional on F_SETOWN. (request_sigio, unrequest_sigio) (emacs_sigaction_init): Also handle SIGPOLLs. (init_sys_modes): Disable TCXONC usage on Haiku, as it doesn't have any ttys other than pseudo ttys, which don't support C-s/C-q flow control, and causes compiler warnings. (speeds): Disable high speeds if HAVE_TINY_SPEED_T. * src/termhooks.h (enum output_method): Add output_haiku. (struct terminal): Add Haiku display info. (TERMINAL_FONT_CACHE): Enable for Haiku. * src/terminal.c (Fterminal_live_p): Return `haiku' if appropriate. * src/verbose.mk.in (AM_V_CXX, AM_V_CXXLD): New logging variables. * src/xdisp.c (redisplay_internal) (note_mouse_highlight): Return on Haiku if a popup is activated. (display_menu_bar): Return on Haiku if frame is a Haiku frame. * src/xfaces.c (GCGraphicsExposures): Enable correctly on Haiku. (x_create_gc): Enable dummy GC code on Haiku. * src/xfns.c (x-server-version, x-file-dialog): Add Haiku specifics to doc strings. * src/xterm.c (syms_of_xterm): Add Haiku information to doc string.
* Make supersession warnings work againLars Ingebrigtsen2021-07-23
| | | | | * src/filelock.c (lock_file): Fix thinko in lock_file in 2ad34bcea4e (bug#49701).
* Further cleanup for file locksMichael Albinus2021-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/misc/tramp.texi (Top, Configuration): Adapt node name for file locks. (Auto-save File Lock and Backup): Rename node name and section title. Add file-lock to @cindex. Describe file locks. * lisp/dired.el (dired-trivial-filenames): Add lock files. (dired-font-lock-keywords): Move files suffixed with `completion-ignored-extensions' up. Add lock files to these checks. * lisp/net/tramp.el (tramp-get-lock-file, tramp-handle-unlock-file): Use `when-let' (tramp-lock-file-info-regexp): Rename from `tramp-lock-file-contents-regexp'. (tramp-handle-file-locked-p, tramp-handle-lock-file): Adapt callees. (tramp-handle-lock-file): Set file modes of lockname. * src/buffer.c (Frestore_buffer_modified_p): * src/fileio.c (write_region): * src/insdel.c (prepare_to_modify_buffer_1): Call Flock_file. * src/filelock.c (Qmake_lock_file_name): Declare symbol. (make_lock_file_name): Use it. Don't check Fboundp, it doesn't work for interned symbols. (lock_file): Return a Lisp_Object. Don't check create_lockfiles. Remove MSDOS version of the function. (Flock_file): Check create_lockfiles. (Flock_buffer): Call Flock_file. * src/lisp.h (lock_file): Remove. * test/lisp/shadowfile-tests.el (shadow-test08-shadow-todo) (shadow-test09-shadow-copy-files): Let-bind `create-lockfiles'. * test/lisp/net/tramp-tests.el (create-lockfiles): Don't set it globally. (tramp-test39-lock-file): Check also for `set-visited-file-name'.
* Code cleanup wrt file locksMichael Albinus2021-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/files.el (make-lock-file-name): Fix docstring. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add `make-lock-file-name'. * lisp/net/tramp.el (tramp-file-name-for-operation): Add `make-lock-file-name'. (tramp-handle-unlock-file): Call `userlock--handle-unlock-error' in case of error. * src/buffer.c (Frestore_buffer_modified_p): * src/editfns.c (Freplace_buffer_contents): * src/fileio.c (Finsert_file_contents, write_region): Call Funlock_file. * src/filelock.c (unlock_file): Rename from unlock_file_body. Remove the other declarations of unlock_file. Move file name handler check to ... (Funlock_file): ... here. Adapt argument numbers. Call unlock_file wrapped by internal_condition_case. (Flock_file): Adapt argument numbers. (unlock_all_files, Funlock_buffer, unlock_buffer): Call Funlock_file. * src/lisp.h (unlock_file): Remove.
* Make make_lock_file_name more robustLars Ingebrigtsen2021-07-07
| | | | | | | * src/filelock.c (make_lock_file_name): Protect against the make-lock-file-name not being defined. (lock_file, unlock_file_body, Ffile_locked_p): Return early if not defined.
* Add new user option lock-file-name-transformsLars Ingebrigtsen2021-07-07
| | | | | | | | | | | | | | | | | | | | | | | | | * doc/emacs/files.texi (Interlocking): Mention lock-file-name-transforms. * doc/lispref/files.texi (File Locks): Document lock-file-name-transforms. * doc/misc/efaq.texi (Not writing files to the current directory): Mention all the three variables needed to not having Emacs writing files to the current directory in one place. * lisp/files.el (lock-file-name-transforms): New user option (bug#49261). (make-auto-save-file-name): Factor out the main logic... (auto-save--transform-file-name): ... to this new function. (make-lock-file-name): New function that also calls the factored-out function. * src/filelock.c: Remove MAKE_LOCK_NAME and fill_in_lock_file_name. (make_lock_file_name): New utility function that calls out to Lisp to heed `lock-file-name-transforms'. (lock_file): Use it. Also remove likely buggy call to dostounix_filename. (unlock_file_body, Ffile_locked_p): Also use make_lock_file_name.
* Implement file locks for remote files (Bug#49261)Michael Albinus2021-07-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/files.texi (Magic File Names): Add file-locked-p, lock-file and unlock-file. * etc/NEWS: Tramp supports file locks now. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-adb-handle-write-region): Handle LOCKNAME. * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file) (tramp-crypt-handle-unlock-file): New defun. * lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify. (tramp-fuse-unmount): New defun. * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property. * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-rclone-maybe-open-connection): Set "lock-pid" connection property. * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-sh-handle-write-region): Handle LOCKNAME. * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-smb-handle-copy-directory): Use `sleep-for'. (tramp-smb-handle-write-region): Handle LOCKNAME. * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-sshfs-handle-write-region): Handle LOCKNAME. (tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property. * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-sudoedit-maybe-open-connection): Set "lock-pid" connection property. * lisp/net/tramp.el (tramp-file-name-for-operation): Add `file-locked-p', `lock-file' and `unlock-file'. (tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid) (tramp-handle-file-locked-p, tramp-handle-lock-file) (tramp-handle-unlock-file): New defuns. (tramp-lock-file-contents-regexp): New regexp. (tramp-handle-write-region): Handle LOCKNAME. * src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p): Call handler if exists. (Flock_file, Funlock_file): New defuns. (Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols. (Slock_file, Sunlock_file): Declare subroutines. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test40-make-nearby-temp-file) (tramp-archive-test43-file-system-info): Rename. * test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil. (tramp--test-fuse-p): New defun. (tramp-test14-delete-directory): Use it. (tramp-test39-lock-file): New test. (tramp-test40-make-nearby-temp-file) (tramp-test41-special-characters) (tramp-test41-special-characters-with-stat) (tramp-test41-special-characters-with-perl) (tramp-test41-special-characters-with-ls, tramp-test42-utf8) (tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl) (tramp-test42-utf8-with-ls, tramp-test43-file-system-info) (tramp-test44-asynchronous-requests, tramp-test45-auto-load) (tramp-test45-delay-load, tramp-test45-recursive-load) (tramp-test45-remote-load-path, tramp-test46-unload): Rename. (tramp--test-special-characters, tramp--test-utf8) (tramp--test-asynchronous-requests-timeout): Modify docstring.
* File unlock errors now issue warnings (Bug#46397)Matt Armstrong2021-03-27
| | | | | | | | | | | | | | | | The primary idea is to allow `kill-buffer' and `kill-emacs' to complete even if Emacs has trouble unlocking the buffer's file. * lisp/userlock.el (userlock--handle-unlock-error): New function, call `display-error'. * src/filelock.c (unlock_file_body): New function, do what 'unlock_file' used to. (unlock_file_handle_error): New function, call `userlock--handle-unlock-error' with the captured error. (unlock_file): Handle `file-error' conditions by calling the handler defined above. * test/src/filelock-tests.el (filelock-tests-kill-buffer-spoiled): (filelock-tests-unlock-spoiled): Modify to test new behavior.
* Fix file lock issue (Bug#46397)Paul Eggert2021-02-10
| | | | | * src/filelock.c (current_lock_owner): Also treat ENOTDIR as meaning the lock file does not exist.
* Update copyright year to 2021Paul Eggert2021-01-01
| | | | Run "TZ=UTC0 admin/update-copyright".
* Use the full name of the null byte/character, not its abbreviationAndreas Schwab2020-10-05
| | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (inhibit-nul-byte-detection): Make it an obsolete alias. * src/coding.c (setup_coding_system): Use original name. (detect_coding): Rename nul_byte_found => null_byte_found. (detect_coding_system): Use original name. Rename nul_byte_found => null_byte_found. (Fdefine_coding_system_internal): Use original name. (syms_of_coding): Rename inhibit-nul-byte-detection to inhibit-null-byte-detection. * src/w16select.c (get_clipboard_data): Rename nul_char to null_char. * src/json.c (check_string_without_embedded_nulls): Rename from check_string_without_embedded_nuls. (Fjson_parse_string): Adjust accordingly. * src/coding.h (enum define_coding_undecided_arg_index) (enum coding_attr_index): Rename ...nul_byte... to ...null_byte.... * lisp/info.el (info-insert-file-contents, Info-insert-dir): * lisp/international/mule.el (define-coding-system): * lisp/vc/vc-git.el (vc-git--call): * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use original name.
* Pacify --enable-gcc-warnings for lock_filePaul Eggert2020-03-25
| | | | | * src/filelock.c (lock_file): Pacify gcc -Wmaybe-uninitialized after recent change to this function.
* Avoid extra "changed on disk" prompt in save-buffer (Bug#18336)Noam Postavsky2020-03-22
| | | | | * src/filelock.c (lock_file): Don't query the user if the current session already owns the lock.
* Work better if stat etc. are interruptedPaul Eggert2020-01-20
| | | | | | | | | | | | | | | | | | | | | Quit or retry if fstat, lstat, stat or openat fail with EINTR. This should fix some bugs on platforms where accessing files via NFS can fail that way (Bug#9256). * src/dired.c (file_attributes): * src/fileio.c (file_directory_p) [O_PATH]: Use emacs_openat instead of openat. * src/dired.c (file_attributes): Use emacs_fstatat instead of fstatat. * src/fileio.c (barf_or_query_if_file_exists, Frename_file): * src/filelock.c (rename_lock_file): Use emacs_fstatat instead of lstat. * src/fileio.c (file_directory_p, Ffile_regular_p, Ffile_modes) (Ffile_newer_than_file_p, Fverify_visited_file_modtime) (Fset_visited_file_modtime, auto_save_1): * src/lread.c (Fload): * src/sysdep.c (get_current_dir_name_or_unreachable): Use emacs_fstatat instead of stat. * src/sysdep.c (emacs_fstatat, emacs_openat): New functions. (emacs_open): Redo in terms of emacs_open.
* Update copyright year to 2020Paul Eggert2020-01-01
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Fix bug with lock file on nonstandard filesystemPaul Eggert2019-10-30
| | | | | * src/filelock.c (create_lock_file): Don’t disable user write access to the lock file (Bug#37884).
* Improve reporting of I/O, access errorsPaul Eggert2019-09-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signal an error for file-oriented errors that are not tame errors like ENOENT and ENOTDIR (Bug#37389). Do this for primitives exposed to Lisp; the lower level internal C API merely makes errno values available to higher-level C code. * doc/lispref/files.texi (Testing Accessibility) (File Attributes, Extended Attributes): Do not say that the functions return nil when the return value cannot be determined. * etc/NEWS: Mention the change. * src/dired.c (Ffile_attributes): Fix doc string confusion about opening a file vs getting its attributes. (file_attributes): Signal serious errors. * src/fileio.c (check_existing, check_executable) (check_writable): Remove. All callers changed to use check_file_access or file_access_p. (file_access_p, file_metadata_errno, file_attribute_errno) (file_test_errno, check_file_access, check_emacs_readlinkat): New functions. * src/fileio.c (Ffile_executable_p, Ffile_readable_p) (Ffile_name_case_insensitive_p, Frename_file, Ffile_exists_p): (Ffile_symlink_p, Ffile_directory_p) (Ffile_accessible_directory_p, Ffile_regular_p) (Ffile_selinux_context, Ffile_acl, Ffile_modes) (Ffile_newer_than_file_p, Fset_visited_file_modtime) (Ffile_system_info): * src/filelock.c (unlock_file, Ffile_locked_p): * src/lread.c (Fload): Signal serious errors. * src/fileio.c (Ffile_writable_p): Remove unnecessary CHECK_STRING. (emacs_readlinkat): Now static. * src/filelock.c (current_lock_owner, lock_if_free): Return a positive errno on error, and the negative of the old old value on success. All callers changed. * src/lread.c (openp): Propagate serious errno values to caller.
* Remove printmax_t etc.Paul Eggert2019-07-07
| | | | | | | | | | | | printmax_t etc. were needed only for platforms that lacked support for printing intmax_t. These platforms are now so obsolete that they are no longer practical porting targets. * src/image.c (gs_load): Fix unlikely buffer overrun discovered while making these changes. It was introduced in 2011-07-17T00:34:43!eggert@cs.ucla.edu. * src/lisp.h (printmax_t, uprintmax_t, pMd, pMu, pMx): Remove. All uses replaced by their standard counterparts intmax_t, uintmax_t, PRIdMAX, PRIuMAX, PRIxMAX.
* Merge from emacs-26Noam Postavsky2019-06-25
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | e62ad04963 Fix sgml-mode handling of quotes within parens (Bug#36347) 06b35b2f92 ; * lisp/frame.el: Enhance add-variable-watcher commentary. 572e34bb6f Rename 'make-symbolic-link' argument NEWNAME to LINKNAME 04477adedc Check that length of data returned by sysctl is non-zero 81535eeadb * test/lisp/progmodes/python-tests.el (python-virt-bin): D... 9d48979ca8 Fix Python tests depending on system-type fcf6cc3177 Fix problem with wdired test when symlinks cannot be created. 4701e0663e Improve wording of documentation of click events # Conflicts: # lisp/textmodes/sgml-mode.el # test/lisp/textmodes/sgml-mode-tests.el
| * Check that length of data returned by sysctl is non-zeroRobert Pluim2019-06-20
| | | | | | | | | | | | | | | | | | | | | | | | The length of the data returned by sysctl can be zero, which was not checked for. This could cause crashes, e.g. when querying non-existent processes. (Bug#36279) * src/sysdep.c (list_system_processes) [DARWIN_OS || __FreeBSD__]: (system_process_attributes) [__FreeBSD__]: (system_process_attributes) [DARWIN_OS]: * src/filelock.c (get_boot_time) [CTL_KERN && KERN_BOOTTIME]: Check for zero length data returned by sysctl.
* | Encode the FILENAME argument of 'file-locked-p'Eli Zaretskii2019-04-06
| | | | | | | | | | * src/filelock.c (Ffile_locked_p): Encode the file name, before passing it to system APIs. (Bug#35171)
* | Fix misuses of NULL when talking about the NUL characterStefan Monnier2019-03-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (inhibit-null-byte-detection): Make it an obsolete alias. * src/coding.c (setup_coding_system): Use new name. (detect_coding): Rename null_byte_found => nul_byte_found. (detect_coding_system): Use new name. Rename null_byte_found => nul_byte_found. (Fdefine_coding_system_internal): Use new name. (syms_of_coding): Rename inhibit-null-byte-detection to inhibit-nul-byte-detection. * src/w16select.c (get_clipboard_data): null_char => nul_char. * src/json.c (check_string_without_embedded_nuls): Rename from check_string_without_embedded_nulls. (Fjson_parse_string): Adjust accordingly. * src/coding.h (enum define_coding_undecided_arg_index) (enum coding_attr_index): ...null_byte... => ...nul_byte.... * lisp/info.el (info-insert-file-contents, Info-insert-dir): * lisp/international/mule.el (define-coding-system): * lisp/vc/vc-git.el (vc-git--call): * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use the new name.
* | Add portable dumperDaniel Colascione2019-01-15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new portable dumper as an alternative to unexec. Use it by default. * src/dmpstruct.awk: New file. * src/doc.c (get_doc_string): use will_dump_p(). * src/editfns.c (styled_format): silence compiler warning with UNINIT. * src/emacs-module.c (syms_of_module): staticpro ltv_mark. * src/emacs.c (gflags): new variable. (init_cmdargs): unwrap (string_starts_with_p, find_argument, dump_error_to_string) (load_pdump): new functions. (main): detect pdumper and --temacs invocation; actually load portable dump when detected; set gflags as appropriate; changes to init functions throughout to avoid passing explicit 'initialized' argument. * src/eval.c (inhibit_lisp_code): remove unused variable. (init_eval_once_for_pdumper): new function. (init_eval_once): call it. * src/filelock.c: CANNOT_DUMP -> will_dump_p() * src/fingerprint-dummy.c: new file * src/fingerprint.h: new file * src/fns.c: CANNOT_DUMP -> will_dump_p(), etc. (weak_hash_tables): remove (hashfn_equal, hashfn_eql): un-staticify (make_hash_table): set new 'next_weak' hash table field; drop global weak_hash_tables logic. (copy_hash_table): drop global weak_hash_tables logic. (hash_table_rehash): new function. (hash_lookup, hash_put, hash_remove_from_table, hash_clear): rehash if needed. (sweep_weak_table): un-staticify; explain logic; bool-ify. (sweep_weak_hash_tables): remove function. * src/font.c (syms_of_font): remember pdumper stuff. * src/fontset.c (syms_of_fontset): remember pdumper stuff. * src/frame.c (make_initial_frame): don't reset Vframe_list. (init_frame_once_for_pdumper, init_frame_once): new functions. (syms_of_frame): remove redundant staticpro. * src/fringe.c (init_fringe_once_for_pdumper): new functin. (init_fringe_once): call it. * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper): new function. (syms_of_ftcrfont): call it. * src/ftfont.c (syms_of_ftfont_for_pdumper): new function. (syms_of_ftfont): call it. * src/ftxont.c (syms_of_ftxfont_for_pdumper): new function. (syms_of_ftxfont): call it. * src/gmalloc.c: adjust for pdumper througout (DUMPED): remove weird custom dumped indicator. * src/gnutls.c (syms_of_gnutls): pdumper note for gnutls_global_initialized. * src/image.c (syms_of_image): add pdumper comment, initializer note. * src/insdel.c (prepare_to_modify_buffer_1): account for buffer contents possibly being in dump image. * src/keyboard.c (syms_of_keyboard_for_pdumper): new function. (syms_of_keyboard): staticpro more; call pdumper syms function. * src/lisp.h: add comments throughout (gflags): declare. (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p) (dumped_with_pdumper_p, will_dump_with_unexec_p) (dumped_with_unexec_p, definitely_will_not_unexec_p): new functions. (POWER_OF_2, ROUNDUP): move macros. (PSEUDOVECTOR_TYPE, PSEUDOVECTOR_TYPEP): take vectorlike header pointer instead of vector; constify. (Lisp_Hash_Table): add comment about need to rehash on access; add comment for next_weak. (HASH_KEY, HASH_VALUE, HASH_HASH, HASH_TABLE_SIZE): const-ify. (hash_table_rehash): declare. (hash_rehash_needed_p, hash_rehash_if_needed): new functions. (finalizers, doomed_finalizers): declare extern. (SUBR_SECTION_ATTRIBUTE): new macro. (staticvec, staticidx): un-static-ify. (sweep_weak_hash_tables): remove declaration. (sweep_weak_table): declare. (hashfn_eql, hashfn_equal): declare. (number_finalizers_run): new variable. (Vdead): externify when ENABLE_CHECKING. (gc_root_type): new enumeration. (gc_root_visitor): new struct. (visit_static_gc_roots): declare. (vectorlike_nbytes): declare. (vector_nbytes): define as trivial inline function wrapper for vectorlike_nbytes. (init_obarray_once): change signature. (primary_thread): extern-ify. (init_buffer): change signature. (init_frame_once): declare. * src/lread.c (readevalloop): adjust for new dumped predicates. (init_obarray_once): new function. (ndefsubr): new variable. (defsubr): increment it. (load_path_check): adjust for pdumper. (load_path_default): use pdumper functions; adjust for dump search. * src/macfont.m (macfont_init_font_change_handler): avoid shadowing global. (syms_of_macfont_for_pdumper): new function. (syms_of_macfont): call it. * src/menu.c (syms_of_menu): staticpro more stuff. * src/minibuf.c (Ftry_completion): rehash if needed. (init_minibuf_once_for_pdumper): new function. (init_minibuf_once): call it. * src/nsfont.m (syms_of_nsfns): staticpro more. * src/nsfont.m (syms_of_nsfont_for_pdumper): new function. (syms_of_nsfont): call it. * src/nsterm.m (syms_of_nsfont): remember pdumper stuff. * src/pdumper.c: new file. * src/pdumper.h: new file. * src/process.c (init_process_emacs): use new pdumper functions instead of CANNOT_DUMP. * src/profiler.c (syms_of_profiler_for_pdumper): new function. (syms_of_profiler_for_pdumper): call it. * src/search.c (syms_of_search_for_pdumper): new function. (syms_of_search_for_pdumper): call it. * src/sheap.c (bss_sbrk_did_unexec): remove. * src/sheap.h (bss_sbrk_did_unexec): remove. * src/syntax.c (syms_of_syntax): don't redundantly staticpro re_match_object. * src/sysdep.c: use will_dump_with_unexec_p() instead of bss hack thing. * src/syssignals.h (init_sigsegv): declare. * src/systime.h (init_timefns): remove bool from signature. * src/textprop.c (syms_of_textprop): move staticpro. * src/thread.c (main_thread_p): constify. * src/thread.h (main_thread_p): constify. * src/timefns.c (init_timefns): remove bool from signature. (syms_of_timefns_for_pdumper): new function. (syms_of_timefns): call it. * src/w32.c: rearrange code. * src/w32.h (w32_relocate): declare. * src/w32fns.c (syms_of_w32fns): add pdumper note. * src/w32font.c (syms_of_w32font_for_pdumper): new function. (syms_of_w32font): call it. * src/w32heap.c (using_dynamic_heap): new variable. (init_heap): use it. * src/w32menu.c (syms_of_w32menu): add pdumper note. * src/w32proc.c (ctrl_c_handler, mainCRTStartup, _start, open_input_file) (rva_to_section, close_file_data): move here. * src/w32uniscribe.c (syms_of_w32uniscribe_for_pdumper): new function. (syms_of_w32uniscribe): call it. * src/window.c (init_window_once_for_pdumper): new function. (init_window_once): call it; staticpro more stuff. * src/xfont.c (syms_of_xfont_for_pdumper): new function. (syms_of_xfont): call it. * src/xftfont.c (syms_of_xftfont_for_pdumper): new function. (syms_of_xftfont): call it. * src/xmenu.c (syms_of_xmenu_for_pdumper): new function. (syms_of_xmenu): call it. * src/xselect.c (syms_of_xselect_for_pdumper): new function. (syms_of_xselect): call it. * src/xsettings.c (syms_of_xsettings): add more pdumper notes. * src/term.c (syms_of_xterm): add pdumper note. * src/dispnew.c (init_faces_initial): new function. (init_display_interactive): rename from init_display; use will_dump_p instead of !initialized. Initialize faces early for pdumper if needed. (init_display): new function. (syms_of_display_for_pdumper): new function. (syms_of_display): call it. * src/dbusbind.c (syms_of_dbusbind): Add TODO for bus reset on pdumper load. * src/data.c (Fdefalias): Use will_dump_p instead of Vpurify_flag. (Fmake_variable_buffer_local): silence compiler warning with -Og by making valcontents UNINIT. (arith_driver): silence compiler warning with UNINIT. * src/conf_post.h (ATTRIBUTE_SECTION): new macro. * src/composite.c (composition_gstring_put_cache): rehash hash table if needed. * src/coding.c (init_coding_once, syms_of_coding): remember pdumper stuff. * src/charset.h (charset_table_size, charset_table_user): declare. * src/charset.c (charset_table_used, charset_table_size): un-static. (init_charset_oncem, syms_of_charset): remember pdumper stuff. * src/category.c (category_table_version): remove obsolete variable. * src/callint.c (syms_of_callint): staticpro 'preserved_fns' (init_callproc): use will_dump_p instead of !CANNOT_DUMP. * src/bytecode.c (exec_byte_code): rehash table tables if needed * src/buffer.c (alloc_buffer_text, free_buffer_text): account for pdumper (init_buffer_once): add TODO; remember stuff for pdumper. (init_buffer): don't take initialized argument; adjust for pdumper. * src/atimer.c (init_atimer): initialize subr only if !initialized. * src/alloc.c: (vector_marked_p, set_vector_marked) (vectorlike_marked_p, set_vectorlike_marked, cons_marked_p) (set_cons_marked, string_marked_p, set_string_marked) (symbol_marked_p, set_symbol_marked, interval_marked_p) (set_interval_marked): new accessor routines. Use them instead of raw GC access throughout. (Vdead): make non-static when ENABLE_CHECKING. (vectorlike_nbytes): rename of 'vector_nbytes'; take a vectorlike header as input instead of a vector. (number_finalizers_run): new internal C variable. (mark_maybe_object): check for pdumper objects. (valid_pointer_p): don't be gratuitously inefficient under rr(1). (make_pure_c_string): add support for size_byte = -2 mode indicating that string data points into Emacs image rodata. (visit_vectorlike_root): visits GC roots embedded in vectorlike objects. (visit_buffer_root): visits GC roots embedded in our totally-not-a-buffer buffer global objects. (visit_static_gc_roots): visit GC roots in the Emacs data section. (mark_object_root_visitor): root callback used for conventional GC marking (weak_hash_tables): new internal variable for tracking found weak hash tables during GC. (mark_and_sweep_weak_table_contents): new weak hash table marking. (garbage_collect_1): use new GC root visitor machinery. (mark_vectorlike): accept a vectorlike_header instead of a Lisp_Vector. (mark_frame, mark_window, mark_hash_table): new functions. (mark_object): initialize 'm'; check for pdumper objects and use new mark-bit accessors throughout. Remove some object-specific marking code and move to helper functions above. (survives_gc_p): check for pdumper objects. (gc-sweep): clear pdumper mark bits. (init_alloc_once_for_pdumper): new helper function for early init called both during normal init and pdumper load. (init_alloc_once): pdumper integration. * src/Makefile.in: Rewrite dumping for pdumper; add pdumper.o; invoke temacs with --temacs command line option; build dmpstruct.h from dmpstruct.awk; stop relying on CANNOT_DUMP; clean up pdumper intermediate files during build. * nextstep/Makefile.in: build emacs.pdmp into NS packages * lisp/startup.el: account for new '--temacs' and '--dump-file' command line option. * lisp/loadup.el: rewrite early init to account for pdumper; use injected 'dump-mode' variable (set via the new '--temacs' option) instead of parsing command line. * lisp/cus-start.el: Check 'dump-mode' instead of 'purify-flag', since the new 'dump-mode' * lib-src/make-fingerprint.c: new program * lib-src/Makefile.in: built make-fingerprint utility program * configure.ac: Add --with-pdumper toggle to control pdumper support; add --with-unexec toggle to control unexec support. Add --with-dumping option to control which dumping strategy we use by default. Adjust for pdumper throughout. Check for posix_madvise. * Makefile.in: Add @DUMPING@ substitution; add pdumper mode. * .gitignore: Add make-fingerprint, temacs.in, fingerprint.c, dmpstruct.h, and pdumper dump files.
* Update copyright year to 2019Paul Eggert2019-01-01
| | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* Add detailed documentation about lock filesRobert Pluim2018-06-01
| | | | | | | | | | | | | | * doc/emacs/files.texi (Interlocking): Point user at detailed file locking description in lisp reference manual. Add index entry for '.#' to improve disoverability of information about locking. * doc/lispref/files.texi (File Locks): Describe in detail what the form of the lock file is. Add index entry for '.#' to improve disoverability of information about locking. * src/filelock.c (create-lockfiles): Add cross reference to file locking in user manual and to 'lock-buffer'. Add string '.#' to help users find the doc string.
* Update copyright year to 2018Paul Eggert2018-01-01
| | | | Run admin/update-copyright.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-13
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Improve make-temp-file performance on local filesPaul Eggert2017-08-18
| | | | | | | * lisp/files.el (make-temp-file): Let make-temp-file-internal do the work of inserting the text. * src/fileio.c (Fmake_temp_file_internal): New arg TEXT. All callers changed.
* Merge from Gnulib; use ‘open’ for O_CLOEXECPaul Eggert2017-08-16
| | | | | | | | | | | | | | | | | | | | | | This incorporates: 2017-08-15 renameat: ensure declaration in <stdio.h> on NetBSD 2017-08-15 extensions: enable NetBSD specific extensions 2017-08-14 open: support O_CLOEXEC 2017-08-13 reallocarray: new module * admin/merge-gnulib (AVOIDED_MODULES): Remove ‘open’, since it now supports O_CLOEXEC and this simplifies Emacs. * build-aux/config.guess, lib/fcntl.in.h, lib/stdio.in.h: * lib/stdlib.in.h, m4/extensions.m4, m4/stdlib_h.m4: Copy from Gnulib. * lib/cloexec.c, lib/cloexec.h, lib/open.c: * m4/mode_t.m4, m4/open-cloexec.m4, m4/open.m4: New files, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib-src/etags.c (O_CLOEXEC) [WINDOWSNT]: Remove, as Gnulib does this for us. * src/filelock.c (create_lock_file): * src/sysdep.c (emacs_open, emacs_pipe): Don’t worry about O_CLOEXEC == 0, as Gnulib no longer sets it to 0.
* Improve make-temp-file performance on local filesPaul Eggert2017-08-12
| | | | | | | | | | | | | | | | | | | | | | | | | | For the motivation behind this patch, please see Bug#28023 and: http://emacshorrors.com/posts/make-temp-name.html Although, given the recent changes to Tramp, the related security problem in make-temp-file is already fixed, make-temp-file still has several unnecessary system calls. In the typical case on GNU/Linux, this patch replaces 8 syscalls (symlink, open, close, readlinkat, uname, getpid, unlink, umask) by 2 (open, close). * admin/merge-gnulib (GNULIB_MODULES): Add tempname, now that Emacs is using it directly. * configure.ac (AUTO_DEPEND): Remove AC_SYS_LONG_FILE_NAMES; no longer needed. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lisp/files.el (files--make-magic-temp-file): Rename from make-temp-file. (make-temp-file): Use make-temp-file-internal for non-magic file names. * src/fileio.c: Include tempname.h. (make_temp_name_tbl, make_temp_name_count) (make_temp_name_count_initialized_p, make_temp_name): Remove. (Fmake_temp_file_internal): New function. (Fmake_temp_name): Use it. * src/filelock.c (get_boot_time): Use Fmake_temp_file_internal instead of make_temp_name.
* When renaming a file, ask only if EEXIST or ENOSYSPaul Eggert2017-08-02
| | | | | | | | | | | | | | * src/fileio.c (Frename_file): Avoid calling Ffile_directory_p more than once on FILE. Use renameat_noreplace, so that we can ask the user (and unlink and retry) only if this fails with errno == EEXIST or ENOSYS. This avoids the need to ask the user for permission to do an operation that will fail anyway. Simplify computation of ok_if_already_exists for subsidiary functions. * src/filelock.c (rename_lock_file): Prefer renameat_noreplace if it works, as this avoids the need to link and unlink. * src/lisp.h (renameat_noreplace): New decl. * src/sysdep.c [HAVE_LINUX_FS_H]: Include linux/fs.h and sys/syscall.h. (renameat_noreplace): New function.
* Merge with gnulib, pacifying GCC 7Paul Eggert2017-05-16
| | | | | | | | | | | | | | | | | | | | | | | | This incorporates: 2017-05-16 manywarnings: update for GCC 7 2017-05-15 sys_select: Avoid "was expanded before it was required" * configure.ac (nw): Suppress GCC 7’s new -Wduplicated-branches and -Wformat-overflow=2 options, due to too many false alarms. * doc/misc/texinfo.tex, lib/strftime.c, m4/manywarnings.m4: Copy from gnulib. * m4/gnulib-comp.m4: Regenerate. * src/coding.c (decode_coding_iso_2022): Fix bug uncovered by -Wimplicit-fallthrough. * src/conf_post.h (FALLTHROUGH): New macro. Use it to mark all switch cases that fall through. * src/editfns.c (styled_format): Use !, not ~, on bool. * src/gtkutil.c (xg_check_special_colors): When using sprintf, don’t trust Gtk to output colors in [0, 1] range. (xg_update_scrollbar_pos): Avoid use of possibly-uninitialized bool; this bug was actually caught by Clang. * src/search.c (boyer_moore): Tell GCC that CHAR_BASE, if nonzero, must be a non-ASCII character. * src/xterm.c (x_draw_glyphless_glyph_string_foreground): Tell GCC that glyph->u.glyphless.ch must be a character.
* Revamp quitting and fix infloopsPaul Eggert2017-02-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes some infinite loops that cannot be quitted out of, e.g., (defun foo () (nth most-positive-fixnum '#1=(1 . #1#))) when byte-compiled and when run under X. See: http://lists.gnu.org/archive/html/emacs-devel/2017-01/msg00577.html This also attempts to keep the performance improvements I recently added, as much as possible under the constraint that the infloops must be caught. In some cases this fixes infloop bugs recently introduced when I removed immediate_quit. * src/alloc.c (Fmake_list): Use rarely_quit, not maybe_quit, for speed in the usual case. * src/bytecode.c (exec_byte_code): * src/editfns.c (Fcompare_buffer_substrings): * src/fns.c (Fnthcdr): * src/syntax.c (scan_words, skip_chars, skip_syntaxes) (Fbackward_prefix_chars): Use rarely_quit so that users can C-g out of long loops. * src/callproc.c (call_process_cleanup, call_process): * src/fileio.c (read_non_regular, Finsert_file_contents): * src/indent.c (compute_motion): * src/syntax.c (scan_words, Fforward_comment): Remove now-unnecessary maybe_quit calls. * src/callproc.c (call_process): * src/doc.c (get_doc_string, Fsnarf_documentation): * src/fileio.c (Fcopy_file, read_non_regular, Finsert_file_contents): * src/lread.c (safe_to_load_version): * src/sysdep.c (system_process_attributes) [GNU_LINUX]: Use emacs_read_quit instead of emacs_read in places where C-g handling is safe. * src/eval.c (maybe_quit): Move comment here from lisp.h. * src/fileio.c (Fcopy_file, e_write): Use emacs_write_quit instead of emacs_write_sig in places where C-g handling is safe. * src/filelock.c (create_lock_file): Use emacs_write, not plain write, as emacs_write no longer has a problem. (read_lock_data): Use emacs_read, not read, as emacs_read no longer has a problem. * src/fns.c (rarely_quit): Move to lisp.h and rename to incr_rarely_quit. All uses changed.. * src/fns.c (Fmemq, Fmemql, Fassq, Frassq, Fplist_put, Fplist_member): * src/indent.c (compute_motion): * src/syntax.c (find_defun_start, back_comment, forw_comment) (Fforward_comment, scan_lists, scan_sexps_forward): Use incr_rarely_quit so that users can C-g out of long loops. * src/fns.c (Fnconc): Move incr_rarely_quit call to within inner loop, so that it catches C-g there too. * src/keyboard.c (tty_read_avail_input): Remove commented-out and now-obsolete code dealing with interrupts. * src/lisp.h (rarely_quit, incr_rarely_quit): New functions, the latter moved here from fns.c and renamed from rarely_quit. (emacs_read_quit, emacs_write_quit): New decls. * src/search.c (find_newline, search_buffer, find_newline1): Add maybe_quit to catch C-g. * src/sysdep.c (get_child_status): Always invoke maybe_quit if interruptible, so that the caller need not bother. (emacs_nointr_read, emacs_read_quit, emacs_write_quit): New functions. (emacs_read): Rewrite in terms of emacs_nointr_read. Do not handle C-g or signals; that is now for emacs_read_quit. (emacs_full_write): Replace PROCESS_SIGNALS two-way arg with INTERRUPTIBLE three-way arg. All uses changed.
* Replace QUIT with maybe_quitPaul Eggert2017-01-25
| | | | | | | | There’s no longer need to have QUIT stand for a slug of C statements. Use the more-obvious function-call syntax instead. Also, use true and false when setting immediate_quit. These changes should not affect the generated machine code. * src/lisp.h (QUIT): Remove. All uses replaced by maybe_quit.
* Merge from origin/emacs-25Paul Eggert2017-01-01
|\ | | | | | | | | 2e2a806 Fix copyright years by hand 5badc81 Update copyright year to 2017