1. 07 Oct, 2019 1 commit
  2. 06 Oct, 2019 1 commit
    • Paul Eggert's avatar
      Port file-acl errno checking to non-GNU · 8ad41af3
      Paul Eggert authored
      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
  3. 23 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Update some URLs · 946a56a1
      Paul Eggert authored
      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.
  4. 21 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Revert too-picky file-access tests · d49d6ea9
      Paul Eggert authored
      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.
  5. 19 Sep, 2019 1 commit
  6. 18 Sep, 2019 4 commits
    • Paul Eggert's avatar
      Out-of-datedness .elc check is merely a file test · 9597ee68
      Paul Eggert authored
      * 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).
    • Eli Zaretskii's avatar
      Fix the MS-Windows build broken by recent errno changes · 7ff2eef9
      Eli Zaretskii authored
      * 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.
    • Paul Eggert's avatar
      Be less picky about EACCES in file test predicates · 735940f4
      Paul Eggert authored
      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.
    • Paul Eggert's avatar
      Improve reporting of I/O, access errors · 9dc306b1
      Paul Eggert authored
      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)
      * 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.
  7. 17 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Don’t round file-system-info counts · c108d8ec
      Paul Eggert authored
      * 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.
  8. 16 Sep, 2019 2 commits
    • Paul Eggert's avatar
      Fix some file-name-case-insensitive glitches · be828883
      Paul Eggert authored
      * 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
    • Paul Eggert's avatar
      Fix unknown-vs-nonexistent glitch for file timestamps · ba060577
      Paul Eggert authored
      * src/fileio.c (time_error_value): EACCES means the file
      timestamp is unknown, not that the file does not exist.
  9. 15 Sep, 2019 1 commit
  10. 11 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Improve checking of pdump load failures · 5fafa40d
      Paul Eggert authored
      * 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
      * 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.
  11. 07 Sep, 2019 1 commit
  12. 06 Sep, 2019 1 commit
    • Paul Eggert's avatar
      file-truename now uses realpath for local files · a59839d7
      Paul Eggert authored
      This uses fewer syscalls on GNU/Linux and other GNUish platforms.
      * lisp/files.el (file-truename): Try fileio--truename
      if there are no handlers.
      * src/fileio.c: Include stdlib.h, for realpath.
      (Ffileio__truename): New function.
  13. 26 Jul, 2019 1 commit
    • Paul Eggert's avatar
      Fix recently-introduced file-name-absolute-p typo · e3575ee4
      Paul Eggert authored
      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.
  14. 24 Jul, 2019 2 commits
    • Paul Eggert's avatar
      Do not treat ~nosuchuser as an absolute file name · a5063aa8
      Paul Eggert authored
      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.
    • Paul Eggert's avatar
      Port double-slash test to z/OS · 50126f20
      Paul Eggert authored
      * 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):
  15. 21 Jul, 2019 1 commit
    • Ken Brown's avatar
      Fix expand-file-name for names starting with '~' · 8b13ec1d
      Ken Brown authored
      * 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.
  16. 11 Jul, 2019 1 commit
  17. 09 Jul, 2019 2 commits
    • Stefan Monnier's avatar
      * src/fileio.c: Fix bug#36431 · fec111c9
      Stefan Monnier authored
      (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.
    • Paul Eggert's avatar
      Use fewer locks when accessing stdio · f8ab9083
      Paul Eggert authored
      * 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)
      * 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_he...
  18. 08 Jul, 2019 1 commit
    • Ken Brown's avatar
      Ensure that expand-file-name returns an absolute file name · 0528a7c8
      Ken Brown authored
      * 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.
  19. 02 Jul, 2019 3 commits
  20. 29 Jun, 2019 2 commits
  21. 27 Jun, 2019 3 commits
    • Paul Eggert's avatar
      Work around Cygwin bug with O_PATH · 4f2b2559
      Paul Eggert authored
      Problem reported by Ken Brown (Bug#36405).
      * src/dired.c, src/fileio.c (O_PATH) [__CYGWIN__]: Undef.
    • Paul Eggert's avatar
      Omit a few minor unnecessary range checks · 06d2eb33
      Paul Eggert authored
      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.
    • Paul Eggert's avatar
      Clean up use of XFIXNUM etc. · 4893a09c
      Paul Eggert authored
      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
      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)
      * src/process.c (conv_lisp_to_sockaddr):
      * src/textprop.c (Fnext_single_char_property_change)
      (Fnext_property_change, Fnext_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.
  22. 22 Jun, 2019 1 commit
    • Eli Zaretskii's avatar
      Fix an off-by-one error in assertion · d79fe1f7
      Eli Zaretskii authored
      * 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)
  23. 21 Jun, 2019 1 commit
  24. 07 Jun, 2019 2 commits
    • Paul Eggert's avatar
      Fix minor ssize_t / ptrdiff_t confusion · 8553af84
      Paul Eggert authored
      * src/fileio.c (Fcopy_file): This limit is because of ssize_t,
      so use TYPE_MAXIMUM (ssize_t) not PTRDIFF_MAX.
    • Paul Eggert's avatar
      Use copy_file_range to copy files · 486a81f3
      Paul Eggert authored
      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.
  25. 22 May, 2019 1 commit
    • Paul Eggert's avatar
      Remove fixnum restriction on some display vars · dfed333b
      Paul Eggert authored
      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.
  26. 22 Mar, 2019 1 commit
    • Stefan Monnier's avatar
      Fix misuses of NULL when talking about the NUL character · 76fea1eb
      Stefan Monnier authored
      * 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
      * src/w16select.c (get_clipboard_data): null_char => nul_char.
      * src/json.c (check_string_without_embedded_nuls): Rename from
      (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.
  27. 18 Mar, 2019 1 commit
  28. 27 Feb, 2019 1 commit
    • Paul Eggert's avatar
      DEFVAR_INT variables are now intmax_t · e828765d
      Paul Eggert authored
      Formerly they were fixnums, which led to problems when dealing
      with values that might not fit on 32-bit platforms, such as
      string-chars-consed or floats_consed.  64-bit counters should
      be good enough for these (for a while, anyway...).
      While we’re at it, fix some unlikely integer overflow bugs
      that have been in the code for a while.
      * lib-src/make-docfile.c (write_globals):
      * src/data.c (do_symval_forwarding, store_symval_forwarding):
      * src/eval.c (restore_stack_limits, call_debugger):
      * src/frame.h (struct frame.cost_calculation_baud_rate):
      * src/keyboard.c (last_auto_save, bind_polling_period, read_char):
      * src/lisp.h (struct Lisp_Intfwd.intvar):
      * src/lread.c (defvar_int):
      * src/pdumper.c (dump_fwd_int):
      * src/thread.h (struct thread_state.m_lisp_eval_depth):
      * src/undo.c (truncate_undo_list):
      * src/xselect.c (wait_for_property_change)
      * src/xterm.c (x_emacs_to_x_modifiers):
      DEFVAR_INT variables now have the C type intmax_t, not EMACS_INT.
      * src/data.c (store_symval_forwarding):
      * src/gnutls.c (Fgnutls_boot):
      * src/keyboard.c (bind_polling_period):
      * src/macros.c (pop_kbd_macro, Fexecute_kbd_macro):
      * src/undo.c (truncate_undo_list):
      Allow any integer that fits into intmax_t, instead of
      requiring it to be a Lisp fixnum.
      * src/dispnew.c (update_window):
      * src/frame.c (x_figure_window_size):
      * src/gnutls.c (init_gnutls_functions)
      * src/keyboard.c (make_lisp_event):
      * src/nsterm.m (ns_dumpglyphs_image):
      * src/profiler.c (make_log):
      * src/scroll.c (calculate_scrolling)
      * src/termcap.c (tputs):
      * src/xterm.c (x_draw_image_relief):
      Avoid implementation-defined behavior on conversion of
      out-of-range integers.
      * src/eval.c (when_entered_debugger): Now intmax_t.
      (max_ensure_room): New function, that avoids signed integer overflow.
      (call_debugger, signal_or_quit): Use it.
      * src/fileio.c (Fdo_auto_save):
      * src/keyboard.c (make_lisp_event):
      * src/term.c (calculate_costs):
      * src/xdisp.c (build_desired_tool_bar_string)
      (hscroll_window_tree, try_scrolling, decode_mode_spec)
      Avoid signed integer overflow.
      * src/lisp.h (clip_to_bounds): Generalize to intmax_t.
      * src/pdumper.c (dump_emacs_reloc_immediate_emacs_int): Remove, ...
      (dump_emacs_reloc_immediate_intmax_t): ... replacing with this
      function.  All uses changed.
      * src/profiler.c (make_log): Omit args.  All callers changed.
      * src/termcap.c: Include stdlib.h, for atoi.
      Include intprops.h.
      * src/window.c (sanitize_next_screen_context_lines): New function.
      (window_scroll_pixel_based, window_scroll_line_based):
      Use it to avoid signed integer overflow.