summaryrefslogtreecommitdiff
path: root/src/fileio.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve integer range checkingPaul Eggert2020-04-051-2/+2
| | | | | | | | | | | | | | | | | | * src/bignum.c (check_integer_range, check_uinteger_max) (check_int_nonnegative): New functions. * src/frame.c (check_frame_pixels): New function. (Fset_frame_height, Fset_frame_width, Fset_frame_size): Use it. * src/lisp.h (CHECK_RANGED_INTEGER, CHECK_TYPE_RANGED_INTEGER): Remove these macros. Unless otherwise specified, all callers replaced by calls to check_integer_range, check_uinteger_range, check_int_nonnegative. * src/frame.c (gui_set_right_divider_width) (gui_set_bottom_divider_width): * src/nsfns.m (ns_set_internal_border_width): * src/xfns.c (x_set_internal_border_width): Using check_int_nonnegative means these functions no longer incorrectly reject negative bignums; they treat them as 0, just like negative fixnums.
* Stop using newly-deprecated dosname Gnulib modulePaul Eggert2020-03-281-1/+1
| | | | | | | | | Code is supposed to use the filename module now. * admin/merge-gnulib (GNULIB_MODULES): Replace dosname with filename. * lib/dosname.h: Remove this forwarding stub. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib-src/emacsclient.c, src/fileio.c: Include filename.h instead of dosname.h.
* Fix the MinGW build as followup to recent "nofollow" changesEli Zaretskii2020-03-081-1/+1
| | | | | | | | | | | | | | | | | | | | * src/w32.c (fdutimens): Call utimensat instead of utime. (set_file_times): Function deleted. (convert_from_timespec): Renamed from convert_from_time_t and modified to accept 'struct timespec' argument instead of 'time_t'. (utimensat): Renamed from utime and modified to accept 'struct timespec [2]' argument and an additional argument FLAG. Emulate Posix 'utimensat'. Call 'convert_from_timespec'. (w32_copy_file): Call 'utimensat' instead of 'set_file_times'. * src/fileio.c (Fcopy_file) [WINDOWSNT]: Make the error message be identical to that on Posix platforms. * nt/inc/sys/stat.h (utimensat): Provide prototype. * nt/mingw-cfg.site (ac_cv_func_futimens) (gl_cv_func_futimens_works, ac_cv_func_utimensat) (gl_cv_func_utimensat_works): Override Gnulib tests. * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_futimens) (OMIT_GNULIB_MODULE_utimensat): Disable these Gnulib modules.
* Add ‘nofollow’ flag to set-file-timesPaul Eggert2020-03-071-25/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a companion to the recent set-file-modes patch. It adds support for a ‘nofollow’ flag to set-file-times (Bug#39773). Like the set-file-modes patch, it needs work in the w32 port. * admin/merge-gnulib (GNULIB_MODULES): Add futimens, utimensat. Remove utimens. * doc/lispref/files.texi (Changing Files): * etc/NEWS: Mention the change. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lisp/files.el (copy-directory): * lisp/gnus/gnus-cloud.el (gnus-cloud-replace-file): * lisp/net/tramp-adb.el (tramp-adb-handle-copy-file): * lisp/net/tramp-smb.el (tramp-smb-handle-copy-file): * lisp/tar-mode.el (tar-copy): * test/lisp/filenotify-tests.el (file-notify-test03-events): * test/lisp/files-tests.el: (files-tests-file-name-non-special-set-file-times): * test/lisp/net/tramp-tests.el (tramp-test22-file-times): When setting file times, avoid following symbolic links when the file is not supposed to be a symbolic link. * lib/futimens.c, lib/utimensat.c, m4/futimens.m4, m4/utimensat.m4: New files, copied from Gnulib. * lisp/gnus/gnus-cloud.el (gnus-cloud-replace-file): When creating a file that is not supposed to exist already, use the excl flag to check this. * lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times): * lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-times): Accept an optional FLAG arg that is currently ignored, and add a FIXME comment for it. * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-times): * src/fileio.c (Fset_file_times): Support an optional FLAG arg. * src/fileio.c (Fcopy_file): Use futimens instead of set_file_times, as it’s simpler and is a POSIX API. * src/sysdep.c (set_file_times): Move from here ... * src/w32.c (set_file_times): ... to here, and make it static, since it is now used only in w32.c. Presumably w32.c should also add support for futimens and utimensat (the POSIX APIs, which Emacs now uses) and it can remove fdutimens (the Gnulib API, which Emacs no longer uses).
* Add 'nofollow' flag to set-file-modes etc.Paul Eggert2020-02-231-18/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids some race conditions (Bug#39683). E.g., if some other program changes a file to a symlink between the time Emacs creates the file and the time it changes the file’s permissions, using the new flag prevents Emacs from inadvertently changing the permissions of a victim in some completely unrelated directory. * admin/merge-gnulib (GNULIB_MODULES): Add fchmodat. * doc/lispref/files.texi (Testing Accessibility, Changing Files): * doc/lispref/os.texi (File Notifications): * etc/NEWS: Adjust documentation accordingly. * lib/chmodat.c, lib/fchmodat.c, lib/lchmod.c, m4/fchmodat.m4: * m4/lchmod.m4: New files, copied from Gnulib. * lib/gnulib.mk.in: Regenerate. * lisp/dired-aux.el (dired-do-chmod): * lisp/doc-view.el (doc-view-make-safe-dir): * lisp/emacs-lisp/autoload.el (autoload--save-buffer): * lisp/emacs-lisp/bytecomp.el (byte-compile-file): * lisp/eshell/em-pred.el (eshell-pred-file-mode): * lisp/files.el (backup-buffer-copy, copy-directory): * lisp/gnus/mail-source.el (mail-source-movemail): * lisp/gnus/mm-decode.el (mm-display-external): * lisp/gnus/nnmail.el (nnmail-write-region): * lisp/net/tramp-adb.el (tramp-adb-handle-file-local-copy) (tramp-adb-handle-write-region): * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-directly): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-write-region): * lisp/net/tramp.el (tramp-handle-write-region) (tramp-make-tramp-temp-file): * lisp/server.el (server-ensure-safe-dir): * lisp/url/url-util.el (url-make-private-file): When getting or setting file modes, avoid following symbolic links when the file is not supposed to be a symbolic link. * lisp/doc-view.el (doc-view-make-safe-dir): Omit no-longer-needed separate symlink test. * lisp/gnus/gnus-util.el (gnus-set-file-modes): * lisp/net/tramp.el (tramp-handle-file-modes): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-modes): * src/fileio.c (symlink_nofollow_flag): New function. (Ffile_modes, Fset_file_modes): Support an optional FLAG arg. All C callers changed. * lisp/net/ange-ftp.el (ange-ftp-set-file-modes): * lisp/net/tramp-adb.el (tramp-adb-handle-set-file-modes): * lisp/net/tramp-sh.el (tramp-sh-handle-set-file-modes): * lisp/net/tramp-smb.el (tramp-smb-handle-set-file-modes): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-modes): Accept an optional FLAG arg that is currently ignored, and add a FIXME comment for it. * m4/gnulib-comp.m4: Regenerate.
* Merge from origin/emacs-27Glenn Morris2020-02-201-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | 9f08524748 (origin/emacs-27) Fix broken regexps 1d10885763 ; spelling and comment fix 614203bc80 ; make change-history-commit 28399e585e * Makefile.in (PREFERRED_BRANCH): Now emacs-27. 62afbc513a Fix bug when visiting euc-jp-encoded directories a2c4eeeecd Clarify when fixnums are used. 4e5ac4b0c6 Reorder discussion of integer basics f765aad28b Make OMake support slightly less expensive (bug#39595) 39410cfc5a Speed up 'msft' and 'watcom' compilation error regexps 96a269d045 Speed up 'maven' compilation error message regexp efc9d4fe3e Amend c-backward-sws better to handle multiline block comm...
| * Fix bug when visiting euc-jp-encoded directoriesPaul Eggert2020-02-191-1/+1
| | | | | | | | | | | | | | | | Problem reported by Ken Sasaki (Bug#39672). * src/fileio.c (Ffile_directory_p): Encode filename before giving it to file_directory_p. This fixes a typo introduced in 2019-09-18T02:18:14Z!eggert@cs.ucla.edu.
* | Work better if stat etc. are interruptedPaul Eggert2020-01-201-15/+24
|/ | | | | | | | | | | | | | | | | | | | | 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.
* * src/fileio.c (Fwrite_region): Improve the doc string.Eli Zaretskii2020-01-021-0/+1
|
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Fix insert-file-contents file error regressionPaul Eggert2019-10-311-3/+2
| | | | | | | | Problem reported for dired-view-file (Bug#37950). * src/fileio.c (Finsert_file_contents): When visiting, signal an error if the file could not be opened for any reason, rather than signaling an error only for nonexistent files, fixing a bug introduced in 2019-09-16T03:17:43!eggert@cs.ucla.edu.
* Fix fileio.c infloops on circular listsPaul Eggert2019-10-301-10/+7
| | | | | | | | | | | | | Fix infinite loops in fileio.c when a circular list is the value of after_insert_file_functions, buffer-auto-save-file-format, buffer-file-format, or write-region-annotate-functions. * src/fileio.c (Finsert_file_contents, build_annotations): Use FOR_EACH_TAIL to avoid infloop on circular lists. (build_annotations): Use an EMACS_INT, not an int, to count nesting level. * test/src/fileio-tests.el: (fileio-tests--circular-after-insert-file-functions): New test.
* Fix port of file-acl errno checking to non-GNUPaul Eggert2019-10-061-1/+1
| | | | | | I had misinterpreted the private email from Ashish Shukla. * src/fileio.c (Ffile_acl): Fix typo in previous change by negating the call to acl_errno_valid.
* Port file-acl errno checking to non-GNUPaul Eggert2019-10-061-1/+1
| | | | | | | Problem reported privately for FreeBSD 12 by Ashish Shukla. * src/fileio.c (Ffile_acl): Treat EINVAL etc. like ENOTSUP if acl_get_file fails, to port to FreeBSD 12 and other non-GNU platforms.
* Update some URLsPaul Eggert2019-09-231-1/+1
| | | | | | | | | | | | | | | | | This mostly changes http: to https: in URLs. It also updates some URLs that have moved, removes some URLs that no longer work, recommends against using procmail (procmail.org no longer works), and removes some mentions of the no-longer-existing Gmane, LPF and VTW. It doesn't update all URLs, just the ones I had time for. * GNUmakefile (help): * admin/admin.el (manual-doctype-string): * admin/charsets/Makefile.in (${charsetdir}/ALTERNATIVNYJ.map): * admin/charsets/mapconv: * lisp/net/soap-client.el (soap-create-envelope): * lisp/org/org.el (org-doi-server-url): * lisp/textmodes/bibtex.el (bibtex-generate-url-list): Prefer https: to http: un URLs.
* Revert too-picky file-access testsPaul Eggert2019-09-211-81/+27
| | | | | | | | | | | | | | | | | | | | | | | | | Problem reported by Andreas Schwab (Bug#37475). * doc/lispref/files.texi (Writing to Files) (Testing Accessibility, Kinds of Files): Document that accessibility and file-type predicates return nil if there is trouble determining accessibility or type. * etc/NEWS: Adjust, and list the affected primitives. * src/callproc.c (init_callproc): Go back to Ffile_exists_p. * src/fileio.c (PICKY_EACCES, file_test_errno): Remove. All uses removed. (Ffile_name_case_insensitive_p, Ffile_exists_p, Ffile_symlink_p) (Ffile_directory_p, Ffile_regular_p): Document that these functions return nil if there is trouble. (Ffile_name_case_insensitive_p, check_file_access) (Ffile_writable_p, Ffile_symlink_p, Ffile_directory_p) (Ffile_accessible_directory_p, Ffile_regular_p) * src/lread.c (Fload): Go back to treating trouble in determining the answer as if the file were missing. * src/fileio.c (Ffile_newer_than_file_p): Use file_attribute_errno not file_test_errno, since returning nil is not appropriate when there are two files to test; e.g., in the rare cases where both file timestamps have overflowed then neither t nor nil is correct.
* Default PICKY_ACCESS to false on non-MSPaul Eggert2019-09-191-4/+8
| | | | * src/fileio.c (PICKY_EACCES) [!DOS_NT]: Default to false.
* Out-of-datedness .elc check is merely a file testPaul Eggert2019-09-181-1/+1
| | | | | | | * src/fileio.c (file_test_errno): Now extern. * src/lread.c (Fload): Use file_test_errno instead, since this is really just a file test (the attributes are not given to the user).
* Fix the MS-Windows build broken by recent errno changesEli Zaretskii2019-09-181-1/+4
| | | | | | * src/fileio.c (file_directory_p): If the file exists, but is not a directory, set errno to ENOTDIR, like the Posix branch does; openp expects that.
* Be less picky about EACCES in file test predicatesPaul Eggert2019-09-181-1/+15
| | | | | | | | Problem reported by Tino Calancha (Bug#37445) and others. * src/fileio.c (PICKY_EACCES): New constant, false by default. (file_test_errno): Ignore EACCES if not picky. (check_file_access): Investigate EACCES problems further if picky.
* Improve reporting of I/O, access errorsPaul Eggert2019-09-171-160/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Don’t round file-system-info countsPaul Eggert2019-09-171-7/+9
| | | | | | * src/fileio.c (blocks_to_bytes): Convert the byte count to an integer, since we have bignums now. This avoids possible rounding errors for file systems containing more than 8 PiB or so.
* Fix some file-name-case-insensitive glitchesPaul Eggert2019-09-151-36/+50
| | | | | | | | | | | | | | | | | | * src/fileio.c (file_name_directory): New static function, broken out of Ffile_name_directory. (file_name_case_insensitive_err, Ffile_writable_p, Fdo_auto_save): Use it. (file_name_case_insensitive_err): Rename from file_name_case_insensitive_p. Accept an unencoded Lisp_Object rather than an encoded char *, so that platforms other than Cygwin and macOS need not encode the file name. Return an int -1, 0, errno rather than a bool (setting errno if false), so that the caller can distinguish an error from false. All callers changed. (Ffile_name_case_insensitive_p): Don’t issue system calls on platforms other than Cygwin and macOS. Fix bug that broke the attempt to move up the filesystem tree (it moved up only one level).
* Fix unknown-vs-nonexistent glitch for file timestampsPaul Eggert2019-09-151-1/+1
| | | | | * src/fileio.c (time_error_value): EACCES means the file timestamp is unknown, not that the file does not exist.
* file_name_case_insensitive_p int->long fixPaul Eggert2019-09-141-2/+2
| | | | | * src/fileio.c (file_name_case_insensitive_p): Don’t assume ‘long int’ fits in ‘int’.
* Improve checking of pdump load failuresPaul Eggert2019-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (memory_full): Just report "memory exhausted" if failure occurs during initialization, since fancier recovery schemes are not likely to work when not initialized. * src/emacs.c (dump_error_to_string): Accept int, not enum pdumper_load_result, since the result might not fit in the enum. Use strerror if it was derived from errno. This is for better diagnostics of pdump load failures. (load_pdump_find_executable): Return char *, not enum. 2nd arg is now pointer to buffer size, rather than pointer to pointer to buffer. All callers changed. Use Emacs allocator since they should now be OK even during early startup. Use check_executable instead access, to use effective rather than real permissions. (load_pdump): Return void since callers ignore result. Use int where enum could be too narrow. Use heap rather than stack for possibly-long string. Prefer ptrdiff_t to size_t. * src/fileio.c (check_executable): Now extern. * src/pdumper.c (pdumper_load): Return int that may have errno added to it, for better diagnostics when loads fail.
* Fix recently-introduced file-name-absolute-p typoPaul Eggert2019-07-261-1/+2
| | | | | | | | Fix a bug introduced in 2019-07-24T21:28:13!eggert@cs.ucla.edu. * src/fileio.c (file_name_absolute_p): ~/foo is also absolute (Bug#36809). * test/src/fileio-tests.el (fileio-tests--file-name-absolute-p): Rename from fileio-tests--no-such-user and add more tests.
* Do not treat ~nosuchuser as an absolute file namePaul Eggert2019-07-241-66/+55
| | | | | | | | | | Derived from Ken Brown’s patch (Bug#36502#97). * doc/lispref/files.texi (Relative File Names): * etc/NEWS: Document this. * src/fileio.c (user_homedir): New function. (Fexpand_file_name, file_name_absolute_p): Use it. (search_embedded_absfilename): Simplify via file_name_absolute_p. * test/src/fileio-tests.el (fileio-tests--no-such-user): New test.
* Port double-slash test to z/OSPaul Eggert2019-07-241-12/+10
| | | | | | | | | | * admin/merge-gnulib (GNULIB_MODULES): Add double-slash-root. Emacs was already using this Gnulib module indirectly, so this is merely noting that there is now a direct dependency. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/fileio.c (search_embedded_absfilename): Use DOUBLE_SLASH_IS_DISTINCT_ROOT instead of (WINDOWSNT || CYGWIN). Simplify.
* Fix expand-file-name for names starting with '~'Ken Brown2019-07-211-24/+44
| | | | | | | | | | | * src/fileio.c: (file_name_absolute_no_tilde_p): New static function. (Fexpand_file_name): If the current buffer's default-directory starts with "~user" where "user" is not a valid user name, don't give the '~' a special meaning. Just treat the value of default-directory as a relative name. (Bug#36502) * test/src/fileio-tests.el (fileio-tests--relative-default-directory): Add a test.
* Clarify the expand-file-name doc stringLars Ingebrigtsen2019-07-111-10/+16
| | | | | | * src/fileio.c (Fexpand_file_name): Clarify that "~" in NAME is expanded, and not just "~/". Also clarify that ~USER is not expanded if USER doesn't exist (bug#36490).
* * src/fileio.c: Fix bug#36431Stefan Monnier2019-07-091-30/+89
| | | | | | | | | | | | | (decide_coding_unwind): Re-introduce. Move text back to the gap. Return the new `inserted` via the unwind_data. (Finsert_file_contents): Use it. Make sure `inserted` is always 0 when we jump straight to `notfound`. Don't insert the text in the buffer until we know it's properly decoded for the byteness of the buffer. * test/src/fileio-tests.el (fileio-tests--insert-file-interrupt): Allow insert-file-contents to return an empty buffer in case of non-local exit in set-auto-coding-function.
* Use fewer locks when accessing stdioPaul Eggert2019-07-081-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c, src/bidi.c, src/emacs-module.c, src/pdumper.c: * src/regex-emacs.c, src/unexhp9k800.c, src/unexmacosx.c: * src/widget.c, src/xdisp.c, src/xselect.c, src/xterm.c: Include sysstdio.h instead of stdio.h, to avoid locking stdio streams in many cases. * src/alloc.c (test_setjmp): * src/bidi.c (bidi_dump_cached_states): * src/cm.c (calccost): * src/dispnew.c (init_display_interactive): * src/emacs.c (main): * src/image.c (convert_mono_to_color_image): * src/minibuf.c (read_minibuf_noninteractive): * src/nsfont.m (ns_descriptor_to_entity) (ns_dump_glyphstring): * src/nsterm.h (NSTRACE_MSG_NO_DASHES): * src/nsterm.m (ns_mouse_position) (sendEvent:, keyDown:, performDragOperation:): * src/pdumper.c (dump_fingerprint, print_paths_to_root_1): * src/print.c (debug_print): * src/regex-emacs.c (debug_putchar, print_fastmap) (print_partial_compiled_pattern, print_compiled_pattern) (print_double_string, regex_compile): * src/term.c (vfatal): * src/unexhp9k800.c (read_header): * src/unexmacosx.c (unexec_error): * src/widget.c (EmacsFrameInitialize): * src/xdisp.c (message_to_stderr, vmessage, dump_glyph_row) (Fdump_glyph_matrix, Fdump_frame_glyph_matrix, dump_glyph_string): * src/xfaces.c (Fdump_colors, Fdump_face): * src/xselect.c (x_clipboard_manager_error_2): * src/xterm.c (x_initialize): * src/xwidget.c (WEBKIT_FN_INIT): Prefer unlocked calls like fputs to locked calls like fprintf. * src/charset.c (read_hex): * src/cm.c (cmputc, cmcheckmagic): * src/dispnew.c (update_frame, update_frame_with_menu) (update_frame_1, Fsend_string_to_terminal, Fding) (bitch_at_user): * src/emacs.c (main, Fdump_emacs): * src/emacs-module.c (module_abort): * src/fileio.c (Fdo_auto_save): * src/image.c (slurp_file) (png_read_from_file, png_load_body, our_stdio_fill_input_buffer): * src/keyboard.c (record_char, kbd_buffer_get_event) (handle_interrupt): * src/lread.c (readbyte_from_stdio, read1): * src/minibuf.c (read_minibuf_noninteractive): * src/print.c (printchar_to_stream, strout) (Fredirect_debugging_output): * src/sysdep.c (reset_sys_modes, close_output_streams) (procfs_ttyname, procfs_get_total_memory): * src/term.c (tty_ring_bell, tty_send_additional_strings) (tty_set_terminal_modes, tty_reset_terminal_modes) (tty_update_end, tty_clear_end_of_line, tty_write_glyphs) (tty_write_glyphs_with_face, tty_insert_glyphs) (tty_menu_activate): * src/xfaces.c (Fx_load_color_file): Simplify by using ordinary calls like putc to explicitly-unlocked calls like putc_unlocked, since the ordinary calls are now unlocked anyway. * src/emacs.c (main, Fdump_emacs): * src/pdumper.c (Fdump_emacs_portable): Coalesce adjacent printfs. * src/nsterm.h: Include sysstdio.h as this file’s macros rely on it. * src/regex-emacs.c (print_compiled_pattern): Omit redundant fflush. * src/sysstdio.h: Include unlocked-io.h. (clearerr_unlocked, feof_unlocked, ferror_unlocked) (fflush_unlocked, fgets_unlocked, fputc_unlocked) (fputs_unlocked, fread_unlocked, fwrite_unlocked) (getc_unlocked, getchar_unlocked, putc_unlocked) (putchar_unlocked): Remove these macros; now done by unlocked-io.h. * src/xwidget.c: Include sysstdio.h.
* Ensure that expand-file-name returns an absolute file nameKen Brown2019-07-081-1/+16
| | | | | | | | * src/fileio.c (Fexpand_file_name): Don't directly use the current buffer's default-directory if it is relative. Instead replace it by its expansion relative to invocation-directory. (Bug#36502) * test/src/fileio-tests.el (fileio-tests--relative-default-directory): New test.
* Merge from origin/emacs-26Glenn Morris2019-07-061-1/+1
|\ | | | | | | | | | | | | | | 316f5a3 Fix typo in doc string of file-exists-p (bug#36408) bfc7c6e * test/lisp/url/url-file-tests.el (url-file): Fix for POSIX f... 13b95e1 Fix typo in windows.texi 8b775c3 Clarify & update (elisp) Writing Emacs Primitives 7648c12 Clarify a subtle issue in the Internals chapter of lispref
| * Fix typo in doc string of file-exists-p (bug#36408)Stefan Kangas2019-06-291-1/+1
| | | | | | | | * src/fileio.c (Ffile_exists_p): Fix typo in doc string.
* | (Finsert_file_contents): Keep buffer consistent in non-local exitStefan Monnier2019-07-021-43/+22
| | | | | | | | | | | | | | | | * src/fileio.c (decide_coding_unwind): Delete function. (Finsert_file_contents): Don't let invalid multibyte byte sequences escape when we exit non-locally. * test/src/fileio-tests.el (fileio-tests--insert-file-interrupt): New test.
* | * src/insdel.c (insert_from_gap_1): New fun, extracted from insert_from_gap.Stefan Monnier2019-07-021-11/+1
| | | | | | | | | | | | | | (insert_from_gap): Use it. * src/lisp.h (insert_from_gap_1): Declare it. * src/json.c (Fjson_insert): * src/fileio.c (Finsert_file_contents): Use it.
* | * src/coding.c (decode_coding_gap): Remove `chars` argument.Stefan Monnier2019-07-021-1/+1
| | | | | | | | | | | | * src/json.c (Fjson_insert): * src/fileio.c (Finsert_file_contents): * src/coding.h (decode_coding_gap): Adjust accordingly.
* | Revert O_PATH change to fileio.cPaul Eggert2019-06-281-4/+0
| | | | | | | | | | Ken Brown pointed out it wasn’t needed (Bug#36405#16): * src/fileio.c (O_PATH) [__CYGWIN__]: Remove #undef.
* | Work around Cygwin bug with O_PATHPaul Eggert2019-06-271-0/+4
| | | | | | | | | | Problem reported by Ken Brown (Bug#36405). * src/dired.c, src/fileio.c (O_PATH) [__CYGWIN__]: Undef.
* | Omit a few minor unnecessary range checksPaul Eggert2019-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | Based on Pip Cet’s review (Bug#36370#19). * src/fileio.c (Fdo_auto_save): * src/image.c (lookup_image): * src/textprop.c (Fnext_single_char_property_change): Prefer XFIXNUM to XFIXNAT for clarity and consistency with neighboring code, and to avoid unnecessary range checks. * src/image.c (lookup_image): Omit unnecessary range checks.
* | Clean up use of XFIXNUM etc.Paul Eggert2019-06-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few bits of the code were relying on the fact that XFIXNUM, XFIXNAT, and XUFIXNUM do something even with arguments that are not fixnums/fixnats. Separate these rare uses out into XFIXNUM_RAW and XUFIXNUM_RAW. Problem and original patch reported by Pip Cet (Bug#36370). * src/ccl.c (Fccl_execute_on_string): * src/fileio.c (Finsert_file_contents, a_write) (Fdo_auto_save): * src/process.c (conv_lisp_to_sockaddr): * src/textprop.c (Fnext_single_char_property_change) (Fprevious_single_char_property_change) (Fnext_property_change, Fnext_single_property_change) (Fprevious_property_change) (Fprevious_single_property_change): Don’t assume fixnums are nonnegative. * src/ccl.c (Fccl_execute_on_string): Fix range-checking bug if AREF (status, i) is out of int range. * src/data.c (arith_driver): Use XFIXNUM_RAW as we want efficient garbage if the value is not a fixnum. * src/dosfns.c (Fint86, Fdos_memput): Check that args are nonnegative. * src/image.c (lookup_image): Check that args are in range. * src/lisp.h (lisp_h_XHASH): Use XUFIXNUM_RAW, since this is for hashing. (lisp_h_XFIXNAT, XFIXNAT) [USE_LSB_TAG]: Remove macros. (lisp_h_XFIXNUM_RAW, XFIXNUM_RAW) [USE_LSB_TAG]: New macros, with the semantics of the old macros without _RAW. (XFIXNUM_RAW, XUFIXNUM_RAW): New inline functions, with the semantics of the old functions without _RAW. (FIXNUMP): Move definition up to avoid forward use. (XFIXNUM, XFIXNAT, XUFIXNUM): Use eassume to add a runtime check (when debugging) that the argument has the proper form. (XFIXNUM, XFIXNAT): Now inline functions only, since they refer to their arguments more than once now that they use eassume. * src/textprop.c (Fprevious_single_char_property_change): Avoid fixnum overflow with invalid input. (set_text_properties): Fix unlikely failure to validate arguments, by using EQ instead of XFIXNAT. * src/w32term.c (w32_draw_glyph_string): * src/xterm.c (x_draw_glyph_string): Treat negative minimums as 0 rather than as garbage patterns.
* | Merge from emacs-26Noam Postavsky2019-06-251-5/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Rename 'make-symbolic-link' argument NEWNAME to LINKNAMEJuanma Barranquero2019-06-211-5/+5
| | | | | | | | | | * src/fileio.c (Fmake_symbolic_link): Fix docstring. * doc/lispref/files.texi (Changing Files): Doc fix.
* | Fix an off-by-one error in assertionEli Zaretskii2019-06-221-1/+1
| | | | | | | | | | | | * src/fileio.c (Fexpand_file_name): Fix off-by-one error in an assertion. This avoids assertion violations when the home directory is an empty string for some reason. (Bug#36363)
* | Fix minor ssize_t / ptrdiff_t confusionPaul Eggert2019-06-071-1/+2
| | | | | | | | | | * src/fileio.c (Fcopy_file): This limit is because of ssize_t, so use TYPE_MAXIMUM (ssize_t) not PTRDIFF_MAX.
* | Use copy_file_range to copy filesPaul Eggert2019-06-071-8/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | The copy_file_range syscall (introduced in Linux kernel version 4.5) can copy files more efficiently via server-side copy etc. * admin/merge-gnulib (GNULIB_MODULES): Add copy-file-range. * lib/copy-file-range.c, m4/copy-file-range.m4: New files, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/fileio.c (Fcopy_file): Try copy_file_range first, falling back on read+write only if copy_file_range failed or if the input is empty and so could be a /proc file.
* | Remove fixnum restriction on some display varsPaul Eggert2019-05-221-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a minor patch to remove some fixnum restrictions. Many more such patches are needed, but one thing at a time. * doc/emacs/custom.texi (Examining): Update fill-column example. * src/buffer.c (fill-column, left-margin, tab-width) (buffer-saved-size, left-margin-width, right-margin-width) (left-fringe-width, right-fringe-width, scroll-bar-width) (scroll-bar-height, buffer-display-count): Allow any integer; do not restrict to fixnums. * src/character.h (SANE_TAB_WIDTH): Do not assume tab_width is a nonnegative fixnum. (sanitize_tab_width): Take a Lisp_Object integer, not an EMACS_INT. Only use changed. * src/data.c (store_symval_forwarding): Remove unnecessary SYMBOLP since the predicate (e.g., Qintegerp) is always a symbol (leave the test in as an eassert). Avoid assignments inside if-conditions. * src/fileio.c (Fdo_auto_save): Do not assume buffer-saved-size is a fixnum. Avoid undefined behavior on EMACS_INT overflow by multiplying a fixnum by at most 4, not by at most 13. * src/window.c (set_window_buffer): When buffer-display-count is too large for a fixnum, make it a bignum. * src/xdisp.c (FILL_COLUMN_INDICATOR_NEEDED): Remove macro, ... (fill_column_indicator_column): ... replacing with this new function. All uses changed. The function is a bit pickier, to prevent problems with non-character fixnums and columns out of range for int, and to remove the assumption that integers are in fixnum range. (append_space_for_newline, extend_face_to_end_of_line): Avoid undefined behavior with signed integer overflow. Simplify.
* | Fix misuses of NULL when talking about the NUL characterStefan Monnier2019-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.