1. 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.
    • 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.
    • 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.
    • 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.
  2. 31 May, 2017 2 commits
  3. 16 May, 2017 2 commits
    • Paul Eggert's avatar
      Fix minor timezone memory leak · f7c07930
      Paul Eggert authored
      * src/editfns.c (wall_clock_tz): Remove; unused.
    • Paul Eggert's avatar
      Merge with gnulib, pacifying GCC 7 · 2e1bebe2
      Paul Eggert authored
      This incorporates:
      2017-05-16 manywarnings: update for GCC 7
      2017-05-15 sys_select: Avoid "was expanded before it was required"
      * configure.ac (nw): Suppress GCC 7’s new -Wduplicated-branches and
      -Wformat-overflow=2 options, due to too many false alarms.
      * doc/misc/texinfo.tex, lib/strftime.c, m4/manywarnings.m4:
      Copy from gnulib.
      * m4/gnulib-comp.m4: Regenerate.
      * src/coding.c (decode_coding_iso_2022):
      Fix bug uncovered by -Wimplicit-fallthrough.
      * src/conf_post.h (FALLTHROUGH): New macro.
      Use it to mark all switch cases that fall through.
      * src/editfns.c (styled_format): Use !, not ~, on bool.
      * src/gtkutil.c (xg_check_special_colors):
      When using sprintf, don’t trust Gtk to output colors in [0, 1] range.
      (xg_update_scrollbar_pos): Avoid use of possibly-uninitialized bool;
      this bug was actually caught by Clang.
      * src/search.c (boyer_moore):
      Tell GCC that CHAR_BASE, if nonzero, must be a non-ASCII character.
      * src/xterm.c (x_draw_glyphless_glyph_string_foreground):
      Tell GCC that glyph->u.glyphless.ch must be a character.
  4. 01 May, 2017 1 commit
    • Paul Eggert's avatar
      Merge from gnulib · 634d0a90
      Paul Eggert authored
      This incorporates:
      2017-05-01 New module 'localtime-buffer'
      2017-04-30 utimens: Add support for native Windows
      * admin/merge-gnulib (AVOIDED_MODULES): Add tzset.
      * configure.ac (tzset): No need for Emacs itself to check now.
      * lib/gettimeofday.c, lib/time.in.h, lib/time_rz.c, lib/utimens.c:
      * m4/gettimeofday.m4, m4/time_h.m4, m4/time_rz.m4: Copy from gnulib.
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
      * lib/localtime-buffer.c, lib/localtime-buffer.h:
      * m4/localtime-buffer.m4: New files, copied from gnulib.
      * src/editfns.c (init_editfns): Assume tzset is callable.
  5. 28 Mar, 2017 1 commit
  6. 05 Mar, 2017 2 commits
  7. 03 Mar, 2017 1 commit
  8. 02 Mar, 2017 1 commit
    • Paul Eggert's avatar
      Restore XFLOATINT but with restricted args · 56aaaf9b
      Paul Eggert authored
      Turn instances of extract_float into XFLOAT_DATA when possible,
      and to a resurrected XFLOATINT when the arg is a number.
      The resurrected XFLOATINT is more like XFLOAT and XINT in
      that is valid only if its arg is a number.  This clarifies
      the ways in which floats can be extracted at the C level.
      * src/editfns.c (styled_format):
      * src/floatfns.c (extract_float, Fexpt):
      Use XFLOATINT rather than open-coding it.
      * src/fns.c (internal_equal):
      * src/image.c (imagemagick_load_image):
      * src/xdisp.c (resize_mini_window):
      Prefer XFLOAT_DATA to extract_float on values known to be floats.
      * src/frame.c (x_set_screen_gamma):
      * src/frame.h (NUMVAL):
      * src/image.c (x_edge_detection, compute_image_size):
      * src/lread.c (read_filtered_event):
      * src/window.c (Fset_window_vscroll):
      * src/xdisp.c (handle_single_display_spec, try_scrolling)
      (redisplay_window, calc_pixel_width_or_height, x_produce_glyphs)
      Prefer XFLOATINT to extract_float on values known to be numbers.
      * src/lisp.h (XFLOATINT): Bring back this function, except
      it now assumes its argument is a number.
  9. 01 Mar, 2017 1 commit
    • Paul Eggert's avatar
      Fix rounding error in ‘ceiling’ etc. · 207ee94b
      Paul Eggert authored
      Without this fix, (ceiling most-negative-fixnum -1.0) returns
      most-negative-fixnum instead of correctly signaling range-error,
      and similarly for floor, round, and truncate.
      * configure.ac (trunc): Add a check, since Gnulib’s doc says
      ‘trunc’ is missing from MSVC 9.  The Gnulib doc says ‘trunc’ is
      also missing from some other older operating systems like Solaris
      9 which I know we don’t care about any more, so MSVC is the only
      reason to worry about ‘trunc’ here.
      * src/editfns.c (styled_format): Formatting a float with %c is now an
      error.  The old code did not work in general, because FIXNUM_OVERFLOW_P
      had rounding errors.  Besides, the "if (FLOATP (...))" was in there
      only as a result of my misunderstanding old code that I introduced
      2011.  Although %d etc. is sometimes used on floats that represent
      huge UIDs or PIDs etc. that do not fit in fixnums, this cannot
      happen with characters.
      * src/floatfns.c (rounding_driver): Rework to do the right thing
      when the intermediate result equals 2.305843009213694e+18, i.e.,
      is exactly 1 greater than MOST_POSITIVE_FIXNUM on a 64-bit host.
      Simplify so that only one section of code checks for overflow,
      rather than two.
      (double_identity): Remove.  All uses changed to ...
      (emacs_trunc): ... this new function.  Add replacement for
      platforms that lack ‘trunc’.
      * src/lisp.h (FIXNUM_OVERFLOW_P, make_fixnum_or_float):
      Make it clear that the arg cannot be floating point.
      * test/src/editfns-tests.el (format-c-float): New test.
      * test/src/floatfns-tests.el: New file, to test for this bug.
  10. 01 Feb, 2017 2 commits
    • Paul Eggert's avatar
      Revamp quitting and fix infloops · b01ac672
      Paul Eggert authored
      This fixes some infinite loops that cannot be quitted out of,
      e.g., (defun foo () (nth most-positive-fixnum '#1=(1 . #1#)))
      when byte-compiled and when run under X.  See:
      This also attempts to keep the performance improvements I recently
      added, as much as possible under the constraint that the infloops
      must be caught.  In some cases this fixes infloop bugs recently
      introduced when I removed immediate_quit.
      * src/alloc.c (Fmake_list):
      Use rarely_quit, not maybe_quit, for speed in the usual case.
      * src/bytecode.c (exec_byte_code):
      * src/editfns.c (Fcompare_buffer_substrings):
      * src/fns.c (Fnthcdr):
      * src/syntax.c (scan_words, skip_chars, skip_syntaxes)
      Use rarely_quit so that users can C-g out of long loops.
      * src/callproc.c (call_process_cleanup, call_process):
      * src/fileio.c (read_non_regular, Finsert_file_contents):
      * src/indent.c (compute_motion):
      * src/syntax.c (scan_words, Fforward_comment):
      Remove now-unnecessary maybe_quit calls.
      * src/callproc.c (call_process):
      * src/doc.c (get_doc_string, Fsnarf_documentation):
      * src/fileio.c (Fcopy_file, read_non_regular, Finsert_file_contents):
      * src/lread.c (safe_to_load_version):
      * src/sysdep.c (system_process_attributes) [GNU_LINUX]:
      Use emacs_read_quit instead of emacs_read in places where
      C-g handling is safe.
      * src/eval.c (maybe_quit): Move comment here from lisp.h.
      * src/fileio.c (Fcopy_file, e_write):
      Use emacs_write_quit instead of emacs_write_sig in places where
      C-g handling is safe.
      * src/filelock.c (create_lock_file): Use emacs_write, not
      plain write, as emacs_write no longer has a problem.
      (read_lock_data): Use emacs_read, not read, as emacs_read
      no longer has a problem.
      * src/fns.c (rarely_quit): Move to lisp.h and rename to
      incr_rarely_quit.  All uses changed..
      * src/fns.c (Fmemq, Fmemql, Fassq, Frassq, Fplist_put, Fplist_member):
      * src/indent.c (compute_motion):
      * src/syntax.c (find_defun_start, back_comment, forw_comment)
      (Fforward_comment, scan_lists, scan_sexps_forward):
      Use incr_rarely_quit so that users can C-g out of long loops.
      * src/fns.c (Fnconc): Move incr_rarely_quit call to within
      inner loop, so that it catches C-g there too.
      * src/keyboard.c (tty_read_avail_input): Remove commented-out
      and now-obsolete code dealing with interrupts.
      * src/lisp.h (rarely_quit, incr_rarely_quit): New functions,
      the latter moved here from fns.c and renamed from rarely_quit.
      (emacs_read_quit, emacs_write_quit): New decls.
      * src/search.c (find_newline, search_buffer, find_newline1):
      Add maybe_quit to catch C-g.
      * src/sysdep.c (get_child_status): Always invoke maybe_quit
      if interruptible, so that the caller need not bother.
      (emacs_nointr_read, emacs_read_quit, emacs_write_quit):
      New functions.
      (emacs_read): Rewrite in terms of emacs_nointr_read.
      Do not handle C-g or signals; that is now for emacs_read_quit.
      (emacs_full_write): Replace PROCESS_SIGNALS two-way arg
      with INTERRUPTIBLE three-way arg.  All uses changed.
    • Paul Eggert's avatar
      Remove immediate_quit. · 33be5003
      Paul Eggert authored
      The old code that sets and clears immediate_quit was
      ineffective except when Emacs is running in terminal mode, and
      has problematic race conditions anyway, so remove it.  This
      will introduce some hangs when Emacs runs in terminal mode,
      and these hangs should be fixed in followup patches.
      * src/keyboard.c (immediate_quit): Remove.  All uses removed.
  11. 28 Jan, 2017 1 commit
    • Eli Zaretskii's avatar
      Improve documentation of 'format' conversions · c331f393
      Eli Zaretskii authored
      * src/editfns.c (Fformat): More accurate description of %g and
      effects of the various flags on it.  More accurate description of
      integer conversions.
      * doc/lispref/strings.texi (Formatting Strings): More accurate
      description of %g and effects of the various flags on it.  More
      accurate description of integer conversions.  (Bug#25557)
  12. 26 Jan, 2017 2 commits
    • Paul Eggert's avatar
      Replace QUIT with maybe_quit · b3a3ed52
      Paul Eggert authored
      There’s no longer need to have QUIT stand for a slug of C statements.
      Use the more-obvious function-call syntax instead.
      Also, use true and false when setting immediate_quit.
      These changes should not affect the generated machine code.
      * src/lisp.h (QUIT): Remove.  All uses replaced by maybe_quit.
    • Paul Eggert's avatar
      A quicker check for quit · 1392ec74
      Paul Eggert authored
      On some microbenchmarks this lets Emacs run 60% faster on my
      platform (AMD Phenom II X4 910e, Fedora 25 x86-64).
      * src/atimer.c: Include keyboard.h, for pending_signals.
      * src/editfns.c (Fcompare_buffer_substrings):
      * src/fns.c (Fnthcdr, Fmemq, Fmemql, Fassq, Frassq, Fplist_put)
      (Fnconc, Fplist_member):
      Set and clear immediate_quit before and after loop instead of
      executing QUIT each time through the loop.  This is OK for loops
      that affect only locals.
      * src/eval.c (process_quit_flag): Now static.
      (maybe_quit): New function, containing QUIT’s old body.
      * src/fns.c (rarely_quit): New function.
      (Fmember, Fassoc, Frassoc, Fdelete, Fnreverse, Freverse)
      (Flax_plist_get, Flax_plist_put, internal_equal, Fnconc):
      Use it instead of QUIT, for
      speed in tight loops that might modify non-locals.
      * src/keyboard.h (pending_signals, process_pending_signals):
      These belong to keyboard.c, so move them here ...
      * src/lisp.h: ... from here.
      (QUIT): Redefine in terms of the new maybe_quit function, which
      contains this macro’s old definiens.  This works well with branch
      prediction on processors with return stack buffers, e.g., x86
      other than the original Pentium.
  13. 01 Jan, 2017 1 commit
  14. 24 Dec, 2016 1 commit
    • Hong Xu's avatar
      Fix timezone detection of parse-iso8601-time-string · 25c9cb77
      Hong Xu authored
      * parse-time.el (parse-iso8601-time-string): Fix timezone
      parsing.  Add a doc string.  (Bug#25086)
      * editfns.c (Fdecode-time): Doc fix.
      * emacs-mime.texi (time-date): Add an example for
      * parse-time-tests.el (parse-time-tests): Add tests for
  15. 20 Nov, 2016 2 commits
  16. 18 Nov, 2016 1 commit
    • Eli Zaretskii's avatar
      Improve documentation of functions that accept time values · 36bafc9c
      Eli Zaretskii authored
      * doc/lispref/os.texi (Time Calculations): Mention the meaning of
      'nil' or a scalar number as the time-value argument.  Add a
      cross-reference to 'float-time' for computing a time difference as
      a scalar number of seconds.
      * src/editfns.c (Fformat_time_string, Ftime_less_p)
      (Ftime_subtract, Ftime_add, Fdecode_time, Fcurrent_time_string)
      (Fcurrent_time_zone): Mention in the doc strings the meaning of
      nil argument and the fact that a time value can be a scalar number
      of seconds since the epoch.
      (Ftime_subtract): Mention 'float-time'.
  17. 17 Oct, 2016 2 commits
  18. 03 Oct, 2016 1 commit
  19. 30 Sep, 2016 1 commit
    • Paul Eggert's avatar
      Limit <config.h>’s includes · f4eb8900
      Paul Eggert authored
      This follows up on recent problems with the fact that config.h
      includes stdlib.h etc.; some files need to include stdlib.h later.
      config.h generally should limit itself to includes that are
      universally safe; outside of MS-Windows, only stdbool.h makes
      the cut among the files currently included.  So, move the
      other includes to just the files that need them (Bug#24506).
      * configure.ac (config_opsysfile): Remove, as this generic hook
      is no longer needed.
      * lib-src/etags.c, src/unexmacosx.c, src/w32.c, src/w32notify.c:
      * src/w32proc.c (_GNU_SOURCE):
      Remove, as it’s OK for config.h to do this now.
      * src/conf_post.h: Include <ms-w32.h>, instead of the generic
      config_opsysfile, for simplicity as this old way of configuring is
      now done only for the MS-Windows port.  Do not include <ms-w32.h>
      if DEFER_MS_W32_H, for the benefit of the few files that want its
      effects later.  Do not include <alloca.h>, <string.h>, or
      <stdlib.h>.  Other files modified to include these headers as
      needed, or to not include headers that are no longer needed.
      * src/lisp.h: Include <alloca.h> and <string.h> here, since
      some of the inline functions need them.
      * src/regex.c: Include <alloca.h> if not emacs.  (If emacs,
      we can rely on SAFE_ALLOCA.)  There is no longer any need to
      worry about HAVE_ALLOCA_H.
      * src/unexmacosx.c: Rely on config.h not including stdlib.h.
      * src/w32.c, src/w32notify.c, src/w32proc.c (DEFER_MS_W32_H):
      Define before including <config.h> first, and include <ms-w32.h>
      after the troublesome headers.
  20. 24 Sep, 2016 1 commit
    • Paul Eggert's avatar
      Improve integer overflow handling a bit · b3e1b382
      Paul Eggert authored
      * src/charset.c (read_hex): Use INT_LEFT_SHIFT_OVERFLOW for clarity.
      The machine code is the same on my platform.
      * src/doprnt.c (doprnt):
      * src/emacs-module.c (module_funcall):
      * src/font.c (font_intern_prop):
      * src/keyboard.c (Frecursion_depth):
      * src/lread.c (read1):
      Use WRAPV macros instead of checking overflow by hand.
      * src/editfns.c (hi_time, time_arith, decode_time_components):
      * src/emacs-module.c (Fmodule_load):
      Simplify by using FIXNUM_OVERFLOW_P.
      * src/emacs-module.c: Include intprops.h.
      * src/xdisp.c (percent99): New function.
      (decode_mode_spec): Use it to simplify overflow avoidance and
      formatting of %p and %P.
  21. 23 Sep, 2016 1 commit
  22. 16 Sep, 2016 1 commit
  23. 31 Aug, 2016 2 commits
    • Paul Eggert's avatar
    • Paul Eggert's avatar
      Minor doc quoting fixes · 6f40b8b2
      Paul Eggert authored
      * doc/misc/htmlfontify.texi (Interactive):
      * lisp/htmlfontify.el (htmlfontify-buffer):
      Spell out character names, for clarity.  The old doc string
      generated the *Help* text ‘^L ([FF]) or ¤ (244)’, where ‘[FF]’
      stands for a form feed character; this was confusing.
      * lisp/electric.el (electric-quote-mode):
      * src/doc.c (syms_of_doc):
      * src/editfns.c (Fformat_message):
      Remove no-longer-necessary ‘\=’s in doc strings.
  24. 20 Aug, 2016 1 commit
    • Philipp Stephani's avatar
      Some assorted documentation clarifications · 9b99772c
      Philipp Stephani authored
      * src/fileio.c (Fwrite_region): Clarify that END is ignored if
      START is nil.
      * src/editfns.c (Fbuffer_size): Add short discussion about
      * src/callproc.c (Fcall_process_region): Discuss behavior when
      START and END are not buffer positions.
  25. 23 Jul, 2016 1 commit
    • Noam Postavsky's avatar
      Adjust match data before calling after-change-funs · 66f95e0d
      Noam Postavsky authored
      It's important to adjust the match data in between calling
      before-change-functions and after-change-functions, so that buffer
      change hooks will always see match-data consistent with buffer content.
      (Bug #23917)
      * src/insdel.c (replace_range): Add new parameter ADJUST_MATCH_DATA, if
      true call update_search_regs.  Update all callers (except
      Freplace_match) to pass 0 for the new parameter.
      * src/search.c (update_search_regs): New function, extracted from
      (Freplace_match): Remove match data adjustment code, pass 1 for
      ADJUST_MATCH_DATA to replace_range instead.
  26. 20 Jul, 2016 1 commit
    • Paul Eggert's avatar
      Fix lifetime bug in tzlookup · 852111f3
      Paul Eggert authored
      * src/editfns.c (tzlookup): Fix storage lifetime bug when
      INTEGERP (zone) && settz.  Problem found by Coverity Scan.
  27. 19 Jul, 2016 1 commit
    • Eli Zaretskii's avatar
      Fix 'transpose-regions' when LEAVE-MARKERS arg is non-nil · 00b66476
      Eli Zaretskii authored
      * src/insdel.c (adjust_markers_bytepos): New function.
      * src/lisp.h (adjust_markers_bytepos): Add prototype.
      * src/insdel.c (replace_range, replace_range_2):
      * src/editfns.c (Ftranspose_regions): Call
      adjust_markers_bytepos.  (Bug#5131)
      * test/src/editfns-tests.el (transpose-test-reverse-word)
      (transpose-test-get-byte-positions): New functions.
      (transpose-nonascii-regions-test-2): New tests.
  28. 15 Jul, 2016 1 commit
  29. 09 Jul, 2016 1 commit
    • Eli Zaretskii's avatar
      Minor tweaks of copying text properties when padding strings · 0a2aedfe
      Eli Zaretskii authored
      * src/editfns.c (styled_format): Don't include padding on the left
      in the properties at the beginning of the string.  (Bug#23897)
      * test/src/editfns-tests.el (format-properties): Add tests for
      faces when the string is padded on the left or on the right.