1. 11 Aug, 2020 2 commits
    • Paul Eggert's avatar
      23c1d5df
    • Pip Cet's avatar
      Rehash hash tables eagerly after loading a dump · 16a16645
      Pip Cet authored
      This simplifies code, and helps performance in some cases (Bug#36597).
      * src/lisp.h (hash_rehash_needed_p): Remove.  All uses removed.
      (hash_rehash_if_needed): Remove.  All uses removed.
      (struct Lisp_Hash_Table): Remove comment about rehashing hash tables.
      * src/pdumper.c (thaw_hash_tables): New function.
      (hash_table_thaw): New function.
      (hash_table_freeze): New function.
      (dump_hash_table): Simplify.
      (dump_hash_table_list): New function.
      (hash_table_contents): New function.
      (Fdump_emacs_portable): Handle hash tables by eager rehashing.
      (pdumper_load): Restore hash tables.
      (init_pdumper_once): New function.
      16a16645
  2. 08 Jul, 2020 1 commit
  3. 28 Jun, 2020 1 commit
    • Eli Zaretskii's avatar
      MS-Windows fixes as followup to import of Gnulib 'getrandom' · 162f375b
      Eli Zaretskii authored
      * nt/mingw-cfg.site (gl_cv_lib_assume_bcrypt): Set to "no" to
      disable linking against bcrypt.dll.  (Bug#42095)
      
      * src/gnutls.c (gnutls_rnd) [WINDOWSNT]: Don't define a function
      pointer, and don't load it from GnuTLS DLL.
      (w32_gnutls_rnd) [WINDOWSNT]: Delete unused function.
      * src/fns.c (gnutls_rnd) [WINDOWSNT]: Don't redirect to
      w32_gnutls_rnd.
      162f375b
  4. 27 Jun, 2020 1 commit
    • Paul Eggert's avatar
      Use getrandom syscall for nonces · 5ce5cf64
      Paul Eggert authored
      * admin/merge-gnulib (GNULIB_MODULES): Add getrandom.
      * doc/lispref/text.texi (Format of GnuTLS Cryptography Inputs):
      Don’t say that iv-auto uses GNUTLS_RND_NONCE.  Also, don’t say
      that it returns the IV’s actual value, as it never has done that.
      * src/fns.c, src/sysdep.c: Include sys/random.h, for getrandom.
      * src/fns.c (Fsecure_hash_algorithms): Use getrandom so that this
      function does not depend on HAVE_GNUTLS3.
      * src/sysdep.c: Do not include <gnutls/crypto.h>.
      (random_seed) [HAVE_LRAND48]: Can be long int now.
      (init_random) [!WINDOWSNT]: Use getrandom syscall instead
      of opening /dev/urandom, as this works even on GNU/Linux
      hosts that lack /dev/urandom.  Don’t bother with gnutls_rnd
      as it’s not needed now that we have getrandom.
      5ce5cf64
  5. 19 May, 2020 1 commit
    • Paul Eggert's avatar
      Reject attempts to clear pure strings · c5eafccc
      Paul Eggert authored
      * src/fns.c (Ffillarray, Fclear_string):
      Add CHECK_IMPURE here, to be consistent with Faset etc.
      (Ffillarray): Prefer memset when the fill is a single byte.
      c5eafccc
  6. 12 May, 2020 1 commit
    • Paul Eggert's avatar
      Pacify GCC 10.1.0 · 4645430b
      Paul Eggert authored
      Pacify GCC 10.1.0 so that it does not issue false alarms
      when Emacs is configured with --enable-gcc-warnings.
      * src/dispnew.c (clear_glyph_row):
      * src/fns.c (hash_clear):
      * src/keyboard.c (append_tab_bar_item):
      * src/lisp.h (vcopy):
      * src/xfaces.c (get_lface_attributes_no_remap)
      (Finternal_copy_lisp_face, realize_default_face):
      * src/xmenu.c (set_frame_menubar):
      Work around -Warray-bounds false alarm in GCC 10.1.0.
      * src/intervals.c (copy_properties):
      Avoid -Wnull-dereference false alarm in GCC 10.1.0.
      * src/lisp.h (xvector_contents_addr, xvector_contents):
      New functions, useful for working around GCC bug 95072.
      4645430b
  7. 29 Apr, 2020 1 commit
  8. 17 Apr, 2020 3 commits
    • Paul Eggert's avatar
      Port recent character.h changes to --with-wide-int · 2cb7e866
      Paul Eggert authored
      * src/fns.c (mapcar1):
      * src/keymap.c (Fkey_description):
      * src/syntax.c (scan_lists):
      Prefer ptrdiff_t to EMACS_INT where either will do; this fixes
      newly-introduced type errors on --with-wide-int platforms where
      ptrdiff_t is narrower than EMACS_INT.
      * src/keymap.c (Fkey_description): Rework for clarity; remove goto.
      * src/syntax.c (scan_words, Fforward_comment, scan_lists)):
      Fix unlikely integer overflow problems that can occur on
      --with-wide-int platforms, and that were caught by the recent
      character.h changes.
      2cb7e866
    • Paul Eggert's avatar
      Prefer more inline functions in character.h · 27d10183
      Paul Eggert authored
      * src/buffer.h (fetch_char_advance, fetch_char_advance_no_check)
      (buf_next_char_len, next_char_len, buf_prev_char_len)
      (prev_char_len, inc_both, dec_both): New inline functions,
      replacing the old character.h macros FETCH_CHAR_ADVANCE,
      FETCH_CHAR_ADVANCE_NO_CHECK, BUF_INC_POS, INC_POS, BUF_DEC_POS,
      DEC_POS, INC_BOTH, DEC_BOTH respectively.  All callers changed.
      These new functions all assume buffer primitives and so need
      to be here rather than in character.h.
      * src/casefiddle.c (make_char_unibyte): New static function,
      replacing the old MAKE_CHAR_UNIBYTE macro.  All callers changed.
      (do_casify_unibyte_string): Use SINGLE_BYTE_CHAR_P instead
      of open-coding it.
      * src/ccl.c (GET_TRANSLATION_TABLE): New static function,
      replacing the old macro of the same name.
      * src/character.c (string_char): Omit 2nd arg.  3rd arg can no
      longer be NULL.  All callers changed.
      * src/character.h (SINGLE_BYTE_CHAR_P): Move up.
      (MAKE_CHAR_UNIBYTE, MAKE_CHAR_MULTIBYTE, PREV_CHAR_BOUNDARY)
      (STRING_CHAR_AND_LENGTH, STRING_CHAR_ADVANCE)
      (FETCH_STRING_CHAR_ADVANCE)
      (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE)
      (FETCH_STRING_CHAR_ADVANCE_NO_CHECK, FETCH_CHAR_ADVANCE)
      (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, INC_BOTH)
      (DEC_BOTH, BUF_INC_POS, BUF_DEC_POS): Remove.
      (make_char_multibyte): New static function, replacing
      the old macro MAKE_CHAR_MULTIBYTE.  All callers changed.
      (CHAR_STRING_ADVANCE): Remove; all callers changed to use
      CHAR_STRING.
      (NEXT_CHAR_BOUNDARY): Remove; it was unused.
      (raw_prev_char_len): New inline function, replacing the
      old PREV_CHAR_BOUNDARY macro.  All callers changed.
      (string_char_and_length): New inline function, replacing the
      old STRING_CHAR_AND_LENGTH macro.  All callers changed.
      (STRING_CHAR): Rewrite in terms of string_char_and_length.
      (string_char_advance): New inline function, replacing the old
      STRING_CHAR_ADVANCE macro.  All callers changed.
      (fetch_string_char_advance): New inline function, replacing the
      old FETCH_STRING_CHAR_ADVANCE macro.  All callers changed.
      (fetch_string_char_as_multibyte_advance): New inline function,
      replacing the old FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE macro.
      All callers changed.
      (fetch_string_char_advance_no_check): New inline function,
      replacing the old FETCH_STRING_CHAR_ADVANCE_NO_CHECK macro.  All
      callers changed.
      * src/regex-emacs.c (HEAD_ADDR_VSTRING): Remove; no longer used.
      * src/syntax.c (scan_lists): Use dec_bytepos instead of
      open-coding it.
      * src/xdisp.c (string_char_and_length): Rename from
      string_char_and_length to avoid name conflict with new function in
      character.h.  All callers changed.
      27d10183
    • Paul Eggert's avatar
      Prefer inline functions in character.h · 3e46a231
      Paul Eggert authored
      In character.h, replace macros with inline functions or enums
      when this is easy.  This improves maintainability and
      on my platform (Fedora 31 x86-64, gcc -O2) improved CPU
      performance very slightly (0.3%) on ‘make compile-always’.
      * src/buffer.h (SANE_TAB_WIDTH, CHARACTER_WIDTH):
      Move here from character.h, and make them inline functions.
      Tune CHARACTER_WIDTH so that ASCII_CHAR_WIDTH is no longer needed.
      (sanitize_tab_width, sanitize_char_width):
      Move here from character.h.
      * src/character.h (MAX_CHAR, MAX_UNICODE_CHAR, MAX_1_BYTE_CHAR)
      (MAX_2_BYTE_CHAR, MAX_3_BYTE_CHAR, MAX_4_BYTE_CHAR)
      (MAX_5_BYTE_CHAR, MIN_MULTIBYTE_LEADING_CODE)
      (MAX_MULTIBYTE_LEADING_CODE, MAX_MULTIBYTE_LENGTH):
      Now enum constants instead of macros.
      * src/character.h (CHAR_BYTES): Redo to avoid conditional branches.
      (CHAR_BYTE8_P, BYTE8_TO_CHAR, UNIBYTE_TO_CHAR, CHAR_TO_BYTE8)
      (CHAR_TO_BYTE_SAFE, CHAR_BYTE8_HEAD_P, CHARACTERP)
      (CHECK_CHARACTER, CHECK_CHARACTER_CAR, CHECK_CHARACTER_CDR)
      (CHAR_PRINTABLE_P, CHAR_BYTES, CHAR_LEADING_CODE, BYTE8_STRING)
      (LEADING_CODE_P, TRAILING_CODE_P, CHAR_HEAD_P)
      (BYTES_BY_CHAR_HEAD):
      Now inline functions instead of macros.
      (ASCII_CHAR_WIDTH): Remove; no longer used.
      * src/conf_post.h (ATTRIBUTE_PURE): New macro.
      * src/lisp.h (char_table_ref): Use it, for better inlining.
      * src/fns.c (base64_decode_1): Add now-necessary casts.
      3e46a231
  9. 27 Mar, 2020 1 commit
    • Paul Eggert's avatar
      Treat out-of-range positions consistently · de00a933
      Paul Eggert authored
      If a position argument to get-byte etc. is an out-of-range integer,
      treat it the same regardless of whether it is a fixnum or a bignum.
      * src/buffer.c (fix_position): New function.
      * src/buffer.c (validate_region):
      * src/character.c (Fget_byte):
      * src/coding.c (Ffind_coding_systems_region_internal)
      (Fcheck_coding_systems_region):
      * src/composite.c (Ffind_composition_internal):
      * src/editfns.c (Fposition_bytes, Fchar_after, Fchar_before)
      (Finsert_buffer_substring, Fcompare_buffer_substrings)
      (Fnarrow_to_region):
      * src/fns.c (Fsecure_hash_algorithms):
      * src/font.c (Finternal_char_font, Ffont_at):
      * src/fringe.c (Ffringe_bitmaps_at_pos):
      * src/search.c (search_command):
      * src/textprop.c (get_char_property_and_overlay):
      * src/window.c (Fpos_visible_in_window_p):
      * src/xdisp.c (Fwindow_text_pixel_size):
      Use it instead of CHECK_FIXNUM_COERCE_MARKER, so that
      the code is simpler and treats bignums consistently with fixnums.
      * src/buffer.h (CHECK_FIXNUM_COERCE_MARKER): Define here
      rather than in lisp.h, and reimplement in terms of fix_position
      so that it treats bignums consistently with fixnums.
      * src/lisp.h (CHECK_FIXNUM_COERCE_MARKER): Move to buffer.h.
      * src/textprop.c (validate_interval_range): Signal with original
      bounds rather than modified ones.
      de00a933
  10. 17 Feb, 2020 1 commit
    • Paul Eggert's avatar
      Avoid unlikely load-average bug · 121f9bb1
      Paul Eggert authored
      * src/fns.c (Fload_average): Do not crash or return nonsense
      if the load average exceeds most-positive-fixnum/100 (Bug#39577).
      121f9bb1
  11. 18 Jan, 2020 1 commit
  12. 07 Jan, 2020 2 commits
    • Paul Eggert's avatar
      Fix sxhash-equal on bytecodes, markers, etc. · 724af767
      Paul Eggert authored
      Problem reported by Pip Cet (Bug#38912#14).
      * doc/lispref/objects.texi (Equality Predicates):
      Document better when ‘equal’ looks inside objects.
      * doc/lispref/windows.texi (Window Configurations):
      Don’t say that ‘equal’ looks inside window configurations.
      * etc/NEWS: Mention the change.
      * src/fns.c (internal_equal):
      Do not look inside window configurations.
      (sxhash_obj): Hash markers, byte-code function objects,
      char-tables, and font objects consistently with Fequal.
      * src/window.c (compare_window_configurations):
      Now static.  Remove last argument.  Caller changed.
      * test/lisp/ffap-tests.el (ffap-other-window--bug-25352):
      Use compare-window-configurations, not ‘equal’.
      * test/src/fns-tests.el (test-sxhash-equal): New test.
      724af767
    • Paul Eggert's avatar
      Help the compiler inline sxhash · f950b078
      Paul Eggert authored
      * src/fns.c (sxhash_obj): Rename from sxhash and make
      it static, so that the compiler can inline it better.
      (sxhash): New function that does not take a depth arg.
      All callers changed.
      f950b078
  13. 01 Jan, 2020 1 commit
  14. 24 Dec, 2019 1 commit
  15. 26 Nov, 2019 1 commit
  16. 16 Oct, 2019 1 commit
  17. 10 Oct, 2019 1 commit
  18. 05 Oct, 2019 1 commit
  19. 04 Oct, 2019 1 commit
  20. 21 Sep, 2019 1 commit
  21. 20 Sep, 2019 1 commit
    • Stefan Kangas's avatar
      Recommend against SHA-1 and MD5 for security · 6d50010b
      Stefan Kangas authored
      * doc/lispref/text.texi (Checksum/Hash):
      * src/fns.c (Fmd5, Fsecure_hash):
      * lisp/subr.el (sha1): Doc fix to recommend against SHA-1 and MD5 for
      security-related applications, since they are not collision
      resistant.  (Bug#37420)
      6d50010b
  22. 16 Sep, 2019 1 commit
    • Paul Eggert's avatar
      Remove obsolete Lint directives · 2c2f0eb9
      Paul Eggert authored
      Most of the directives were wrong anyway.  Apparently
      traditional lint hasn’t been used to check Emacs for years.
      * src/callint.c (Finteractive):
      * src/cm.c (evalcost):
      * src/emacs.c (main):
      * src/eval.c (call1, call2, call3, call4, call5, call6, call7, call8):
      * src/fns.c (concat2, concat3, nconc2):
      * src/term.c (calculate_ins_del_char_costs):
      Omit ARGSUSED comments.
      * src/eval.c (call1): Omit VARARGS comment.
      2c2f0eb9
  23. 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
  24. 22 Aug, 2019 3 commits
    • Paul Eggert's avatar
      Fix Qunbound-Qnil confusion in clrhash patch · e5defc3e
      Paul Eggert authored
      Problem reported by Stefan Monnier.
      * src/fns.c (hash_clear): Fix typo I introduced in my previous
      patch here, by setting keys to Qunbound not Qnil.
      e5defc3e
    • 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
    • Paul Eggert's avatar
      Don’t hard-loop on cycles in ‘read’ etc. · 951ea375
      Paul Eggert authored
      Problem for ‘read’ reported by Pip Cet in:
      https://lists.gnu.org/r/emacs-devel/2019-08/msg00316.html
      * src/fns.c (Frequire): Protect against circular current-load-list.
      * src/lread.c (Fget_load_suffixes):
      Protect against circular load-suffixes or load-file-rep-suffixes.
      (Fload): Protect against circular loads-in-progress.
      (openp): Protect against circular PATH and SUFFIXES.
      (build_load_history): Protect against circular load-history or
      current-load-list.
      (readevalloop_eager_expand_eval): Protect against circular SUBFORMS.
      (read1): Protect against circular data.
      * test/src/lread-tests.el (lread-circular-hash): New test.
      951ea375
  25. 21 Aug, 2019 1 commit
    • Paul Eggert's avatar
      Be more careful about pointers to bignum vals · 39fee209
      Paul Eggert authored
      This uses ‘const’ to be better at catching bugs that
      mistakenly attempt to modify a bignum value.
      Lisp bignums are supposed to be immutable.
      * src/alloc.c (make_pure_bignum):
      * src/fns.c (sxhash_bignum):
      Accept Lisp_Object instead of struct Lisp_Bignum *, as that’s
      simpler now.  Caller changed.
      * src/bignum.h (bignum_val, xbignum_val): New inline functions.
      Prefer them to &i->value and XBIGNUM (i)->value, since they
      apply ‘const’ to the result.
      * src/timefns.c (lisp_to_timespec): Use mpz_t const *
      to point to a bignum value.
      39fee209
  26. 15 Aug, 2019 1 commit
    • 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
  27. 26 Jul, 2019 4 commits
  28. 23 Jul, 2019 3 commits
  29. 21 Jul, 2019 1 commit
    • Paul Eggert's avatar
      Avoid integer overflow in hash table size · c72e6328
      Paul Eggert authored
      * src/fns.c (INDEX_SIZE_BOUND): Use a tighter bound.
      (maybe_resize_hash_table): Avoid integer overflow when
      checking for hash table size overflow.  Fix confusion
      between INDEX_SIZE_BOUND (which is for the index vector)
      and hash table size.  Fix typo in debugging message
      when ENABLE_CHECKING.
      c72e6328