1. 28 Jun, 2019 3 commits
    • Mattias Engdegård's avatar
      Correct regexp matching of raw bytes · a1f76adf
      Mattias Engdegård authored
      Make regexp matching of raw bytes work in all combination of unibyte
      and multibyte patterns and targets, as exact strings and in character
      alternatives (bug#3687).
      
      * src/regex-emacs.c (analyze_first):
      Include raw byte in fastmap when pattern is a multibyte exact string.
      Include leading byte in fastmap for raw bytes in character alternatives.
      (re_match_2_internal):
      Decrement the byte count by the number of bytes in the pattern character,
      not 1.
      * test/src/regex-emacs-tests.el (regexp-unibyte-unibyte)
      (regexp-multibyte-unibyte, regexp-unibyte-mutibyte)
      (regexp-multibyte-multibyte): New tests.
      a1f76adf
    • Mattias Engdegård's avatar
      More readable regexp debug output · 24a32960
      Mattias Engdegård authored
      * src/regex-emacs.c (debug_putchar): New.
      (print_fastmap, print_partial_compiled_pattern, print_double_string)
      (regex_compile): Use debug_putchar.
      (re_match_2_internal): Add newline.
      24a32960
    • Mattias Engdegård's avatar
      Consistently use stderr for debug output in regexp code · 82172558
      Mattias Engdegård authored
      * src/regex-emacs.c (DEBUG_PRINT, print_fastmap, print_compiled_pattern)
      (print_double_string, regex_compile): Print to stderr instead of stdout.
      82172558
  2. 23 May, 2019 1 commit
    • Paul Eggert's avatar
      Avoid backslash-newline-newline in source code · 54244364
      Paul Eggert authored
      * etc/refcards/Makefile (PDF_FRENCH):
      * lib-src/etags.c (LOOP_ON_INPUT_LINES):
      * lisp/dabbrev.el (dabbrev-check-other-buffers):
      * lisp/org/org-id.el (org-id-link-to-org-use-id):
      * lisp/org/org.el (org-support-shift-select, org-file-apps):
      * src/alloc.c (CHECK_ALLOCATED_AND_LIVE)
      (CHECK_ALLOCATED_AND_LIVE_SYMBOL):
      * src/frame.h (FRAME_PIXEL_WIDTH_TO_TEXT_COLS):
      * src/regex-emacs.c (PREFETCH_NOLIMIT):
      * src/window.h (WINDOW_BUFFER):
      Remove backslash-newline that immediately precedes another
      newline, as this is not the usual style and is confusing.
      54244364
  3. 28 Mar, 2019 1 commit
    • Paul Eggert's avatar
      Tweak re_registers allocation · 81795bb7
      Paul Eggert authored
      * src/regex-emacs.c (re_match_2_internal):
      No need to allocate one extra trailing search register;
      Emacs does not use it.  Avoid quadratic behavior on
      reallocation.
      81795bb7
  4. 25 Mar, 2019 2 commits
    • Paul Eggert's avatar
      Fix some integer issues in regex-emacs · b7a98993
      Paul Eggert authored
      Also, remove some duplicate comments related to thread.h.
      * src/regex-emacs.h (struct re_registers):
      * src/regex-emacs.c (SIGN_EXTEND_CHAR): Remove.
      (TALLOC, RETALLOC): Remove.  All uses replaced by usual
      allocators, which check for integer overflow.
      (extract_number): Redo without using ‘unsigned’.
      (CHARSET_RANGE_TABLE_EXISTS_P): Clearly return a boolean.
      (print_fastmap, print_partial_compiled_pattern, CHECK_INFINITE_LOOP)
      (regex_compile, analyze_first, bcmp_translate, mutually_exclusive_p)
      (re_match_2_internal):
      Use bool for booleans.
      (print_fastmap, regex_compile, execute_charset):
      Prefer int to unsigned where either will do.
      (print_double_string): Prefer ptrdiff_t to ssize_t, since the
      latter can in theory be narrower than the former.  Use fwrite
      instead of repeated putchar.
      (emacs_re_max_failures, fail_stack_type, compile_stack_type)
      (re_wctype_parse, regex_compile, re_search, re_search_2)
      (re_match_2, re_match_2_internal, re_compile_pattern):
      Prefer ptrdiff_t to size_t where either will do.
      (union fail_stack_elt, PUSH_FAILURE_REG, POP_FAILURE_REG_OR_COUNT):
      Make the integer an intptr_t, not long.
      (GET_BUFFER_SPACE, EXTEND_BUFFER, regex_compile):
      Use xpalloc to simplify allocation.
      (regex_compile): Check for integer overflow when calculating
      register numbers.
      * src/regex-emacs.c (re_set_registers, re_match_2_internal):
      * src/regex-emacs.h (struct re_registers, struct re_pattern_buffer):
      * src/search.c (Freplace_match):
      Prefer ptrdiff_t to unsigned where either will do.
      * src/regex-emacs.h (struct re_pattern_buffer):
      Prefer bool_bf to unsigned where either will do.
      b7a98993
    • Paul Eggert's avatar
      176ababa
  5. 01 Mar, 2019 1 commit
    • Alan Mackenzie's avatar
      Maintain interval ->position fields correctly in update_interval · 31182c1d
      Alan Mackenzie authored
      Also fix some anomalies in the handling of byte positions in regexp-emacs.c
      This fixes bug #34525.
      
      * src/intervals.c (SET_PARENT_POSITION): New macro.
      (update_interval): When moving to an interval's parent, set that parent's
      ->position field, to maintain the consistency of the tree.
      
      * src/intervals.h (struct interval): Amend the comment describing when
      ->position is valid.
      
      * src/pdumper.c: Update the hash associated with struct interval.
      
      * src/regex-emacs.c: (re_match_2_internal): Only invoke POINTER_TO_OFFSET on a
      known character boundary.  Only perform arithmetic on character positions, not
      on byte positions.  Correct the argument to an invocation of
      UPDATE_SYNTAX_TABLE_FORWARD by adding 1 to it (in case wordend:).
      
      * src/syntax.c: (update_syntax_table): Remove the now redundant code that set
      the ->position field of all parents of the interval found by update_interval.
      31182c1d
  6. 17 Dec, 2018 1 commit
    • Paul Eggert's avatar
      Assume ‘emacs’ is defined in Emacs-only code · 4d77c4ac
      Paul Eggert authored
      * src/charset.c, src/coding.c, src/coding.h, src/gmalloc.c:
      * src/ralloc.c, src/regex-emacs.c: Simplify slightly by
      assuming that ‘emacs’ is defined.  These modules have long
      been specific to Emacs, and are not used elsewhere.
      4d77c4ac
  7. 06 Aug, 2018 5 commits
    • Paul Eggert's avatar
      Spruce up some regex-emacs comments · 9c022a48
      Paul Eggert authored
      * src/regex-emacs.c, src/regex-emacs.h: Update comments.
      9c022a48
    • Paul Eggert's avatar
      Remove always-0 struct re_pattern_buffer members · e097826f
      Paul Eggert authored
      * src/regex-emacs.h (struct re_pattern_buffer):
      Remove no_sub, not_bol, not_eol.  They are always zero.
      All uses removed, and code simplified.
      e097826f
    • Paul Eggert's avatar
      Simplify regex-emacs by assuming Emacs syntax · 03dfb606
      Paul Eggert authored
      * src/regex-emacs.c (reg_syntax_t)
      (RE_BACKSLASH_ESCAPE_IN_LISTS, RE_BK_PLUS_QM)
      (RE_CHAR_CLASSES, RE_CONTEXT_INDEP_ANCHORS)
      (RE_CONTEXT_INDEP_OPS, RE_CONTEXT_INVALID_OPS)
      (RE_DOT_NEWLINE, RE_DOT_NOT_NULL, RE_HAT_LISTS_NOT_NEWLINE)
      (RE_INTERVALS, RE_LIMITED_OPS, RE_NEWLINE_ALT)
      (RE_NO_BK_BRACES, RE_NO_BK_PARENS, RE_NO_BK_REFS)
      (RE_NO_BK_VBAR, RE_NO_EMPTY_RANGES)
      (RE_UNMATCHED_RIGHT_PAREN_ORD, RE_NO_POSIX_BACKTRACKING)
      (RE_NO_GNU_OPS, RE_FRUGAL, RE_SHY_GROUPS)
      (RE_NO_NEWLINE_ANCHOR, RE_SYNTAX_EMACS, RE_TRANSLATE_P):
      Remove.  All uses removed and resulting code simplified.
      (TRANSLATE): Treat nil as an absent translation table, not zero.
      All uses changed.
      03dfb606
    • Paul Eggert's avatar
      Simplify regex-emacs code by assuming Emacs · 3a6abe65
      Paul Eggert authored
      * src/regex-emacs.c: Omit no-longer-needed AIX code.
      Don’t ignore GCC warnings.
      Include regex-emacs.h immediately after config.h,
      to test that it’s independent.
      Omit the "#ifndef emacs" and "#ifdef REGEX_MALLOC" and
      "#if WIDE_CHAR_SUPPORT" or "#ifdef _REGEX_RE_COMP",
      code, as we are no longer interested in compiling outside
      Emacs (with or without debugging or native wide char support)
      or in avoiding alloca.
      (REGEX_EMACS_DEBUG, regex_emacs_debug): Rename from DEBUG and debug,
      to avoid collision with other DEBUGS.  All uses changed.
      In debugging output, change %ld and %zd to %zu when appropriate.
      No need to include stddef.h, stdlib.h, sys/types.h, wchar.h,
      wctype.h, locale/localeinfo.h, locale/elem-hash.h, langinfo.h,
      libintl.h, unistd.h, stdbool.h, string.h, stdio.h, assert.h.
      All uses of assert changed to eassert.
      (RE_DUP_MAX, reg_syntax_t, RE_BACKSLASH_ESCAPE_IN_LISTS)
      (RE_BK_PLUS_QM, RE_CHAR_CLASSES, RE_CONTEXT_INDEP_ANCHORS)
      (RE_CONTEXT_INDEP_OPS, RE_CONTEXT_INVALID_OPS, RE_DOT_NEWLINE)
      (RE_DOT_NOT_NULL, RE_HAT_LISTS_NOT_NEWLINE, RE_INTERVALS)
      (RE_LIMITED_OPS, RE_NEWLINE_ALT, RE_NO_BK_BRACES)
      (RE_NO_BK_PARENS, RE_NO_BK_REFS, RE_NO_BK_VBAR)
      (RE_NO_EMPTY_RANGES, RE_UNMATCHED_RIGHT_PAREN_ORD)
      (RE_NO_POSIX_BACKTRACKING, RE_NO_GNU_OPS, RE_FRUGAL)
      (RE_SHY_GROUPS, RE_NO_NEWLINE_ANCHOR, RE_SYNTAX_EMACS)
      (REG_NOERROR, REG_NOMATCH, REG_BADPAT, REG_ECOLLATE)
      (REG_ECTYPE, REG_EESCAPE, REG_ESUBREG, REG_EBRACK, REG_EPAREN)
      (REG_EBRACE, REG_BADBR, REG_ERANGE, REG_ESPACE, REG_BADRPT)
      (REG_EEND, REG_ESIZE, REG_ERPAREN, REG_ERANGEX, REG_ESIZEBR)
      (reg_errcode_t, REGS_UNALLOCATED, REGS_REALLOCATE, REGS_FIXED)
      (RE_NREGS, RE_TRANSLATE, RE_TRANSLATE_P):
      Move here from regex-emacs.h.
      (RE_NREGS): Define unconditionally.
      (boolean): Remove.  All uses replaced by bool.
      (WIDE_CHAR_SUPPORT, regfree, regexec, regcomp, regerror):
      (re_set_syntax, re_syntax_options, WEAK_ALIAS, gettext, gettext_noop):
      Remove.  All uses removed.
      (malloc, realloc, free): Do not redefine.  Adjust all callers
      to use xmalloc, xrealloc, xfree instead.
      (re_error_msgid): Use C99 to avoid need to keep in same order
      as reg_error_t.
      (REGEX_USE_SAFE_ALLOCA): Simplify by using USE_SAFE_ALLOCA.
      (REGEX_ALLOCATE, REGEX_REALLOCATE, REGEX_FREE, REGEX_ALLOCATE_STACK)
      (REGEX_REALLOCATE_STACK, REGEX_FREE_STACK): Remove.
      All callers changed to use the non-REGEX_MALLOC version.
      (REGEX_TALLOC): Remove.  All callers changed to use SAFE_ALLOCA.
      (re_set_syntax): Remove; unused.
      (MATCH_MAY_ALLOCATE): Remove; now always true.  All uses simplified.
      (INIT_FAILURE_ALLOC): Define unconditionally.
      (re_compile_fastmap): Now static.
      (re_compile_pattern): Avoid unnecessary cast.
      * src/regex-emacs.h (EMACS_REGEX_H): Renamed from _REGEX_H to
      avoid possible collision with glibc.
      Don’t include sys/types.h.  All uses of ssize_t changed to ptrdiff_t.
      Don’t worry about C++ or VMS.
      Assume emacs is defined and that _REGEX_RE_COMP and WIDE_CHAR_SUPPORT
      are not.
      Define struct re_registers before including lisp.h.
      (REG_ENOSYS, RE_TRANSLATE_TYPE): Remove; all uses replaced by
      Lisp_Object.
      (regoff_t): Remove.  All uses replaced with ptrdiff_t.
      (re_match, regcomp, regexec, regerror, regfree):
      Remove decl of nonexistent functions.
      (RE_DEBUG, RE_SYNTAX_AWK, RE_SYNTAX_GNU_AWK)
      (RE_SYNTAX_POSIX_AWK, RE_SYNTAX_GREP, RE_SYNTAX_EGREP)
      (RE_SYNTAX_POSIX_EGREP, RE_SYNTAX_ED, RE_SYNTAX_SED)
      (_RE_SYNTAX_POSIX_COMMON, RE_SYNTAX_POSIX_BASIC)
      (RE_SYNTAX_POSIX_MINIMAL_BASIC, RE_SYNTAX_POSIX_EXTENDED)
      (RE_SYNTAX_POSIX_MINIMAL_EXTENDED, REG_EXTENDED, REG_ICASE)
      (REG_NEWLINE, REG_NOSUB, REG_NOTBOL, REG_NOTEOL, regmatch_t):
      Remove; unused.
      * src/search.c (Fset_match_data): Simplify range test now that
      we know it’s ptrdiff_t.
      3a6abe65
    • Paul Eggert's avatar
      Rename src/regex.c to src/regex-emacs.c. · e5652268
      Paul Eggert authored
      This is in preparation for using Gnulib regex for etags,
      to avoid collisions in include directives.
      * src/regex-emacs.c: Rename from src/regex.c.
      * src/regex-emacs.h: Rename from src/regex.h.  All uses changed.
      * test/src/regex-emacs-tests.el: Rename from test/src/regex-tests.el.
      e5652268
  8. 28 Jun, 2018 1 commit
    • Paul Eggert's avatar
      Tune SAFE_FREE · 76eda952
      Paul Eggert authored
      On my platform (Fedora 28 x86-64, AMD Phenom II X4 910e) this sped
      up a SAFE_FREE-using microbenchmark (string-distance "abc" "abc")
      by about 18%, and shrank the Emacs text size by about 0.1%.
      * src/callint.c (Fcall_interactively):
      * src/callproc.c (call_process):
      * src/doc.c (get_doc_string, Fsnarf_documentation):
      * src/editfns.c (Freplace_buffer_contents):
      * src/emacs-module.c (funcall_module):
      * src/eval.c (Flet):
      * src/process.c (Fmake_process):
      * src/term.c (tty_menu_show):
      * src/xdisp.c (safe__call):
      * src/xmenu.c (x_menu_show):
      Use SAFE_FREE_UNBIND_TO.
      * src/data.c (wrong_choice): No need to call SAFE_FREE here.
      * src/lisp.h (USE_SAFE_ALLOCA):
      * src/regex.c (REGEX_USE_SAFE_ALLOCA):
      Do not declare sa_must_free local; no longer needed.
      All uses removed.
      (SAFE_FREE): Rewrite in terms of safe_free.
      (safe_free): New function, optimized to use xfree.
      (SAFE_FREE_UNBIND_TO): New macro.
      (safe_free_unbind_to): New function.
      76eda952
  9. 16 Jun, 2018 1 commit
    • Daniel Colascione's avatar
      Make regex matching reentrant; update syntax during match · 938d252d
      Daniel Colascione authored
      * src/lisp.h (compile_pattern): Remove prototype of
      now-internal function.
      
      * src/regex.c (POS_AS_IN_BUFFER): Consult gl_state instead of
      re_match_object: the latter can change in Lisp.
      (re_match_2_internal): Switch back to UPDATE_SYNTAX_* FROM
      UPDATE_SYNTAX_FAST*, allowing calls into Lisp.
      
      * src/regex.h (re_match_object): Uncomment declaration.
      
      * src/search.c (struct regexp_cache): Add `busy' field.
      (thaw_buffer_relocation): Delete; rely on unbind.
      (compile_pattern_1): Assert pattern isn't busy.
      (shrink_regexp_cache): Don't shrink busy patterns.
      (clear_regexp_cache): Don't nuke busy patterns.
      (unfreeze_pattern, freeze_pattern): New functions.
      (compile_pattern): Return a regexp_cache pointer instead of the
      re_pattern_buffer, allowing callers to use `freeze_pattern' if
      needed.  Do not consider busy patterns as cache hit candidates;
      error if we run out of non-busy cache entries.
      (looking_at_1, fast_looking_at): Snapshot
      Vinhibit_changing_match_data; mark pattern busy while we're
      matching it; unbind.
      (string_match_1, fast_string_match_internal)
      (fast_c_string_match_ignore_case): Adjust for compile_pattern
      return type.
      (search_buffer_re): Regex code from old search_buffer moved here;
      snapshot Vinhibit_changing_match_data; mark pattern busy while
      we're matching it; unbind.
      (search_buffer_non_re): Non-regex code from old search_buffer
      moved here.
      (search_buffer): Split into search_buffer_re,
      search_buffer_non_re.
      (syms_of_search): Staticpro re_match_object, even though we really
      shouldn't have to.
      
      * src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
      (UPDATE_SYNTAX_TABLE_FAST): Remove.
      
      * src/thread.h (struct thread_state): Remove m_re_match_object,
      which is global again.  (It never needs to be preserved across
      thread switch.)
      938d252d
  10. 01 May, 2018 1 commit
    • Paul Eggert's avatar
      Port --enable-gcc-warnings to GCC 8 · 65ac2778
      Paul Eggert authored
      Backport from master.
      * lib-src/emacsclient.c (fail):
      Do not dereference a null pointer.
      * src/frame.c (delete_frame):
      Add a decl with UNINIT to work around GCC bug 85563.
      * src/menu.h (finish_menu_items):
      Do not use attribute const.
      * src/regex.c (analyze_first): Use FALLTHROUGH, not a comment.
      65ac2778
  11. 28 Apr, 2018 1 commit
    • Paul Eggert's avatar
      Port --enable-gcc-warnings to GCC 8 · 8c3215e7
      Paul Eggert authored
      * configure.ac: Do not use GCC 8’s new -Wcast-align flag.
      * lib-src/ebrowse.c (xmalloc):
      * lib-src/emacsclient.c (xmalloc, xstrdup):
      * lib-src/etags.c (xmalloc):
      * lib-src/make-docfile.c (xmalloc):
      * lib-src/movemail.c (xmalloc):
      * src/dispnew.c (new_glyph_pool):
      * src/regex.c (xmalloc):
      * src/term.c (tty_menu_create):
      * src/tparam.h (tparam):
      Use ATTRIBUTE_MALLOC.  Also see GCC bug 85562.
      * lib-src/emacsclient.c (fail):
      Do not dereference a null pointer.
      * src/frame.c (delete_frame):
      Add a decl with UNINIT to work around GCC bug 85563.
      * src/menu.h (finish_menu_items):
      Do not use attribute const.
      * src/regex.c (analyze_first): Use FALLTHROUGH, not a comment.
      8c3215e7
  12. 16 Feb, 2018 1 commit
  13. 27 Jan, 2018 1 commit
    • Noam Postavsky's avatar
      Raise limit of regexp repetition (Bug#24914) · 559f1606
      Noam Postavsky authored
      * src/regex.h (RE_DUP_MAX): Raise limit to 2^16-1.
      * etc/NEWS: Announce it.
      * doc/lispref/searching.texi (Regexp Backslash): Document it.
      * test/src/regex-tests.el (regex-repeat-limit): Test it.
      
      * src/regex.h (reg_errcode_t): Add REG_ESIZEBR code.
      * src/regex.c (re_error_msgid): Add corresponding entry.
      (GET_INTERVAL_COUNT): Return it instead of the more generic REG_EBADBR
      when encountering a repetition greater than RE_DUP_MAX.
      
      * lisp/isearch.el (isearch-search): Don't convert errors starting with
      "Invalid" into "incomplete".  Such errors are not incomplete, in the
      sense that they cannot be corrected by appending more characters to
      the end of the regexp.  The affected error messages are:
      
      - REG_BADPAT "Invalid regular expression"
        - \\(?X:\\) where X is not a legal group number
        - \\_X where X is not < or >
      
      - REG_ECOLLATE "Invalid collation character"
        - There is no code to throw this.
      
      - REG_ECTYPE "Invalid character class name"
        - [[:foo:] where foo is not a valid class name
      
      - REG_ESUBREG "Invalid back reference"
        - \N where N is referenced before matching group N
      
      - REG_BADBR "Invalid content of \\{\\}"
        - \\{N,M\\} where N < 0, M < N, M or N larger than max
        - \\{NX where X is not a digit or backslash
        - \\{N\\X where X is not a }
      
      - REG_ERANGE "Invalid range end"
        - There is no code to throw this.
      
      - REG_BADRPT "Invalid preceding regular expression"
        - We never throw this.  It would usually indicate a "*" with no
          preceding regexp text, but Emacs allows that to match a literal
          "*".
      559f1606
  14. 01 Jan, 2018 1 commit
  15. 03 Nov, 2017 1 commit
    • Paul Eggert's avatar
      Simplify by assuming !_MSC_VER. · 5b4ff53a
      Paul Eggert authored
      Emacs has not been portable to MSVC for some time (Bug#29040#57).
      * admin/CPP-DEFINES (_MSC_VER): Remove.
      * src/lisp.h (ENUM_BF, DEFUN):
      * src/regex.c (re_char):
      Simplify by assuming _MSC_VER is not defined.
      * src/regex.c (const_re_char): Remove.
      All uses replaced by re_char.
      5b4ff53a
  16. 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
  17. 30 Jul, 2017 1 commit
  18. 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
  19. 16 May, 2017 2 commits
    • Paul Eggert's avatar
      Pacify GCC 7 with --enable-gcc-warnings · c4ac34f2
      Paul Eggert authored
      * src/regex.c (regex_compile): Swap labels, so that the
      FALLTHROUGH immediately precedes the case label.
      c4ac34f2
    • 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.
      2e1bebe2
  20. 19 Feb, 2017 1 commit
  21. 01 Feb, 2017 1 commit
    • 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.
      33be5003
  22. 26 Jan, 2017 1 commit
    • 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.
      b3a3ed52
  23. 08 Jan, 2017 2 commits
    • Noam Postavsky's avatar
      Use expanded stack during regex matches · 13c6f1d1
      Noam Postavsky authored
      While the stack is increased in main(), to allow the regex stack
      allocation to use alloca we also need to modify regex.c to actually take
      advantage of the increased stack, and not limit stack allocations to
      SAFE_ALLOCA bytes.
      
      * src/regex.c (MATCH_MAY_ALLOCATE): Remove obsolete comment about
      allocations in signal handlers which no longer happens and correct
      description about when and why MATCH_MAY_ALLOCATE should be defined.
      (emacs_re_safe_alloca): New variable.
      (REGEX_USE_SAFE_ALLOCA): Use it as the limit of stack allocation instead
      of MAX_ALLOCA.
      (emacs_re_max_failures): Rename from `re_max_failures' to avoid
      confusion with glibc's `re_max_failures'.
      * src/emacs.c (main): Increase the amount of fixed 'extra' bytes we add
      to the stack.  Instead of changing emacs_re_max_failures based on the
      new stack size, just change emacs_re_safe_alloca; emacs_re_max_failures
      remains constant regardless, since if we run out stack space SAFE_ALLOCA
      will fall back to heap allocation.
      Co-authored-by: default avatarEli Zaretskii <eliz@gnu.org>
      13c6f1d1
    • Noam Postavsky's avatar
      Fix computation of regex stack limit · 9a19f26c
      Noam Postavsky authored
      The regex stack limit was being computed as the number of stack entries,
      whereas it was being compared with the current size as measured in
      bytes.  This could cause indefinite looping when nearing the stack limit
      if re_max_failures happened not to be a multiple of sizeof
      fail_stack_elt_t (Bug #24751).
      
      * src/regex.c (GROW_FAIL_STACK): Compute both current stack size and
      limit as numbers of stack entries.
      9a19f26c
  24. 06 Jan, 2017 1 commit
    • Philipp Stephani's avatar
      Add support for Unicode whitespace in [:blank:] · 512e9886
      Philipp Stephani authored
      See Bug#25366.
      
      * src/character.c (blankp): New function for checking Unicode
      horizontal whitespace.
      * src/regex.c (ISBLANK): Use 'blankp' for non-ASCII horizontal
      whitespace.
      (BIT_BLANK): New bit for range table.
      (re_wctype_to_bit, execute_charset): Use it.
      * test/lisp/subr-tests.el (subr-tests--string-match-p--blank): Add
      unit test for [:blank:] character class.
      * test/src/regex-tests.el (test): Adapt unit test.
      * doc/lispref/searching.texi (Char Classes): Document new Unicode
      behavior for [:blank:].
      512e9886
  25. 01 Jan, 2017 1 commit
  26. 10 Dec, 2016 1 commit
    • Eli Zaretskii's avatar
      Documentation and commentary improvements · 19bc4302
      Eli Zaretskii authored
      * src/lisp.h:
      * src/regex.c:
      * src/xgselect.c (xg_select): Improve commentary and formatting.
      
      * doc/lispref/objects.texi (Thread Type, Mutex Type)
      (Condition Variable Type): New subsections.
      (Type Predicates): Add thread-related predicates.
      * doc/lispref/objects.texi (Editing Types):
      * doc/lispref/elisp.texi (Top): Update higher-level menus.
      19bc4302
  27. 05 Dec, 2016 1 commit
  28. 26 Nov, 2016 1 commit
    • Paul Eggert's avatar
      Don't access pointers to freed storage in regex.c · b7f3a305
      Paul Eggert authored
      Remove __BOUNDED_POINTERS__ code, which does not work with
      -fcheck-pointer-bound and which has undefined behavior anyway.
      Problem found when trying to port to gcc -fcheck-pointer-bounds.
      (This code was removed from glibc and gnulib regex.c many years ago.)
      * src/regex.c (ELSE_EXTEND_BUFFER_HIGH_BOUND): Remove.
      (EXTEND_BUFFER): Use a more-portable approach that avoids
      undefined behavior due to inspecting pointers to freed storage.
      b7f3a305
  29. 26 Oct, 2016 1 commit
    • Noam Postavsky's avatar
      Revert fixes to allocation of regex matching · fee4cef7
      Noam Postavsky authored
      The fix was not complete, and completing it was proving too complicated.
      
      - Revert "* src/regex.c (re_search_2): Make new code safe for
                -Wjump-misses-init."
        This reverts commit c2a17924.
      - Revert "Port to GCC 6.2.1 + --enable-gcc-warnings"
        This reverts commit f6134bbd.
      - Revert "Fix handling of allocation in regex matching"
        This reverts commit ad66b3fa.
      - Revert "Fix handling of buffer relocation in regex.c functions"
        This reverts commit ee04aedc.
      fee4cef7
  30. 23 Oct, 2016 2 commits