1. 18 Sep, 2019 2 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).
      9597ee68
    • 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)
      (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.
      9dc306b1
  2. 14 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Improve gc-cons-percentage calculation · bac66302
      Paul Eggert authored
      The old calculation relied on a hodgpodge of partly updated GC
      stats to find a number to multiply gc-cons-percentage by.
      The new one counts data found by the previous GC, plus half of
      the data allocated since then; this is more systematic albeit
      still ad hoc.
      * src/alloc.c (consing_until_gc, gc_threshold, consing_threshold):
      Now EMACS_INT, not intmax_t.
      (HI_THRESHOLD): New macro.
      (tally_consing): New function.
      (make_interval, allocate_string, allocate_string_data)
      (make_float, free_cons, allocate_vectorlike, Fmake_symbol): Use it.
      (allow_garbage_collection, inhibit_garbage_collection)
      (consing_threshold, garbage_collect):
      Use HI_THRESHOLD rather than INTMAX_MAX.
      (consing_threshold): New arg SINCE_GC.  All callers changed.
      (bump_consing_until_gc): Return new consing_until_gc, instead of
      nil.  All callers changed.  Don’t worry about overflow since we
      now saturate at HI_THRESHOLD.  Guess that half of
      recently-allocated objects are still alive, instead of relying on
      the previous (even less-accurate) hodgepodge.
      (maybe_garbage_collect): New function.
      (garbage_collect): Work even if a finalizer disables or enables
      memory profiling.  Do not use malloc_probe if GC reclaimed nothing.
      * src/lisp.h (maybe_gc): Call maybe_garbage_collect instead
      of garbage_collect.
      bac66302
  3. 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
      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.
      5fafa40d
  4. 24 Aug, 2019 1 commit
    • Paul Eggert's avatar
      extern function cleanup · b62eac0f
      Paul Eggert authored
      Most of these functions can be static.  A few are unused.
      * src/coding.c (encode_string_utf_8, decode_string_utf_8):
      Define only if ENABLE_UTF_8_CONVERTER_TEST, as they're
      not needed otherwise.
      * src/coding.c (encode_string_utf_8, decode_string_utf_8):
      * src/data.c (integer_mod):
      * src/fns.c (base64_encode_region_1, base64_encode_string_1):
      * src/ftfont.c (ftfont_get_fc_charset):
      Now static.
      * src/sysdep.c (verrprintf): Remove; unused.
      b62eac0f
  5. 22 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Fix clrhash bug when hash table needs rehashing · ceebf3ef
      Paul Eggert authored
      Problem reported by Pip Cet in:
      https://lists.gnu.org/r/emacs-devel/2019-08/msg00316.html
      * src/fns.c (maybe_resize_hash_table): Prefer ASET to gc_aset
      where either will do.  Simplify appending of Qunbound values.
      Put index_size calculation closer to where it’s needed.
      (hash_clear): If hash_rehash_needed_p (h), don’t clear the
      nonexistent hash vector.  Use memclear to speed up clearing.
      * src/lisp.h (HASH_TABLE_SIZE): Check that the size is positive,
      and tell that to the compiler.
      ceebf3ef
  6. 15 Aug, 2019 2 commits
    • Paul Eggert's avatar
      Fix typeof portability issue with bitfields · 96ef76e4
      Paul Eggert authored
      Problem reported by Glenn Morris in:
      https://lists.gnu.org/r/emacs-devel/2019-08/msg00300.html
      * src/lisp.h (lisp_h_make_fixnum): Use typeof (+(n)) instead
      of typeof (n), so that it works with compilers that do
      not allow typeof to be applied to a bitfield.
      96ef76e4
    • Paul Eggert's avatar
      Debug out-of-range make_fixnum args · 3548fd8a
      Paul Eggert authored
      With --enable-checking, make_fixnum (N) now checks that N is
      in fixnum range.  Suggested by Pip Cet in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00548.html
      A new function make_ufixnum (N) is for the rare cases where N
      is intended to be unsigned and is in the range 0..INTMASK.
      * configure.ac (AC_C_TYPEOF): Add.
      (HAVE_STATEMENT_EXPRESSIONS): Resurrect this macro.
      * src/fns.c (Frandom, hashfn_eq, hashfn_equal, hashfn_user_defined):
      * src/profiler.c (hashfn_profiler):
      Use make_ufixnum rather than make_fixum, since the argument is
      an unsigned integer in the range 0..INTMASK rather than a signed
      integer in the range MOST_NEGATIVE_FIXNUM..MOST_POSITIVE_FIXNUM.
      Typically this is for hashes.
      * src/lisp.h (lisp_h_make_fixnum_wrap) [USE_LSB_TAG]:
      Rename from lisp_h_make_fixnum.
      (lisp_h_make_fixnum): Redefine in terms of lisp_h_make_fixnum_wrap.
      Check for fixnum overflow on compilers like GCC that
      have statement expressions and typeof.
      (FIXNUM_OVERFLOW_P): Move up.
      (make_fixnum): Check for fixnum overflow.
      (make_ufixnum): New function, which checks that the arg
      fits into 0..INTMASK range.
      3548fd8a
  7. 13 Aug, 2019 2 commits
    • Paul Eggert's avatar
      Let consing_until_gc exceed EMACS_INT_MAX · b80559be
      Paul Eggert authored
      This builds on the previous patch.
      * src/alloc.c (consing_until_gc): Now of type intmax_t,
      since gc-cons-threshold can be up to INTMAX_MAX.  All uses changed.
      * src/lisp.h (CONSING_CT_MAX, consing_ct): Remove.
      b80559be
    • Paul Eggert's avatar
      Let consing_until_gc exceed INTPTR_MAX · a354736e
      Paul Eggert authored
      Suggested by Eli Zaretskii (Bug#37006#46).
      * src/alloc.c (consing_until_gc): Now of type consing_ct.
      All uses changed, so gc-cons-threshold no longer saturates
      against OBJECT_CT_MAX.
      (object_ct): Move typedef here from lisp.h.
      * src/lisp.h (consing_ct, CONSING_CT_MAX): New type and macro.
      (OBJECT_CT_MAX): Remove.  Replace all uses with CONSING_CT_MAX.
      a354736e
  8. 06 Aug, 2019 1 commit
    • Paul Eggert's avatar
      decode-time now returns subsec too · b06917a4
      Paul Eggert authored
      The list that decode-time returns now contains an extra
      trailing component that counts the subseconds part of the
      original timestamp (Bug#36549).
      This builds on a suggestion by Lars Ingebrigtsen in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00734.html
      * doc/lispref/os.texi (Time Conversion):
      * doc/misc/emacs-mime.texi (time-date):
      * etc/NEWS: Document this.
      * lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
      * lisp/calendar/iso8601.el (iso8601-parse)
      (iso8601-parse-time, iso8601-parse-duration)
      (iso8601--decoded-time):
      * lisp/calendar/parse-time.el (parse-time-string):
      * lisp/calendar/time-date.el (make-decoded-time)
      (decoded-time-set-defaults):
      * lisp/org/org.el (org-fix-decoded-time)
      (org-parse-time-string):
      * src/timefns.c (Fdecode_time):
      Generate subsec member for decoded time.
      * lisp/calendar/time-date.el (decoded-time-add)
      Add the decoded subsec too.
      * lisp/simple.el (decoded-time): New subsec member.
      * src/data.c (Frem): Simplify zero-check to match that of new Fmod.
      (integer_mod): New function, with most of the guts of the old Fmod.
      Remove redundant zero-check.
      (Fmod): Use it.
      * src/timefns.c (Fencode_time): Handle new subsec member
      or (with the obsolescent calling convention) subsec arg.
      It defaults to 0.
      * test/lisp/calendar/icalendar-tests.el:
      (icalendar--decode-isodatetime):
      * test/lisp/calendar/iso8601-tests.el (test-iso8601-date-years)
      (test-iso8601-date-dates, test-iso8601-date-obsolete)
      (test-iso8601-date-weeks, test-iso8601-date-ordinals)
      (test-iso8601-time, test-iso8601-combined)
      (test-iso8601-duration, test-iso8601-intervals)
      (standard-test-dates, standard-test-time-of-day-fractions)
      (standard-test-time-of-day-beginning-of-day)
      (standard-test-time-of-day-utc)
      (standard-test-time-of-day-zone)
      (standard-test-date-and-time-of-day, standard-test-interval):
      * test/lisp/calendar/parse-time-tests.el (parse-time-tests):
      * test/src/timefns-tests.el (format-time-string-with-zone)
      (encode-time-dst-numeric-zone):
      Adjust to match new behavior.
      b06917a4
  9. 26 Jul, 2019 2 commits
    • Stefan Monnier's avatar
      Don't dump the `hash` vector if it will need to be recomputed anyway · 0dc5a85a
      Stefan Monnier authored
      * src/fns.c (hash_table_rehash): Only set `hash` field at the end.
      (sweep_weak_table): Only set slot of `hash` vector when that vector exists.
      (Fhash_table_count): No need to hash_rehash_if_needed any more.
      
      * src/lisp.h (hash_rehash_needed_p): Test the presence of `hash` instead.
      
      * src/pdumper.c (check_hash_table_rehash, dump_hash_table):
      Set `hash` to nil to indicate that the table needs to be rehashed.
      0dc5a85a
    • Stefan Monnier's avatar
      * src/fns.c: Use `EQ (key, Qunbound)` to check if a slot is in use · c74da403
      Stefan Monnier authored
      (make_hash_table): Use Qunbound for the key_and_value table.
      (maybe_resize_hash_table): Set new key_and_value slots to Qunbound.
      (hash_table_rehash): Don't bother copying the old table of hashes since
      we're recomputing it completely.
      (hash_table_rehash): Use hash_rehash_needed_p more.
      (hash_put): Add assertion that the slot was indeed considered empty.
      (hash_remove_from_table, hash_clear, sweep_weak_table): Set empty
      slot's key to Qunbound.
      (Fmaphash): Use `EQ (key, Qunbound)` to check if a slot is in use.
      
      * src/lisp.h (struct Lisp_Hash_Table): Update comments.
      c74da403
  10. 23 Jul, 2019 2 commits
    • Paul Eggert's avatar
      Merge pdumper.c and alloc.c builtin symbol tests · a48726eb
      Paul Eggert authored
      * src/alloc.c (c_symbol_p): Move from here ...
      * src/lisp.h (c_symbol_p): ... to here, and make it more portable
      to hypothetical platforms where pointers are wider than ptrdiff_t.
      * src/pdumper.c (dump_builtin_symbol_p): Use c_symbol_p.
      a48726eb
    • Paul Eggert's avatar
      Do not pdump user-defined hashtabs · 3f4a9a5a
      Paul Eggert authored
      * src/pdumper.c (dump_hash_table_stable_p):
      Signal an error if a hash table has user-defined tests (Bug#36769).
      * src/fns.c (hashfn_user_defined): Now extern.
      3f4a9a5a
  11. 21 Jul, 2019 5 commits
    • Paul Eggert's avatar
      Fix lifetime error in previous patch · 5d4dd552
      Paul Eggert authored
      Problem reported by Pip Cet in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00520.html
      * src/alloc.c (inhibit_garbage_collection): Use new function.
      (allow_garbage_collection): Accept intmax_t, not pointer.
      * src/eval.c (default_toplevel_binding, do_one_unbind)
      (backtrace_eval_unrewind, Fbacktrace__locals, mark_specpdl):
      Support SPECPDL_UNWIND_INTMAX.
      (record_unwind_protect_excursion): New function.
      * src/lisp.h (enum specbind_tag): New constant SPECPDL_UNWIND_INTMAX.
      (union specbinding): New member unwind_intmax.
      5d4dd552
    • Paul Eggert's avatar
      Fix crash if user test munges hash table · 515afc9c
      Paul Eggert authored
      * src/fns.c (restore_mutability)
      (hash_table_user_defined_call): New functions.
      (cmpfn_user_defined, hashfn_user_defined): Use them.
      (make_hash_table, copy_hash_table):
      Mark new hash table as mutable.
      (check_mutable_hash_table): New function.
      (Fclrhash, Fputhash, Fremhash): Use it instead of CHECK_IMPURE.
      * src/lisp.h (struct hash_table_test): User-defined functions
      now take pointers to struct Lisp_Hash_Table, not to struct
      hash_table_test.  All uses changed.
      (struct Lisp_Hash_Table): New member ‘mutable’.
      * src/pdumper.c (dump_hash_table): Copy it.
      * test/src/fns-tests.el (test-hash-function-that-mutates-hash-table):
      New test, which tests for the bug.
      515afc9c
    • Paul Eggert's avatar
      Simplify hashfn/cmpfn calling convention · b6f194a0
      Paul Eggert authored
      * src/fns.c (cmpfn_eql, cmpfn_equal, cmpfn_user_defined)
      (hashfn_eq, hashfn_equal, hashfn_eql, hashfn_user_defined):
      * src/profiler.c (cmpfn_profiler, hashfn_profiler):
      Use new calling convention where the return value is a fixnum
      instead of EMACS_UINT.  While we’re at it, put the hash table
      at the end, since that’s a bit simpler and generates better
      code (at least on the x86-64).  All callers changed.
      * src/fns.c (hash_lookup): Store fixnum rather than EMACS_UINT.
      All callers changed.
      (hash_put): Take a fixnum rather than an EMACS_UINT.
      All callers changed.  Remove unnecessary eassert (XUFIXNUM does it).
      * src/lisp.h (struct hash_table_test):
      Adjust signatures of cmpfn and hashfn.
      b6f194a0
    • Paul Eggert's avatar
      Simplify maybe_gc implementation · 26de2d42
      Paul Eggert authored
      * src/alloc.c (consing_until_gc): New variable, replacing the
      combination of consing_since_gc and gc_relative_threshold.
      All uses changed.
      (byte_ct): Move decl here from lisp.h.
      (memory_full_cons_threshold): New an enum constant.
      (free_cons): Check for integer overflow in
      statistics calculation.
      * src/lisp.h (object_ct): Move decl here from alloc.c.
      (OBJECT_CT_MAX): New macro.
      (maybe_gc): Simplify accordingly.
      26de2d42
    • Paul Eggert's avatar
      Rename ‘pure’ to ‘purecopy’ · df5024db
      Paul Eggert authored
      * src/lisp.h (struct Lisp_Hash_Table): Rename ‘pure’ member to
      ‘purecopy’, as the old name was quite confusing (it did not
      mean the hash table was pure).  All uses changed.
      df5024db
  12. 14 Jul, 2019 1 commit
  13. 13 Jul, 2019 2 commits
    • Paul Eggert's avatar
      Avoid interleaving stderr in dump_fingerprint · 1178f98f
      Paul Eggert authored
      * src/fns.c (hexbuf_digest): New function, containing most of
      the old make_digest_string.
      (make_digest_string): Use it.
      * src/pdumper.c (dump_fingerprint): Rewrite to use a single
      fprintf call, to avoid interleaving on GNU/Linux.
      1178f98f
    • Paul Eggert's avatar
      Replace Vdead with tagged pointer · 04cbdde9
      Paul Eggert authored
      This speeds up ‘make compile-always’ by 0.1% on my platform.
      Suggested by Pip Cet in:
      https://lists.gnu.org/r/emacs-devel/2019-07/msg00257.html
      * src/.gdbinit (pwinx, pgx, xbuffer, xprintstr):
      Output dead_object () as "DEAD".
      * src/alloc.c (Vdead, DEADP): Remove.
      All uses replaced by dead_object () / deadp.
      (deadp): New function.
      (init_alloc_once_for_pdumper): Remove no-longer-needed
      initialization.
      * src/lisp.h (dead_object): New function.
      04cbdde9
  14. 12 Jul, 2019 1 commit
    • Paul Eggert's avatar
      Avoid duplicate comparison in describe_map_compare · 77a4cc9f
      Paul Eggert authored
      * src/fns.c (string_version_cmp): New function.
      This has most of the old Fstring_version_lessp,
      with an assertion to make things a bit clearer.
      * src/fns.c (Fstring_version_lessp):
      * src/keymap.c (describe_map_compare): Use it (Bug#33237).
      77a4cc9f
  15. 09 Jul, 2019 1 commit
    • Paul Eggert's avatar
      Do not alter match data in Fcapitalize etc. · 412139f1
      Paul Eggert authored
      Without this patch, (capitalize "x") can alter the match data,
      which is not what users expect.  Problem found by running
      morse-tests-unnato-region in a stripped-down Emacs.
      Perhaps ‘load’ should also save and restore the match data?
      That would be a simpler fix, though arguably incompatible.
      * src/lread.c (save_match_data_load): New function.
      * src/chartab.c (uniprop_table):
      * src/doc.c (reread_doc_file):
      * src/eval.c (Fautoload_do_load):
      * src/fns.c (Frequire): Use it.
      412139f1
  16. 07 Jul, 2019 1 commit
    • Paul Eggert's avatar
      Remove printmax_t etc. · 8f522efe
      Paul Eggert authored
      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.
      8f522efe
  17. 02 Jul, 2019 1 commit
  18. 27 Jun, 2019 2 commits
    • Paul Eggert's avatar
      Improve XFIXNUM cleanup a bit · f59a3f3d
      Paul Eggert authored
      Based on Pip Cet’s review (Bug#36370#13).
      * src/ccl.c (Fccl_execute_on_string): Use clearer indexing.
      * src/dosfns.c (Fint86, Fdos_memput):
      Avoid runtime checks for negative fixnums when debugging.
      This restores the earlier machine code.
      * src/lisp.h (XFIXNUM, XUFIXNUM): Use eassert, not eassume.
      (XFIXNAT): At the start, merely eassert FIXNUMP rather
      than eassuming FIXNATP.  At the end, eassume that the
      result is nonnegative.  This restores help to the compiler
      that the previous patch mistakenly removed.
      f59a3f3d
    • 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
      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.
      4893a09c
  19. 10 Jun, 2019 1 commit
  20. 07 Jun, 2019 1 commit
  21. 31 May, 2019 1 commit
    • Eli Zaretskii's avatar
      Add HarfBuzz font backend for MS-Windows · fba3687d
      Eli Zaretskii authored
      * src/w32uniscribe.c [HAVE_HARFBUZZ]: Include math.h and
      hb.h.
      (bswap_32): Define for GCC 4.3.0 and later; else include
      <byteswap.h> from Gnulib.
      (struct uniscribe_font_info): Extend for HarfBuzz; 'cache' is
      now a 'void *' (all users changed).
      [HAVE_HARFBUZZ]: Define typedefs for HarfBuzz functions to be
      loaded dynamically from the HarfBuzz DLL.  Define macros to
      call those functions via function pointers.
      (uniscribe_open) [HAVE_HARFBUZZ]: Use the HarfBuzz font driver
      if the type of the font entity is 'harfbuzz'.
      (uniscribe_close) [HAVE_HARFBUZZ]: For fonts using the
      HarfBuzz backend, call hb_font_destroy to free memory used for
      the cached hb_font data.
      (uniscribe_shape): Fix assignment of character codepoints to
      glyphs from a single cluster.
      (w32hb_list, w32hb_match, free_cb, w32hb_get_font_table)
      (w32hb_get_font, w32hb_encode_char, w32hb_begin_font)
      (w32uni_combining, w32uni_general, w32uni_mirroring)
      (get_hb_unicode_funcs, w32hb_shape)
      (w32hb_combining_capability, load_harfbuzz_funcs)
      [HAVE_HARFBUZZ]: New functions.
      (syms_of_w32uniscribe_for_pdumper) [HAVE_HARFBUZZ]: Load the
      HarfBuzz DLL and register the HarfBuzz backend with its
      functions.
      * src/w32font.c (syms_of_w32font) <Qharfbuzz>: New DEFSYM.
      * src/w32fns.c (Fx_create_frame, w32_create_tip_frame)
      [HAVE_HARFBUZZ]: Register the harfbuzz font backend.
      * src/lisp.h (get_unicode_property): Declare prototype.
      * src/font.h (harfbuzz_font_driver) [HAVE_NTGUI]: Declare.
      * src/chartab.c (get_unicode_property): New function, body
      taken from get-unicode-property-internal.
      (Fget_unicode_property_internal): Call get_unicode_property
      after validating input.
      
      * doc/lispref/frames.texi (Font and Color Parameters):
      * doc/emacs/msdos.texi (Windows Fonts): Document support for
      HarfBuzz text shaping on MS-Windows.
      
      * configure.ac (HAVE_HARFBUZZ): Move out of the X-specific
      part, and consider HarfBuzz also for HAVE_W32 systems.
      Require HarfBuzz v1.2.3 for w32.
      fba3687d
  22. 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.
      Simplify.
      dfed333b
  23. 18 May, 2019 1 commit
    • Paul Eggert's avatar
      Clean up and simplify image-type setup · 41bf8653
      Paul Eggert authored
      This also fixes an unlikely hang involving a circular image
      description.
      * src/dispextern.h (struct image.type): Now pointer-to-const.
      * src/image.c (struct image_type.init) [!WINDOWSNT]: Omit.
      (IMAGE_TYPE_INIT): New macro.
      (image_types): Now a small array-of-const, not a pointer.
      (CACHE_IMAGE_TYPE): Remove; the code’s simpler without it.
      (ADD_IMAGE_TYPE): Remove this macro, replacing with ...
      (add_image_type): ... this equivalent function.  All uses changed.
      (define_image_type): Remove.  All uses removed.
      (valid_image_p): Use FOR_EACH_TAIL_SAFE to avoid Emacs hanging
      if the user creates a circular description of an image.
      (xbm_type, xpm_type, pbm_type, png_type, jpeg_type, tiff_type)
      (gif_type, imagemagick_type, svg_type, gs_type):
      Remove; now done by image_types.
      (init_imagemagick_functions): Remove decl of nonexistent function.
      (gs_clear_image): Remove; all uses replaced by image_clear_image.
      (initialize_image_type): New function, which captures a lot
      of the previously-scattered WINDOWSNT ifdefs.
      (lookup_image_type): Use it.
      (reset_image_types): Remove.  All uses removed.
      (syms_of_image): Don’t worry about ignoring image_types for
      pdumper, since it’s a constant now.
      41bf8653
  24. 06 May, 2019 2 commits
    • Eli Zaretskii's avatar
      f77bd2b4
    • Paul Eggert's avatar
      Use simpler way to print function pointers · 926a3949
      Paul Eggert authored
      The module code can’t possibly work on weird platforms where
      function pointers are wider than data pointers, so there’s no need
      to bother with the stackoverflow-like approach that is intended
      only for portability to such platforms.  Besides, the
      stackoverflow-like approach does not work well on weird platforms
      where CHAR_BIT is not a multiple of 4.
      * src/lisp.h (pMx): New macro.
      * src/print.c (data_from_funcptr) [HAVE_MODULES]: New function.
      (print_vectorlike) [HAVE_MODULES]: Use it.
      (print_object): Make sure buf is big enough for this.
      926a3949
  25. 26 Apr, 2019 1 commit
    • Alexander Gramiak's avatar
      Rename generic x_* identifiers · a411517f
      Alexander Gramiak authored
      * src/image.c: Rename x_* procedures to image_*.
      
      * src/frame.c: Rename x_* procedures to gui_*. Rename
      xrdb_get_resource to gui_display_get_resource. Rename x_get_arg to
      gui_display_get arg.
      
      * src/frame.h: Rename can_x_set_window_size to can_set_window_size.
      
      * src/xfaces.c: Rename realize_x_face to realize_gui_face. Rename
      x_supports_face_attributes_p to gui_supports_face_attributes_p.
      
      * src/keyboard.c:
      * src/lisp.h:
      * src/nsterm.m:
      * src/w32term.c:
      * src/xterm.c: Rename x_get_keysym_name to get_keysym_name.
      
      * src/nsfns.c:
      * src/nsterm.m: Rename x_* procedures to ns_*.
      
      * src/w32fns.c:
      * src/w32term.c: Rename x_* procedures to w32_*.
      
      * src/termhooks.h (query_colors, get_focus_frame, focus_frame_hook)
      (frame_visible_invisible_hook, iconify_frame_hook)
      (set_window_size_hook, set_frame_offset_hook, set_frame_alpha_hook)
      (set_new_font_hook, set_bitmap_icon_hook, implicit_set_name_hook)
      (activate_menubar_hook, change_tool_bar_height_hook)
      (set_scroll_bar_default_width_hook)
      (set_scroll_bar_default_height_hook, get_string_resource_hook): New
      terminal hooks to replace backend-specific x_* procedures.
      
      * src/dispextern.h (clear_under_internal_border): New RIF procedure.
      
      * src/alloc.c:
      * src/frame.c:
      * src/xdisp.c: Use FRAME_OUTPUT_DATA instead of FRAME_X_OUTPUT.
      
      * src/frame.c:
      * src/w32term.c:
      * src/w32fns.c: Use FRAME_NATIVE_WINDOW instead of FRAME_X_WINDOW.
      a411517f
  26. 25 Apr, 2019 1 commit
    • Paul Eggert's avatar
      Port to Oracle Developer Studio 12.6 · 69947311
      Paul Eggert authored
      This compiler is a bit pickier about checking conformance to
      the C standard, ranging from syntax trivia (no extra ";" at
      the top level) to portability trivia (warnings re conversion
      between function and data pointers) to more-important stuff
      like lack of support for some __attribute__ usages.
      * src/dynlib.c (dynlib_addr): First argument is a function
      pointer, not a data pointer.  All callers changed.
      * src/emacs-module.c (module_function_address):
      Return module_funcptr, not void *.  All uses changed.
      * src/lisp.h (module_funcptr) [HAVE_MODULES]: New type.
      * src/lread.c (union ieee754_double): Don’t assume the usual
      semantics for converting signed to unsigned int when initializing
      a bitfield, as the Oracle compiler complains and the C standard
      is unclear.
      * src/pdumper.c (ALLOW_IMPLICIT_CONVERSION): Make it clearer
      that -Wsign-conversion is disabled everywhere in this file.
      (dump_trace, dump_tailq_prepend, dump_tailq_append):
      Don’t assume __attribute__.
      (dump_object_self_representing_p): Don’t disable conversion
      warnings; it’s not needed here.
      (DEFINE_FROMLISP_FUNC): Avoid possible signal in integer
      conversion from unsigned to signed.
      (DEFINE_FROMLISP_FUNC, finish_dump_pvec): Avoid warning about
      unreachable statements on platforms not supporting the
      __attribute__.
      (intmax_t_from_lisp, intmax_t_to_lisp, dump_off_from_lisp)
      (dump_off_to_lisp, dump_emacs_reloc_immediate_lv)
      (dump_emacs_reloc_immediate_ptrdiff_t)
      (dump_emacs_reloc_immediate_intmax_t)
      (dump_emacs_reloc_immediate_int, dump_emacs_reloc_immediate_bool):
      Omit stray semicolon that violates C standard.
      (dump_metadata_for_pdumper): Add cast to pacify compiler complaining
      about conversion from function pointer to data pointer.
      (Fdump_emacs_portable): Do not use CALLN to call a function
      with zero arguments, as C99 prohibits empty initializers.
      * src/xdisp.c (syms_of_xdisp): Do not nest calls to pure_list,
      to work around a bug in Oracle Developer Studio 12.6.
      69947311
  27. 24 Apr, 2019 2 commits
    • Philipp Stephani's avatar
      Move definition of Lisp_Module_Function to emacs-module.c. · d2e1bac4
      Philipp Stephani authored
      * src/lisp.h: Remove include of emacs-module.h.  Remove definition
      of Lisp_Module_Function structure.
      
      * src/emacs-module.c (module_function_documentation)
      (module_function_address): New accessor functions for module function
      fields.
      (emacs_subr, struct Lisp_Module_Function): Move from lisp.h.
      
      * src/print.c (print_vectorlike):
      * src/doc.c (Fdocumentation): Use the new accessor functions.
      d2e1bac4
    • Paul Eggert's avatar
      Simplify thread initialization and GC · 4c90369d
      Paul Eggert authored
      * src/lisp.h (PVECHEADERSIZE): New macro.
      (XSETPVECTYPESIZE): Use it.
      * src/search.c (syms_of_search): No need to initialize or
      staticpro last_thing_searched or saved_last_thing_searched, as
      the thread code arranges for initialization and GC.
      * src/thread.c (main_thread): Initialize statically.
      (Fmake_mutex, Fmake_condition_variable, Fmake_thread):
      Use ALLOCATE_ZEROED_PSEUDOVECTOR rather than zeroing by hand.
      (mark_one_thread): No need to mark Lisp_Object members.
      (init_main_thread, init_threads_once): Remove.  All uses removed.
      4c90369d