1. 08 Sep, 2017 2 commits
    • Eli Zaretskii's avatar
      Fix 'directory-file-name' on DOS_NT systems as well · e2a10d7f
      Eli Zaretskii authored
      * src/fileio.c (directory_file_name) [DOS_NT]: Fix the DOS_NT case
      to be consistent with last change.
      
      * test/src/fileio-tests.el (fileio-tests--odd-symlink-chars):
      Disable on MS-Windows.
      (fileio-tests--directory-file-name-dos-nt)
      (fileio-tests--file-name-as-directory-dos-nt): New tests.
      e2a10d7f
    • Paul Eggert's avatar
      Fix bug: (directory-file-name "///") returned "//" · aedc566a
      Paul Eggert authored
      * src/fileio.c (directory_file_name): For "///" and longer,
      return "/", not "//", as per POSIX.
      * test/src/fileio-tests.el (fileio-tests--directory-file-name)
      (fileio-tests--file-name-as-directory): New tests.
      aedc566a
  2. 02 Sep, 2017 1 commit
    • Philipp Stephani's avatar
      Improve error messages for improper plists (Bug#27726) · 71766a45
      Philipp Stephani authored
      * src/fns.c (Fplist_put, Flax_plist_get, Flax_plist_put)
      (Fplist_member, syms_of_fns): Use ‘plistp’ as pseudo-predicate for
      improper plists instead of ‘listp.’
      
      * test/src/fns-tests.el (plist-get/odd-number-of-elements)
      (lax-plist-get/odd-number-of-elements)
      (plist-put/odd-number-of-elements)
      (lax-plist-put/odd-number-of-elements)
      (plist-member/improper-list): Add unit tests.
      71766a45
  3. 27 Aug, 2017 1 commit
    • Paul Eggert's avatar
      Do not munge contents of local symbolic links · e8001d4c
      Paul Eggert authored
      This lets Emacs deal with arbitrary local symlinks without
      mishandling their contents (Bug#28156).  For example,
      (progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x"))
      now consistently creates a symbolic link from '/tmp/x' to '~'.
      Formerly, it did that only if the working directory was on the
      same filesystem as /tmp; otherwise, it expanded the '~' to
      the user's home directory.
      * lisp/dired.el (dired-get-filename): Use files--name-absolute-system-p
      instead of rolling our own code.
      * lisp/files.el (files--name-absolute-system-p): New function.
      (file-truename, file-chase-links): Use it to avoid mishandling
      symlink contents that begin with ~.
      (copy-directory, move-file-to-trash):
      Use concat rather than expand-file-name, to avoid mishandling
      symlink contents that begin with ~.
      * src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the
      target unless interactive.  Strip leading "/:" if interactive.
      (emacs_readlinkat): Do not prepend "/:" to the link target if
      it starts with "/" and contains ":" before NUL.
      * test/src/fileio-tests.el (try-link): Rename from try-char,
      and accept a string instead of a char.  All uses changed.
      (fileio-tests--symlink-failure): Also test leading ~, and "/:",
      to test the new behavior.
      e8001d4c
  4. 20 Aug, 2017 2 commits
    • Paul Eggert's avatar
      Change recent symlink tests to just test ASCII · 1b8d0fe4
      Paul Eggert authored
      * test/src/fileio-tests.el (fileio-tests--symlink-failure):
      Be less ambitious about testing non-ASCII chars and encoding
      errors, as there are too many portability issues.
      1b8d0fe4
    • Paul Eggert's avatar
      Don’t adjust CRLF in file names · 83f0d60e
      Paul Eggert authored
      * doc/misc/gnus.texi (Non-ASCII Group Names):
      * etc/NEWS:
      * test/lisp/net/tramp-tests.el (tramp--test-utf8):
      Use utf-8-unix, not utf-8, for default-file-name-coding-system, so
      that CRLF in file names is left alone.
      * lisp/international/mule-cmds.el (set-default-coding-systems):
      Do not alter CRLF in file name coding systems.
      (prefer-coding-system): Ignore differences in CRLF processing when
      checking whether we used the user-specified file name coding system.
      * test/src/fileio-tests.el: New file.
      83f0d60e
  5. 09 Aug, 2017 1 commit
    • Eli Zaretskii's avatar
      Fix crashing emacs-module tests on MS-Windows · 7fc27ea7
      Eli Zaretskii authored
      * src/w32fns.c (syms_of_w32fns) <w32-disable-abort-dialog>: New
      variable.
      (emacs_abort): If w32-disable-abort-dialog is non-nil, abort right
      away, without displaying the Abort dialog, which waits for the user.
      
      * test/src/emacs-module-tests.el (module--test-assertion): Run the
      inferior Emacs with the w32 abort dialog disabled.  Expect the
      status of the aborted Emacs sub-process to be 3 on MS-Windows and
      2 on MS-DOS.
      7fc27ea7
  6. 06 Aug, 2017 1 commit
    • Paul Eggert's avatar
      Fix some crashes on self-modifying Elisp code · 93511e94
      Paul Eggert authored
      Prompted by a problem report by Alex in:
      http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00143.html
      * src/eval.c (For, Fprogn, Fsetq, FletX, eval_sub):
      Compute XCDR (x) near XCAR (x); although this doesn't fix any bugs,
      it is likely to run a bit faster with typical hardware caches.
      (Fif): Use Fcdr instead of XCDR, to avoid crashing on
      self-modifying S-expressions.
      (Fsetq, Flet, eval_sub): Count the number of arguments as we go
      instead of trusting an Flength prepass, to avoid problems when the
      code is self-modifying.
      (Fquote, Ffunction, Fdefvar, Fdefconst): Prefer !NILP to CONSP
      where either will do.  This is mostly to document the fact that
      the value must be a proper list.  It's also a tiny bit faster on
      typical machines nowadays.
      (Fdefconst, FletX): Prefer XCAR+XCDR to Fcar+Fcdr when either will do.
      (eval_sub): Check that the args are a list as opposed to some
      other object that has a length. This prevents e.g. (if . "string")
      from making Emacs dump core in some cases.
      * test/src/eval-tests.el (eval-tests--if-dot-string)
      (eval-tests--let-with-circular-defs, eval-tests--mutating-cond):
      New tests.
      93511e94
  7. 05 Aug, 2017 1 commit
    • Eli Zaretskii's avatar
      Fix a bug in 'generate-new-buffer-name' · 885c5126
      Eli Zaretskii authored
      * src/buffer.c (Fgenerate_new_buffer_name): Test IGNORE for being
      nil before calling string-equal, since the latter will compare
      "nil and 'nil' as equal.  (Bug#27966)
      
      * test/src/buffer-tests.el
      (test-generate-new-buffer-name-bug27966): New test.
      885c5126
  8. 22 Jul, 2017 1 commit
  9. 11 Jul, 2017 1 commit
    • NicolasPetton's avatar
      Add an optional testfn parameter to assoc · 0bece6c6
      NicolasPetton authored
      * src/fns.c (assoc): New optional testfn parameter used for comparison
      when provided.
      * test/src/fns-tests.el (test-assoc-testfn): Add tests for the new
      'testfn' parameter.
      * src/buffer.c:
      * src/coding.c:
      * src/dbusbind.c:
      * src/font.c:
      * src/fontset.c:
      * src/gfilenotify.c:
      * src/image.c:
      * src/keymap.c:
      * src/process.c:
      * src/w32fns.c:
      * src/w32font.c:
      * src/w32notify.c:
      * src/w32term.c:
      * src/xdisp.c:
      * src/xfont.c: Add a third argument to Fassoc calls.
      * etc/NEWS:
      * doc/lispref/lists.texi: Document the new 'testfn' parameter.
      0bece6c6
  10. 09 Jul, 2017 2 commits
    • Glenn Morris's avatar
      Fix failing module tests on GNU/Linux · 273f4bde
      Glenn Morris authored
      * test/src/emacs-module-tests.el
      (module--test-assertions--load-non-live-object)
      (module--test-assertions--call-emacs-from-gc):
      Avoid test failures due to backtraces.
      273f4bde
    • Paul Eggert's avatar
      Fix core dump in substitute-object-in-subtree · 083940a9
      Paul Eggert authored
      Without this fix, (substitute-object-in-subtree #0=(#0# 'a) 'a)
      would dump core, since the C code would recurse indefinitely through
      the infinite structure.  This patch adds an argument to the function,
      and renames it to lread--substitute-object-in-subtree as the function
      is not general-purpose and should not be relied on by outside code.
      See Bug#23660.
      * src/intervals.c (traverse_intervals_noorder): ARG is now void *,
      not Lisp_Object, so that callers need not cons unnecessarily.
      All callers changed.  Also, remove related #if-0 code that was
      “temporary” in the early 1990s and has not been compilable for
      some time.
      * src/lread.c (struct subst): New type, for substitution closure data.
      (seen_list): Remove this static var, as this info is now part of
      struct subst.  All uses removed.
      (Flread__substitute_object_in_subtree): Rename from
      Fsubstitute_object_in_subtree, and give it a 3rd arg so that it
      doesn’t dump core when called from the top level with an
      already-cyclic structure.  All callers changed.
      (SUBSTITUTE): Remove.  All callers expanded and then simplified.
      (substitute_object_recurse): Take a single argument SUBST rather
      than a pair OBJECT and PLACEHOLDER, so that its address can be
      passed around as part of a closure; this avoids the need for an
      AUTO_CONS call.  All callers changed.  If the COMPLETED component
      is t, treat every subobject as potentially circular.
      (substitute_in_interval): Take a struct subst * rather than a
      Lisp_Object, for the closure data.  All callers changed.
      * test/src/lread-tests.el (lread-lread--substitute-object-in-subtree):
      New test, to check that the core dump does not reoccur.
      083940a9
  11. 08 Jul, 2017 1 commit
    • Philipp Stephani's avatar
      Module assertions: check for garbage collections · b7dab24b
      Philipp Stephani authored
      It's technically possible to write a user pointer finalizer that calls
      into Emacs module functions.  This would be disastrous because it
      would allow arbitrary Lisp code to run during garbage collection.
      Therefore extend the module assertions to check for this case.
      
      * src/emacs-module.c (module_assert_thread): Also check whether a
      garbage collection is in progress.
      
      * test/data/emacs-module/mod-test.c (invalid_finalizer)
      (Fmod_test_invalid_finalizer): New test module functions.
      (emacs_module_init): Register new test function.
      
      * test/src/emacs-module-tests.el (module--test-assertion)
      (module--with-temp-directory): New helper macros.
      (module--test-assertions--load-non-live-object): Rename existing
      unit test, use helper macros.
      (module--test-assertions--call-emacs-from-gc): New unit test.
      b7dab24b
  12. 17 Jun, 2017 2 commits
    • Philipp Stephani's avatar
      Add command to replace buffer contents · d682f0da
      Philipp Stephani authored
      Add a new command 'replace-buffer-contents' that uses the Myers diff
      algorithm to non-destructively replace the accessible portion of the
      current buffer.  The Myers algorithm is implemented in Gnulib.
      
      * src/editfns.c (Freplace_buffer_contents): New command.
      (set_bit, bit_is_set, buffer_chars_equal): New helper functions.
      (syms_of_editfns): Define new command.
      
      * test/src/editfns-tests.el (replace-buffer-contents-1)
      (replace-buffer-contents-2): New unit tests.
      
      * src/buffer.h (BUF_FETCH_CHAR_AS_MULTIBYTE): New helper macro.
      
      * admin/merge-gnulib (GNULIB_MODULES): Add diffseq.h and minmax.h.
      d682f0da
    • Dmitry Gutov's avatar
      Add test for the fix in the parent commit · 32b0f153
      Dmitry Gutov authored
      * test/src/undo-tests.el (undo-test-skip-invalidated-markers):
      New test, for the fix in the parent commit.
      32b0f153
  13. 12 Jun, 2017 4 commits
    • Glenn Morris's avatar
      Give a more informative failure in module assertion test · 73b50a10
      Glenn Morris authored
      * test/src/emacs-module-tests.el (module--test-assertions):
      Rephrase final check to give a more informative failure.
      73b50a10
    • Glenn Morris's avatar
      Clean up after module assertion tests · ab2116c9
      Glenn Morris authored
      * test/src/emacs-module-tests.el (module--test-assertions):
      Use a temporary directory to contain any core dumps.
      ab2116c9
    • Glenn Morris's avatar
      Small improvement for module assertion test · 1612d3dd
      Glenn Morris authored
      * test/src/emacs-module-tests.el (module--test-assertions):
      Don't rely on the precise form of an "Abort" message.
      1612d3dd
    • Philipp Stephani's avatar
      Implement module assertions for users · cf971327
      Philipp Stephani authored
      Add a new command-line option '-module-assertions' that users can
      enable developing or debugging a module.  If this option is present,
      Emacs performs additional checks to verify that modules fulfill their
      requirements.  These checks are expensive and crash Emacs if modules
      are invalid, so disable them by default.
      
      This is a command-line option instead of an ordinary variable because
      changing it while Emacs is running would cause data structure
      imbalances.
      
      * src/emacs.c (main): New command line option '-module-assertions'.
      
      * src/emacs-module.c (module_assert_main_thread)
      (module_assert_runtime, module_assert_env, module_assert_value):
      New functions to assert module requirements.
      (syms_of_module): New uninterned variable 'module-runtimes'.
      (init_module_assertions, in_main_thread, module_abort): New helper
      functions.
      (initialize_environment): Initialize value list.  If assertions are
      enabled, use a heap-allocated environment object.
      (finalize_environment): Add assertion that environment list is never
      empty.
      (finalize_runtime_unwind): Pop module runtime object stack.
      (value_to_lisp): Assert that the value is valid.
      (lisp_to_value): Record new value if assertions are enabled.
      (mark_modules): Mark allocated object list.
      (MODULE_FUNCTION_BEGIN_NO_CATCH)
      (module_non_local_exit_check, module_non_local_exit_clear)
      (module_non_local_exit_get, module_non_local_exit_signal)
      (module_non_local_exit_throw): Assert thread and environment.
      (module_get_environment): Assert thread and runtime.
      (module_make_function, module_funcall, module_intern)
      (module_funcall, module_make_integer, module_make_float)
      (module_make_string, module_make_user_ptr, module_vec_get)
      (funcall_module, Fmodule_load): Adapt callers.
      (module_make_global_ref): If assertions are enabled, use the global
      environment to store global values.
      (module_free_global_ref): Remove value from global value list.
      
      * test/Makefile.in (EMACSOPT): Enable module assertions when testing
      modules.
      
      * test/data/emacs-module/mod-test.c (Fmod_test_invalid_store)
      (Fmod_test_invalid_load): New functions to test module assertions.
      (emacs_module_init): Bind the new functions.
      
      * test/src/emacs-module-tests.el (mod-test-emacs): New constant for
      the Emacs binary file.
      (mod-test-file): New constant for the test module file name.
      (module--test-assertions): New unit test.
      cf971327
  14. 04 Jun, 2017 1 commit
    • Philipp Stephani's avatar
      Rework printing of module functions · 3b0080de
      Philipp Stephani authored
      Fix a FIXME in emacs-module.c.  Put the printing into print.c, like
      other types.
      
      * src/print.c (print_vectorlike): Add code to print module functions.
      
      * src/emacs-module.c (funcall_module): Stop calling
      'module_format_fun_env'.  Now that module functions are first-class
      objects, they can be added to signal data directly.
      (module_handle_signal): Remove now-unused function
      'module_format_fun_env'.
      
      * test/src/emacs-module-tests.el (mod-test-sum-test): Adapt unit test.
      
      * src/eval.c (funcall_lambda): Adapt call to changed signature of
      'funcall_module'.
      3b0080de
  15. 03 Jun, 2017 1 commit
    • Philipp Stephani's avatar
      Fix a bug when using format field numbers · 7d413cb4
      Philipp Stephani authored
      Previously styled_format overwrite the argument vector.  This is no
      longer possible because there might be more than one specification per
      argument.  Use the existing auxiliary info array instead.
      
      * src/editfns.c (styled_format): Record arguments in the info
      structure instead of overwriting them.
      * test/src/editfns-tests.el (format-with-field): Add unit test.
      7d413cb4
  16. 01 Jun, 2017 4 commits
    • Paul Eggert's avatar
      Limit format fields to more POSIX-like spec · 8de2581a
      Paul Eggert authored
      * doc/lispref/strings.texi (Formatting Strings):
      Don’t allow mixing numbered with unnumbered format specs.
      * src/editfns.c (styled_format): Don’t bother checking for field 0,
      since it doesn’t crash and the behavior is not specified.
      * test/src/editfns-tests.el (format-with-field): Adjust tests to
      match current doc.  Add more tests for out-of-range fields.
      8de2581a
    • Paul Eggert's avatar
      Minor improvements to format field numbers · 53247108
      Paul Eggert authored
      * src/editfns.c (styled_format): Allow field numbers in a %% spec.
      No need for a special diagnostic for field numbers greater than
      PTRDIFF_MAX.  Reword diagnostic for field 0.
      * test/src/editfns-tests.el (format-with-field): Adjust to match.
      53247108
    • Philipp Stephani's avatar
      Implement field numbers in format strings · 0dd1bbb0
      Philipp Stephani authored
      A field number explicitly specifies the argument to be formatted.
      This is especially important for potential localization work, since
      grammars of various languages dictate different word orders.
      
      * src/editfns.c (Fformat): Update documentation.
      (styled_format): Implement field numbers.
      
      * doc/lispref/strings.texi (Formatting Strings): Document field numbers.
      
      * lisp/emacs-lisp/bytecomp.el (byte-compile-format-warn): Adapt.
      
      * test/src/editfns-tests.el (format-with-field): New unit test.
      0dd1bbb0
    • Glenn Morris's avatar
      Quieten compilation of some test files · afcbec61
      Glenn Morris authored
      * test/lisp/dired-tests.el (dired-test-bug25609): Mark unused args.
      * test/src/data-tests.el (binding-test-set-constant-t)
      (binding-test-set-constant-nil, binding-test-set-constant-keyword)
      (binding-test-set-constant-nil): Silence compiler.
      * test/src/regex-tests.el (regex-tests-BOOST): Escape char literal.
      afcbec61
  17. 23 May, 2017 1 commit
  18. 20 May, 2017 1 commit
    • Philipp Stephani's avatar
      Reimplement module functions · 31fded03
      Philipp Stephani authored
      Instead of a lambda, create a new type containing all data required to
      call the function, and support it in the evaluator.  Because this type
      now also needs to store the function documentation, it is too big for
      Lisp_Misc; use a pseudovector instead.  That also has the nice benefit
      that we don't have to add special support to the garbage collector.
      
      Since the new type is user-visible, give it a predicate.
      
      Now we can easily support 'help-function-args' and 'func-arity'; add
      unit tests for these.
      
      * src/lisp.h (allocate_module_function, MODULE_FUNCTIONP)
      (XMODULE_FUNCTION): New pseudovector type 'module function'.
      
      * src/eval.c (FUNCTIONP): Also treat module functions as functions.
      (funcall_lambda, Ffuncall, eval_sub): Add support for calling module
      functions.
      (Ffunc_arity): Add support for detecting the arity of module
      functions.
      
      * src/emacs-module.c (module_make_function): Adapt to new structure.
      Return module function object directly instead of wrapping it in a
      lambda; remove FIXME.
      (funcall_module): New function to call module functions.  Replaces
      `internal--module-call' and is called directly from eval.c.
      (syms_of_module): Remove internal helper function, which is no longer
      needed.
      (module_function_arity): New helper function.
      
      * src/data.c (Ftype_of): Adapt to new implementation.
      (Fmodule_function_p, syms_of_data): New user-visible function.  Now
      that module functions are first-class objects, they deserve a
      predicate.  Define it even if not compiled with --enable-modules so
      that Lisp code doesn't have to check for the function's existence.
      
      * src/doc.c (Fdocumentation): Support module functions.
      
      * src/print.c (print_object): Adapt to new implementation.
      
      * src/alloc.c (mark_object): Specialized garbage collector support is
      no longer needed.
      
      * lisp/help.el (help-function-arglist): Support module functions.
      While there, simplify the arity calculation by using `func-arity',
      which does the right thing for all kinds of functions.
      
      * test/data/emacs-module/mod-test.c: Amend docstring so we can test
      the argument list.
      
      * test/src/emacs-module-tests.el (mod-test-sum-docstring): Adapt to
      new docstring.
      (mod-test-non-local-exit-signal-test): Because `internal--module-call'
      is gone, the backtrace has changed and no longer leaks the
      implementation.
      (module--func-arity): New test for `func-arity'.
      (module--help-function-arglist): New test for `help-function-arglist'.
      31fded03
  19. 19 May, 2017 1 commit
    • Philipp Stephani's avatar
      Fix module tests on some systems · 45944e01
      Philipp Stephani authored
      If dladdr(3) isn't available or didn't work, the printed
      representation of a module function will not include the file name,
      but only the address.  Make the tests pass in that case.
      
      * test/src/emacs-module-tests.el (module-function-object): Fix match for
      module function printed representation
      45944e01
  20. 13 May, 2017 2 commits
    • Philipp's avatar
      Make `old-style-backquotes' variable internal · a1d46159
      Philipp authored
      * src/lread.c (load_warn_old_style_backquotes, Fload, read1)
      (syms_of_lread): Rename `old-style-backquotes' to
      `lread--old-style-backquotes', and clarify that it's for internal
      use only.
      * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Rename
      variable.
      * test/src/lread-tests.el (lread-tests--old-style-backquotes): Add
      unit test.
      * emacs-lisp/bytecomp-tests.el
      (bytecomp-tests--old-style-backquotes): Add unit test.
      a1d46159
    • Philipp Stephani's avatar
      Improve unescaped character literal warnings · 16004397
      Philipp Stephani authored
      * src/lread.c (load_warn_unescaped_character_literals)
      (syms_of_lread):
      lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Improve
      formatting of unescaped character literal warnings.
      
      * test/src/lread-tests.el (lread-tests--unescaped-char-literals):
      test/lisp/emacs-lisp/bytecomp-tests.el
      (bytecomp-tests--unescaped-char-literals): Adapt unit tests.
      16004397
  21. 10 May, 2017 2 commits
    • Glenn Morris's avatar
      Fix finding test .el files · 48e6e9a9
      Glenn Morris authored
      * test/Makefile.in (ELFILES): Exclude the data/ directory.
      * test/src/lread-tests.el (lread-test-bug26837): Revert previous.
      48e6e9a9
    • Tino Calancha's avatar
      Tweak a recent test · 4f391b9d
      Tino Calancha authored
      This test fails in my local machine because the data files
      are compiled, and the test doesn't expect that.
      * test/src/lread-tests.el (lread-test-bug26837): Match a suffix
      ending with '.elc' when the data files are compiled.
      4f391b9d
  22. 09 May, 2017 1 commit
    • Glenn Morris's avatar
      Put re-loaded file back at start of load-history (bug#26837) · db30296b
      Glenn Morris authored
      * src/lread.c (readevalloop): Fix the "whole buffer" check to
      operate in the correct buffer.
      (Feval_buffer): Move point back to the start after checking
      for lexical binding.
      * test/src/lread-tests.el (lread-test-bug26837): New test.
      * test/data/somelib.el, test/data/somelib2.el: New test data files.
      db30296b
  23. 06 May, 2017 3 commits
    • Eli Zaretskii's avatar
      ; Fix last change · b104d764
      Eli Zaretskii authored
      * test/src/emacs-module-tests.el (module-function-object): Fix thinko
      in last change.
      b104d764
    • Eli Zaretskii's avatar
      Fix last change for MS-Windows · 89b5a828
      Eli Zaretskii authored
      * test/src/emacs-module-tests.el (module-function-object): Port to
      MS-Windows.
      89b5a828
    • Philipp Stephani's avatar
      Introduce new misc type for module function · a3e96940
      Philipp Stephani authored
      This resolves a couple of FIXMEs in emacs-module.c.
      
      * src/lisp.h (MODULE_FUNCTIONP, XMODULE_FUNCTION): New functions.
      
      * src/alloc.c (make_module_function): New function.
      (mark_object): GC support.
      
      * src/data.c (Ftype_of, syms_of_data): Handle module function type.
      
      * src/print.c (print_object): Print support for new type.
      
      * src/emacs-module.c (module_make_function, Finternal_module_call):
      Use new module function type, remove FIXMEs.
      (module_format_fun_env): Adapt and give it external linkage.
      
      * test/src/emacs-module-tests.el (module-function-object): Add unit
      test.
      a3e96940
  24. 01 May, 2017 3 commits