1. 15 Mar, 2018 1 commit
    • Paul Eggert's avatar
      Improve port to NetBSD tzalloc · 64a1da49
      Paul Eggert authored
      Problem reported by Valery Ushakov (Bug#30738#13).
      * src/editfns.c (tzlookup) [__NetBSD_Version__ < 700000000]:
      If tzalloc fails for any reason other than memory exhaustion,
      assume it’s because NetBSD 6 does not support tzalloc on
      POSIX-format TZ strings, and fall back on tzdb if possible.
      64a1da49
  2. 11 Mar, 2018 2 commits
    • Charles A. Roelli's avatar
      Make transpose-regions interactive (Bug#30343) · b88e7c8b
      Charles A. Roelli authored
      * doc/emacs/fixit.texi (Transpose): Mention and explain the new
      command.
      * editfns.c (Ftranspose_regions): Add an interactive calling
      specification, and add documentation for it.
      b88e7c8b
    • Paul Eggert's avatar
      Port to NetBSD tzalloc · d48f4c3b
      Paul Eggert authored
      Problem reported by Valery Ushakov (Bug#30738).
      * src/editfns.c (xtzalloc): Remove.
      (invalid_time_zone_specification): New function.
      (tzlookup): Port to NetBSD, where tzalloc can fail when the TZ
      string has an invalid value.
      d48f4c3b
  3. 09 Mar, 2018 1 commit
    • Paul Eggert's avatar
      Avoid losing info when formatting integers · 80e145fc
      Paul Eggert authored
      * doc/lispref/numbers.texi (Integer Basics): Clarify that
      out-of-range integers are treated as floating point only when the
      integers are decimal.
      * etc/NEWS: Mention changes.
      * src/editfns.c (styled_format): Use %.0f when formatting %d or %i
      values outside machine integer range, to avoid losing info.
      Signal an error for %o or %x values that are too large to be
      formatted, to avoid losing info.
      80e145fc
  4. 06 Jan, 2018 2 commits
  5. 01 Jan, 2018 1 commit
  6. 12 Dec, 2017 1 commit
    • Paul Eggert's avatar
      Narrow pointer bounds when appropriate · 4295050e
      Paul Eggert authored
      This typically occurs in a storage manager, where the caller
      is expected to access only the newly-allocated object,
      instead of using the returned value to access unrelated
      parts of the heap.
      * src/alloc.c (allocate_string, allocate_string_data)
      (compact_small_strings, find_string_data_in_pure)
      (sweep_strings, setup_on_free_list, allocate_vectorlike
      (pure_alloc):
      * src/bytecode.c (exec_byte_code):
      * src/callint.c (Fcall_interactively):
      * src/dispnew.c (scrolling):
      * src/editfns.c (styled_format):
      * src/frame.c (xrdb_get_resource, x_get_resource_string):
      * src/fringe.c (Fdefine_fringe_bitmap):
      * src/gmalloc.c (malloc, realloc, aligned_alloc):
      Narrow pointer bounds when appropriate.
      * src/alloc.c (SDATA_OF_STRING):
      * src/lisp.h (make_lisp_symbol) [__CHKP__]:
      Widen bounds here, though.
      * src/bytecode.c, src/callint.c, src/dispnew.c, src/editfns.c:
      * src/emacs.c, src/frame.c, src/fringe.c:
      Include ptr-bounds.h.
      * src/ptr-bounds.h (ptr_bounds_clip): New function.
      4295050e
  7. 08 Dec, 2017 2 commits
  8. 03 Dec, 2017 1 commit
    • Paul Eggert's avatar
      Fix bug in i18n/l10n optimization · 04e5b28f
      Paul Eggert authored
      This fixes a off-by-one buffer overrun bug introduced in
      2017-06-04T15:39:37Z!eggert@cs.ucla.edu.  Problem uncovered by an
      experimental version of Emacs built with -fcheck-pointer-bounds
      and running on Intel MPX hardware.
      * src/editfns.c (styled_format): Avoid overrunning internal buffers.
      04e5b28f
  9. 22 Nov, 2017 1 commit
  10. 04 Nov, 2017 1 commit
    • Eli Zaretskii's avatar
      Allow 'make-string' callers force creation of multibyte strings · bd886c6f
      Eli Zaretskii authored
      * src/alloc.c (Fmake_string): Accept additional argument
      MULTIBYTE, and produce a multibyte string if it is non-nil.
      (make_event_array):
      * src/lread.c (read0):
      * src/editfns.c (Ftranslate_region_internal):
      * src/coding.c (Fdefine_coding_system_internal):
      * src/cmds.c (internal_self_insert):
      * src/xdisp.c (build_desired_tool_bar_string)
      (store_mode_line_string): All C callers changed.
      
      * doc/lispref/strings.texi (Creating Strings): Document the new
      optional argument.
      
      * etc/NEWS: Mention the new optional argument.
      
      * lisp/ruler-mode.el (ruler-mode-ruler): Call make-string with the
      3rd argument non-nil.
      bd886c6f
  11. 28 Oct, 2017 1 commit
    • Glenn Morris's avatar
      Fix some doc typos · e6b4e5ff
      Glenn Morris authored
      * lisp/calendar/todo-mode.el (todo-next-item)
      (todo-previous-item, todo-toggle-item-header):
      * lisp/window.el (move-to-window-group-line):
      * src/editfns.c (Fformat):
      * test/lisp/calendar/todo-mode-tests.el (todo-test-move-item05):
      Fix doc typos.
      
      ; And in some comments.
      e6b4e5ff
  12. 18 Oct, 2017 1 commit
    • Paul Eggert's avatar
      Improve format-time-string doc · 8ca6fa58
      Paul Eggert authored
      * doc/lispref/os.texi (Time Parsing): Fix some errors in the
      documentation for format-time-string.  Document ^, #, %s, and %z
      with colons.  Say that unrecognized sequences are output as-is.
      * src/editfns.c (Fformat_time_string): %S can stand for 60.
      Also mention unrecognized sequences.
      8ca6fa58
  13. 06 Oct, 2017 1 commit
  14. 04 Oct, 2017 1 commit
    • Paul Eggert's avatar
      Speed up (format "%s" STRING) and the like · 3db388b0
      Paul Eggert authored
      Although the Lisp manual said that ‘format’ returns a
      newly-allocated string, this was not true for a few cases like
      (format "%s" ""), and fixing the documentation to allow reuse of
      arguments lets us improve performance in common cases like
      (format "foo") and (format "%s" "foo") (Bug#28625).
      * doc/lispref/strings.texi (Formatting Strings):
      * etc/NEWS:
      Say that the result of ‘format’ might not be newly allocated.
      * src/callint.c (Fcall_interactively):
      * src/dbusbind.c (XD_OBJECT_TO_STRING):
      * src/editfns.c (Fmessage, Fmessage_box):
      * src/xdisp.c (vadd_to_log, Ftrace_to_stderr):
      Just use Fformat or Fformat_message, as that’s simpler and no
      longer makes unnecessary copies.
      * src/editfns.c (styled_format): Remove last argument, as it
      is no longer needed: all callers now want it to behave as if it
      were true.  All remaining callers changed.  Make this function
      static again.  Simplify the function now that we no longer
      need to worry about whether the optimization is allowed.
      3db388b0
  15. 01 Oct, 2017 1 commit
  16. 27 Sep, 2017 1 commit
  17. 26 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Avoid some unnecessary copying in Fformat etc. · 0e82fa34
      Paul Eggert authored
      This patch is just for performance; it should not affect behavior.
      On my platform, it made the microbenchmark (format "%S" load-path)
      run about 45% faster.  It should also speed up calls like (message
      "%s" STRING).
      * src/callint.c (Fcall_interactively):
      * src/dbusbind.c (XD_OBJECT_TO_STRING):
      * src/editfns.c (Fmessage, Fmessage_box):
      * src/xdisp.c (vadd_to_log, Ftrace_to_stderr):
      Use styled_format instead of Fformat or Fformat_message,
      to avoid unnecessary copying.
      * src/editfns.c (styled_format): New arg NEW_RESULT.
      All uses changed.  Reuse an input string if it has the
      right value and if !NEW_RESULT.
      * src/lisp.h (style_format): New decl.
      0e82fa34
  18. 18 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Fix format-time-string %Z bug with negative tz · 541006c5
      Paul Eggert authored
      * src/editfns.c (tzlookup): Fix sign error in %Z when a purely
      numeric zone is negative (Bug#28746).
      * test/src/editfns-tests.el (format-time-string-with-zone):
      Add test for this bug.
      541006c5
  19. 13 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to FTP and HTTP in documentation · bc511a64
      Paul Eggert authored
      Most of this change is to boilerplate commentary such as license URLs.
      This change was prompted by ftp://ftp.gnu.org's going-away party,
      planned for November.  Change these FTP URLs to https://ftp.gnu.org
      instead.  Make similar changes for URLs to other organizations moving
      away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
      fsf.org when this works, as this will further help defend against
      man-in-the-middle attacks (for this part I omitted the MS-DOS and
      MS-Windows sources and the test tarballs to keep the workload down).
      HTTPS is not fully working to lists.gnu.org so I left those URLs alone
      for now.
      bc511a64
  20. 09 Sep, 2017 2 commits
    • Paul Eggert's avatar
      Improve --enable-gcc-warnings for MinGW64 · d6312354
      Paul Eggert authored
      This partially reverts my 2016-05-30 patch.  Apparently MinGW64
      still requires pacifications that GCC 7.1.1 x86-64 (Fedora 26)
      does not.  Also, pacify tparam.c, which isn’t used on Fedora.
      * lib-src/etags.c (process_file_name, TeX_commands):
      * src/buffer.c (fix_overlays_before):
      * src/data.c (Fmake_variable_buffer_local, cons_to_unsigned)
      (cons_to_signed):
      * src/editfns.c (Ftranslate_region_internal):
      Prefer UNINIT to some stray value, as this simplifies
      code-reading later.
      * src/eval.c (CACHEABLE): New macro.
      (internal_lisp_condition_case): Use it.
      * src/tparam.c (tparam1): Use FALLTHROUGH to pacify GCC.
      d6312354
    • Eli Zaretskii's avatar
      Fix compilation warnings in MinGW64 build using GCC 7 · 2b84c166
      Eli Zaretskii authored
      Reported by Richard Copley <rcopley@gmail.com>.
      * src/w32heap.c (init_heap): Declare enable_lfh only for
      mingw.org's MinGW build.
      
      * src/w32console.c (w32con_write_glyphs):
      * src/unexw32.c (get_section_info, COPY_CHUNK, unexec): Fix some
      mismatches of data type vs format spec.
      
      * src/w32fns.c (compute_tip_xy):
      * src/w32proc.c (stop_timer_thread):
      * src/w32notify.c (remove_watch):
      * src/eval.c (internal_lisp_condition_case):
      * src/editfns.c (Ftranslate_region_internal):
      * src/data.c (Fmake_variable_buffer_local, cons_to_unsigned)
      (cons_to_signed):
      * src/buffer.c (fix_overlays_before): Initialize variables to
      avoid compiler warnings.
      
      * lib-src/etags.c (TeX_commands, process_file_name): Initialize
      variables to avoid compilation warnings.
      2b84c166
  21. 06 Jul, 2017 1 commit
    • Paul Eggert's avatar
      Convert hex digits more systematically · d6662694
      Paul Eggert authored
      This makes the code a bit smaller and presumably faster, as
      it substitutes a single lookup for conditional jumps.
      * src/character.c (hexdigit): New constant.
      (syms_of_character) [HEXDIGIT_IS_CONST]: Initialize it.
      * src/character.h (HEXDIGIT_CONST, HEXDIGIT_IS_CONST): New macros.
      (hexdigit): New decl.
      (char_hexdigit): New inline function.
      * src/charset.c: Do not include c-ctype.h.
      * src/charset.c (read_hex):
      * src/editfns.c (styled_format):
      * src/image.c (xbm_scan):
      * src/lread.c (read_escape):
      * src/regex.c (ISXDIGIT) [emacs]:
      Use char_hexdigit insted of doing it by hand.
      d6662694
  22. 22 Jun, 2017 1 commit
  23. 17 Jun, 2017 3 commits
    • Eli Zaretskii's avatar
      Improve documentation of replace-buffer-contents · f8cc7a83
      Eli Zaretskii authored
      * etc/NEWS (replace-buffer-contents): Fix formatting.
      
      * src/editfns.c (Freplace_buffer_contents): Doc fix.
      f8cc7a83
    • Philipp Stephani's avatar
      Remove unnecessary point motion · 5575db92
      Philipp Stephani authored
      * src/editfns.c (Freplace_buffer_contents): Remove unnecessary point
      motion.
      5575db92
    • 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
  24. 04 Jun, 2017 1 commit
    • Paul Eggert's avatar
      Tune ‘format’ after recent fix · d5fcf9e4
      Paul Eggert authored
      * doc/lispref/strings.texi (Formatting Strings):
      * src/editfns.c (Fformat): Format field numbers no longer need
      to be unique, reverting the previous doc change since that has
      now been fixed.  Also, document that %% should not have modifiers.
      * src/editfns.c (styled_format): Improve performance.  Remove
      the need for the new prepass over the format string, by using
      a typically-more-generous bound for the info array size.
      Initialize the info array lazily.  Move string inspection to
      the same area to help caching.  Avoid the need for a
      converted_to_string bitfield by using EQ.  Cache arg in a
      local and avoid some potential aliasing issues to help the
      compiler.  Info array is now 0-origin, not 1-origin.
      d5fcf9e4
  25. 03 Jun, 2017 3 commits
    • Philipp Stephani's avatar
      ; Fix off-by-one error · e3b7eead
      Philipp Stephani authored
      e3b7eead
    • 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
    • Paul Eggert's avatar
      Document uniqueness limitation of ‘format’ · 0147cdd4
      Paul Eggert authored
      * doc/lispref/strings.texi (Formatting Strings):
      * src/editfns.c (Fformat):
      Document that field numbers should be unique within a format.
      0147cdd4
  26. 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
      Improve performance by avoiding strtoumax · 178d0cb5
      Paul Eggert authored
      This made (string-to-number "10") 20% faster on my old desktop,
      an AMD Phenom II X4 910e running Fedora 25 x86-64.
      * admin/merge-gnulib (GNULIB_MODULES): Remove strtoumax.
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
      * lib/strtoul.c, lib/strtoull.c, lib/strtoumax.c, m4/strtoull.m4:
      * m4/strtoumax.m4: Remove.
      * src/editfns.c (str2num): New function.
      (styled_format): Use it instead of strtoumax.  Use ptrdiff_t
      instead of uintmax_t.  Check for integer overflow.
      * src/lread.c (LEAD_INT, DOT_CHAR, TRAIL_INT, E_EXP):
      Move to private scope and make them enums.
      (string_to_number): Compute integer value directly during
      first pass instead of revisiting it with strtoumax later.
      178d0cb5
    • 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
  27. 31 May, 2017 2 commits
  28. 16 May, 2017 1 commit