1. 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
  2. 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
  3. 23 Oct, 2016 3 commits
  4. 22 Oct, 2016 1 commit
    • Noam Postavsky's avatar
      Fix handling of allocation in regex matching · ad66b3fa
      Noam Postavsky authored
      `re_match_2_internal' uses pointers to the lisp objects that it
      searches.  Since it may call malloc when growing the "fail stack", these
      pointers may be invalidated while searching, resulting in memory
      curruption (Bug #24358).
      
      To fix this, we check the pointer that the lisp object (as specified by
      re_match_object) points to before and after growing the stack, and
      update existing pointers accordingly.
      
      * src/regex.c (STR_BASE_PTR): New macro.
      (ENSURE_FAIL_STACK, re_search_2): Use it to convert pointers into
      offsets before possible malloc call, and back into pointers again
      afterwards.
      (POS_AS_IN_BUFFER): Add explanatory comment about punning trick.
      * src/search.c (search_buffer): Instead of storing search location as
      pointers, store them as pointers and recompute the corresponding address
      for each call to `re_search_2'.
      (string_match_1, fast_string_match_internal, fast_looking_at):
      * src/dired.c (directory_files_internal): Set `re_match_object' to Qnil
      after calling `re_search' or `re_match_2'.
      * src/regex.h (re_match_object): Mention new usage in commentary.
      ad66b3fa
  5. 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.
      f4eb8900
  6. 09 Sep, 2016 3 commits
    • Michal Nazarewicz's avatar
      Remove dead loop iterations in regex.c · 0e7eb640
      Michal Nazarewicz authored
      RE_CHAR_TO_MULTIBYTE(c) yields c for ASCII characters and a byte8
      character for c ≥ 0x80.  Furthermore, CHAR_BYTE8_P(c) is true only
      for byte8 characters.  This means that
      
      	c = RE_CHAR_TO_MULTIBYTE (ch);
      	if (! CHAR_BYTE8_P (c) && re_iswctype (c, cc))
      
      is equivalent to:
      
      	c = c;
      	if (! false && re_iswctype (c, cc))
      
      for 0 ⪬ c < 0x80, and
      
      	c = BYTE8_TO_CHAR (c);
      	if (! true && re_iswctype (c, cc))
      
      for 0x80 ⪬ c < 0x100.  In other words, the loop never executes for
      c ≥ 0x80 and RE_CHAR_TO_MULTIBYTE call is unnecessary for c < 0x80.
      
      * src/regex.c (regex_compile): Simplyfy a for loop by eliminating
      dead iterations and unnecessary macro calls.
      0e7eb640
    • Michal Nazarewicz's avatar
      Replace decimalnump with alphanumericp · c579b28f
      Michal Nazarewicz authored
      decimalnump was used in regex.c only in ISALNUM macro which ored it with
      alphabeticp.  Because both of those functions require Unicode general
      category lookup, this resulted in unnecessary lookups (if alphabeticp
      return false decimalp had to perform another lookup).  Drop decimalnump
      in favour of alphanumericp which combines decimelnump with alphabeticp.
      
      * src/character.c (decimalnump): Remove in favour of…
      (alphanumericp): …new function.
      
      * src/regex.c (ISALNUM): Use alphanumericp.
      c579b28f
    • Michal Nazarewicz's avatar
      Remove inaccurate comment in regex.c · b1c4c005
      Michal Nazarewicz authored
      * src/regex.c (regex_compile): Remove comment indicating that wctype of
      some character classes may be negative.  All wctypes are in fact
      non-negative.
      b1c4c005
  7. 05 Aug, 2016 1 commit
  8. 02 Aug, 2016 7 commits
    • Paul Eggert's avatar
      Port regex changes to strict ISO C · 0100805a
      Paul Eggert authored
      * src/regex.c (regex_compile): Redo casts.
      0100805a
    • Michal Nazarewicz's avatar
      Remove unused STREQ macro · edd5dd80
      Michal Nazarewicz authored
      This fixes the following compilation warning:
      
          regex.c:516:0: warning: macro "STREQ" is not used [-Wunused-macros]
           #define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
           ^
      
      * src/regex.c (STREQ): Remove unused macro.  It should have been removed
      in a [4538a5e3: Refactor regex character class parsing in [:name:]]
      commit but was mistakenly left out.
      edd5dd80
    • Michal Nazarewicz's avatar
      Hardcode regex syntax to remove dead code handling different syntax · 54a3c0c9
      Michal Nazarewicz authored
      Emacs only ever uses its own regex syntax so support for other syntaxes
      is never used.  Hardcode the syntax so that the compilar can detect such
      dead code and remove it from compiled code.
      
      The only exception is RE_NO_POSIX_BACKTRACKING which can be separatelly
      specified.  Handle this separatelly with a function argument (replacing
      now unnecessary syntax argument).
      
      With this patchset, size of Emacs binary on x86_64 machine is reduced by
      around 60 kB:
      
      	new-sizes:-rwx------ 3 mpn eng 30254720 Jul 27 23:31 src/emacs
      	old-sizes:-rwx------ 3 mpn eng 30314828 Jul 27 23:29 src/emacs
      
      * src/regex.h (re_pattern_buffer): Don’t define syntax field #ifdef emacs.
      (re_compile_pattern): Replace syntax with posix_backtracking argument.
      
      * src/regex.c (print_compiled_pattern): Don’t print syntax #ifdef emacs.
      (regex_compile): #ifdef emacs, replace syntax argument with
      posix_backtracking which is now used instead of testing for
      RE_NO_POSIX_BACKTRACKING syntax.
      (re_match_2_internal): Don’t access bufp->syntax #ifndef emacs.
      (re_compile_pattern): Replace syntax with posix_backtracking argument.
      
      * src/search.c (compile_pattern_1): Pass boolean posix_backtracking
      instead of syntax to re_compile_pattern.
      54a3c0c9
    • Michal Nazarewicz's avatar
      Get rid of re_set_whitespace_regexp · da9c55dd
      Michal Nazarewicz authored
      * src/regex.h (re_set_whitespace_regexp): Delete.
      (re_compile_pattern): Add whitespace_regexp argument #ifdef emacs.
      
      * src/regex.c (re_set_whitespace_regexp, whitespace_regexp): Delete.
      (regex_compile): Add whitespace_regexp argument #ifdef emacs and wrap
      whitespace_regexp-related code in an #ifdef emacs so it’s compiled out
      unless building Emacs.
      (re_compile_pattern): Pass whitespace_regexp argument to regex_compile
      
      * src/search.c (compile_pattern_1): Don’t use re_set_whitespace_regexp,
      pass the regex as argument to re_compile_pattern instead.
      da9c55dd
    • Michal Nazarewicz's avatar
      Get rid of re_set_syntax · 04d96eca
      Michal Nazarewicz authored
      Instead of using a global variable for storing regex syntax, pass it
      to re_compile_pattern.  This is only enabled when compiling Emacs (i.e.
      ‘#ifdef emacs’).
      
      * src/regex.h (re_set_syntax): Declare only #ifndef emacs.
      (re_compile_pattern): Now takes syntax argument #ifdef emacs.
      
      * src/regex.c (re_syntax_options): Define only #ifndef emacs.
      (re_compile_pattern): Use the new syntax argument #ifdef emacs.
      
      * src/search.c (compile_pattern_1): Don’t use re_set_syntax and
      instead pass syntax to re_compile_pattern directly.
      04d96eca
    • Michal Nazarewicz's avatar
      Remove dead opcodes in regex bytecode · 9a418e0f
      Michal Nazarewicz authored
      There is no way to specify before_dot and after_dot opcodes in a regex
      so code handling those ends up being dead.  Remove it.
      
      * src/regex.c (print_partial_compiled_pattern, regex_compile,
      analyze_first, re_match_2_internal): Remove handling and references to
      before_dot and after_dot opcodes.
      9a418e0f
    • Michal Nazarewicz's avatar
      Refactor regex character class parsing in [:name:] · 4538a5e3
      Michal Nazarewicz authored
      re_wctype function is used in three separate places and in all of
      those places almost exact code extracting the name from [:name:]
      surrounds it.  Furthermore, re_wctype requires a NUL-terminated
      string, so the name of the character class is copied to a temporary
      buffer.
      
      The code duplication and unnecessary memory copying can be avoided by
      pushing the responsibility of parsing the whole [:name:] sequence to
      the function.
      
      Furthermore, since now the function has access to the length of the
      character class name (since it’s doing the parsing), it can take
      advantage of that information in skipping some string comparisons and
      using a constant-length memcmp instead of strcmp which needs to take
      care of NUL bytes.
      
      * src/regex.c (re_wctype): Delete function.  Replace it with:
      (re_wctype_parse): New function which parses a whole [:name:] string
      and returns a RECC_* constant or -1 if the string is not of [:name:]
      format.
      (regex_compile): Use re_wctype_parse.
      * src/syntax.c (skip_chars): Use re_wctype_parse.
      4538a5e3
  9. 27 Jul, 2016 1 commit
  10. 25 Jul, 2016 1 commit
    • Michal Nazarewicz's avatar
      Fix ‘[[🇨🇨]]*literal’ regex failing to match ‘literal’ (bug#24020) · 6dc6b007
      Michal Nazarewicz authored
      The regex engine tries to optimise Kleene star by avoiding backtracking
      when it can detect that star’s operand cannot match what follows it in
      the pattern.
      
      For example, when ‘[[:alpha:]]*1’ tries to match a ‘foo’, the engine
      will test the longest match for ‘[[:alpha:]]*’, namely ’foo’ which is
      the entire string.  Literal digit one still present in the pattern will
      however not match the remaining empty string.
      
      Normally, backtracking would be performed trying a shorter match for the
      character class (namely ‘fo’ leaving ‘o’ in the string), but since the
      engine knows whatever would be put back into the string cannot possibly
      match literal digit one so no backtracking will be attempted.
      
      In the regexes of the form ‘[[:CC:]]*X’, the optimisation can be applied
      if the character class CC does not match character X.  In the above
      example, this holds because digit one is not in alpha character class.
      
      This test is performed by mutually_exclusive_p function but it did not
      check class bits of a charset opcode.  This resulted in an assumption
      that character classes do not match multibyte characters.  For example,
      it would incorrectly conclude that [[:alpha:]] doesn’t match ‘ż’.
      
      This, in turn, led to the aforementioned Kleene star optimisation being
      incorrectly applied in patterns such as ‘[[:graph:]]*’ (which should
      match ‘’ but doesn’t as can be tested by executing
          (string-match-p "[[:graph:]]*" "")
      which should return 0 but instead yields nil.
      
      This issue affects any class witch matches multibyte characters, i.e.
      if ‘[[🇨🇨]]’ matches a multibyte character X then ‘[[🇨🇨]]*X’ will
      fail to match ‘X’.
      
      * src/regex.c (executing_charset): A new function for executing the
      charset and charset_not opcodes.  It performs check on the character
      taking into consideration existing bitmap, range table and class bits.
      It also advances the pointer in the regex bytecode past the parsed
      opcode.
      (CHARSET_LOOKUP_RANGE_TABLE_RAW, CHARSET_LOOKUP_RANGE_TABLE): Removed.
      Code now included in executing_charset.
      (mutually_exclusive_p, re_match_2_internal): Changed to take advantage
      of executing_charset function.
      
      * test/src/regex-tests.el: New file with tests for the character class
      matching.
      6dc6b007
  11. 08 Jun, 2016 1 commit
  12. 30 May, 2016 2 commits
    • Paul Eggert's avatar
      Omit IF_LINT code that no longer seems needed · 237244bb
      Paul Eggert authored
      Nowadays GCC is smarter, or the Emacs code has mutated, or both,
      and now is as good a time as any to remove uses of IF_LINT that
      now seem to be unnecessary.
      * lib-src/emacsclient.c (set_local_socket):
      * lib-src/movemail.c (main) [MAIL_USE_MAILLOCK && HAVE_TOUCHLOCK]:
      * src/buffer.c (fix_start_end_in_overlays, fix_overlays_before):
      * src/casefiddle.c (casify_region):
      * src/charset.c (load_charset_map):
      * src/coding.c (decode_coding_object, encode_coding_object):
      * src/data.c (Fmake_variable_buffer_local, Fmake_local_variable)
      (cons_to_unsigned, cons_to_signed):
      * src/frame.c (make_frame, x_set_frame_parameters):
      * src/keyboard.c (read_event_from_main_queue):
      * src/regex.c (regex_compile):
      * src/syntax.c (back_comment):
      * src/window.c (Frecenter):
      * src/xfaces.c (Fx_list_fonts):
      Remove IF_LINT that no longer seems necessary.
      * src/image.c (png_load_body, jpeg_load_body): Simplify use of IF_LINT.
      * src/keyboard.c (read_char): Use IF_LINT (volatile) rather than
      a pragma dance to pacify GCC -Wclobbered.
      * src/xdisp.c (x_produce_glyphs): Rewrite to avoid need for IF_LINT.
      
      * src/xterm.c (x_connection_closed): Now _Noreturn, which should
      mean we do not need IF_LINT any more.
      (x_io_error_quitter): Now _Noreturn.  Put an 'assume (false)’
      at the end, to forestall warnings from older compilers.
      237244bb
    • Ken Brown's avatar
      060026b9
  13. 04 Apr, 2016 1 commit
    • Paul Eggert's avatar
      Port redirect-debugging-output to non-GNU/Linux · 6bccb19c
      Paul Eggert authored
      Problem reported by Kylie McClain for musl in:
      http://lists.gnu.org/archive/html/emacs-devel/2016-03/msg01592.html
      * etc/DEBUG, etc/NEWS: Mention this.
      * src/callproc.c (child_setup) [!MSDOS]:
      * src/dispnew.c (init_display):
      * src/emacs.c (main, Fdaemon_initialized):
      * src/minibuf.c (read_minibuf_noninteractive):
      * src/regex.c (xmalloc, xrealloc):
      Prefer symbolic names like STDERR_FILENO to magic numbers like 2,
      to make file-descriptor manipulation easier to follow.
      * src/emacs.c (relocate_fd) [!WINDOWSNT]: Remove; no longer needed
      now that we make sure stdin, stdout and stderr are open.  All uses
      removed.
      (main): Make sure standard FDs are OK.  Prefer symbolic names like
      EXIT_FAILURE to magic numbers like 1.  Use bool for boolean.
      * src/lisp.h (init_standard_fds): New decl.
      * src/print.c (WITH_REDIRECT_DEBUGGING_OUTPUT) [GNU_LINUX]:
      Remove; no longer needed.
      (Fredirect_debugging_output): Define on all platforms, not just
      GNU/Linux.  Redirect file descriptor, not stream, so that the code
      works even if stderr is not an lvalue.  Report an error if the
      file arg is neither a string nor nil.
      (syms_of_print): Always define redirect-debugging-output.
      * src/sysdep.c (force_open, init_standard_fds): New functions.
      6bccb19c
  14. 26 Feb, 2016 1 commit
    • Paul Eggert's avatar
      --enable-gcc-warnings now uses -Wjump-misses-init · e35f99f2
      Paul Eggert authored
      When configuring with --enable-gcc-warnings, also enable
      -Wjump-misses-init, as it’s confusing to use a goto to skip over
      an initialization.  Fix the few places in the code that run afoul
      of this warning.
      * configure.ac (WERROR_CFLAGS): Add -Wjump-misses-init.
      * src/doc.c (Fsubstitute_command_keys):
      * src/image.c (svg_load_image):
      * src/regex.c (re_match_2_internal):
      * src/xdisp.c (redisplay_internal, redisplay_window):
      Don’t jump over initialization.
      e35f99f2
  15. 20 Feb, 2016 1 commit
  16. 01 Jan, 2016 1 commit
  17. 22 Nov, 2015 1 commit
    • Stefan Monnier's avatar
      Unrevert most of regexp reentrancy abort patch · 702d76db
      Stefan Monnier authored
      The problem was in:
        * src/syntax.c (update_syntax_table_forward): Propertize even when truncated
      which is hence not unreverted.
      The rest is:
      * src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
      (UPDATE_SYNTAX_TABLE_FAST): Re-introduce.
      All callers in regex.c changed back to the _FAST versions.
      
      * test/automated/message-mode-tests.el: Tweak the test to rely on auto
      propertization in backward-sexp.
      702d76db
  18. 21 Nov, 2015 1 commit
  19. 15 Nov, 2015 1 commit
    • Paul Eggert's avatar
      Fix regex abort when it tries to reenter itself · 8121757b
      Paul Eggert authored
      Problem reported by Ken Raeburn.
      Solution suggested by Stefan Monnier (Bug#21688).
      * src/regex.c (re_match_2_internal):
      Use new _FAST functions to avoid regex code reentering itself.
      * src/syntax.c (update_syntax_table_forward): New arg PROPERTIZE.
      All callers changed.
      * src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST)
      (UPDATE_SYNTAX_TABLE_FAST): New inline functions.
      8121757b
  20. 09 Aug, 2015 1 commit
    • Paul Eggert's avatar
      Fix some minor quoting issues with grave accent · 6a45e720
      Paul Eggert authored
      * src/dispnew.c (add_window_display_history) [GLYPH_DEBUG]:
      Remove redundant quotes.
      * src/doc.c (uLSQM, uRSQM): New macros.
      * src/doc.c (Fsubstitute_command_keys):
      * src/syntax.c (Finternal_describe_syntax_value): Follow the user
      preference for quotes rather than hardcoding the ‘grave’ style.
      * src/regex.c (PUSH_FAILURE_POINT, POP_FAILURE_POINT)
      (re_match_2_internal) [DEBUG]: In debugging output, quote C
      strings with "...", not `...'.
      6a45e720
  21. 16 Apr, 2015 1 commit
    • Paul Eggert's avatar
      '[:graph:]' now excludes whitespace, not just ' ' · 3074a9fa
      Paul Eggert authored
      * doc/lispref/searching.texi (Char Classes):
      * lisp/emacs-lisp/rx.el (rx): Document [:graph:] to be [:print:]
      sans whitespace (not sans space).
      * src/character.c (graphicp): Exclude all Unicode whitespace chars,
      not just space.
      * src/regex.c (ISGRAPH): Exclude U+00A0 (NO-BREAK SPACE).
      3074a9fa
  22. 15 Apr, 2015 1 commit
    • Paul Eggert's avatar
      Make [:graph:] act like [:print:] sans space · a122a027
      Paul Eggert authored
      In POSIX [[:print:]] is equivalent to [ [:graph:]], so change
      [:graph:] so that it matches everything that [:print:] does,
      except for space.
      * doc/lispref/searching.texi (Char Classes):
      * etc/NEWS:
      * lisp/emacs-lisp/rx.el (rx):
      Document [:graph:] to be [:print:] sans ' '.
      * src/character.c, src/character.h (graphicp): New function.
      * src/regex.c (ISGRAPH) [emacs]: Use it.
      (BIT_GRAPH): New macro.
      (BIT_PRINT): Increase to 0x200, to make room for BIT_GRAPH.
      (re_wctype_to_bit) [! WIDE_CHAR_SUPPORT]:
      Return BIT_GRAPH for RECC_GRAPH.
      (re_match_2_internal) [emacs]: Use ISGRAPH if BIT_GRAPH,
      and ISPRINT if BIT_PRINT.
      a122a027
  23. 14 Apr, 2015 1 commit
    • Eli Zaretskii's avatar
      Make [:print:] support non-ASCII characters correctly · 6c284c6b
      Eli Zaretskii authored
      * src/regex.c (ISPRINT): Call 'printablep' for multibyte characters.
      (BIT_PRINT): New bit mask.
      (re_wctype_to_bit): Return BIT_PRINT for RECC_PRINT.
      * src/character.c (printablep): New function.
      * src/character.h (printablep): Add prototype.
      
      * lisp/emacs-lisp/rx.el (rx): Doc fix: document the new behavior
      of 'print', 'alnum', and 'alphabetic'.
      
      * doc/lispref/searching.texi (Char Classes): Document the new
      behavior of [:print:].
      
      * etc/NEWS: Mention the new behavior of [:print:].
      6c284c6b
  24. 28 Feb, 2015 1 commit
    • Eli Zaretskii's avatar
      Improve [:alpha:] and [:alnum:] for multibyte characters (Bug#19878) · 1a50945f
      Eli Zaretskii authored
       src/character.c (alphabeticp, decimalnump): New functions.
       src/character.h (alphabeticp, decimalnump): Add prototypes.
       src/regex.c (ISALNUM, ISALPHA): Check Unicode character properties
       for multibyte characters by calling alphabeticp and decimalnump.
       (BIT_ALPHA, BIT_ALNUM): New bit masks.
       (re_wctype_to_bit): Return them when the class is RECC_ALPHA or
       RECC_ALNUM.
       (re_match_2_internal): Call ISALPHA and ISALNUM when appropriate.
      
       doc/lispref/searching.texi (Char Classes): Update the documentation of
       [:alpha:] and [:alnum:].
      
       etc/NEWS: Mention the changes in [:alpha:] and [:alnum:].
      1a50945f
  25. 01 Jan, 2015 2 commits
  26. 14 Dec, 2014 1 commit
    • Paul Eggert's avatar
      Spelling fixes · 3de474e4
      Paul Eggert authored
      All uses changed.
      * lib-src/etags.c (analyze_regex): Rename from analyse_regex.
      * lisp/cedet/semantic/lex-spp.el:
      (semantic-lex-spp-analyzer-do-replace):
      Rename from semantic-lex-spp-anlyzer-do-replace.
      * lisp/emacs-lisp/cconv.el (cconv--analyze-use):
      Rename from cconv--analyse-use.
      (cconv--analyze-function): Rename from cconv--analyse-function.
      (cconv-analyze-form): Rename from cconv-analyse-form.
      * src/regex.c (analyze_first): Rename from analyze_first.
      3de474e4
  27. 03 Oct, 2014 1 commit
    • Dmitry Antipov's avatar
      Consistently use min and max macros from lisp.h. · 6846b003
      Dmitry Antipov authored
      * coding.c (min, max):
      * font.c (MAX):
      * unexhp9k800.c (min):
      * unexw32.c (min, max): Use definitions from lisp.h.
      * regex.c (MAX, MIN) [!emacs]: Define own max and min as such.
      Adjust users.
      * gmalloc.c (min): Tiny style change.
      6846b003
  28. 07 Sep, 2014 1 commit
    • Paul Eggert's avatar
      Use SAFE_ALLOCA etc. to avoid unbounded stack allocation. · b3bf18b3
      Paul Eggert authored
      This follows up on the recent thread in emacs-devel on alloca; see:
      http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00042.html
      This patch also cleans up alloca-related glitches noted while
      examining the code looking for unbounded alloca.
      * alloc.c (listn):
      * callproc.c (init_callproc):
      Rewrite to avoid need for alloca.
      * buffer.c (mouse_face_overlay_overlaps)
      (report_overlay_modification):
      * buffer.h (GET_OVERLAYS_AT):
      * coding.c (make_subsidiaries):
      * doc.c (Fsnarf_documentation):
      * editfns.c (Fuser_full_name):
      * fileio.c (Ffile_name_directory, Fexpand_file_name)
      (search_embedded_absfilename, Fsubstitute_in_file_name):
      * fns.c (Fmake_hash_table):
      * font.c (font_vconcat_entity_vectors, font_update_drivers):
      * fontset.c (fontset_pattern_regexp, Ffontset_info):
      * frame.c (Fmake_terminal_frame, x_set_frame_parameters)
      (xrdb_get_resource, x_get_resource_string):
      * ftfont.c (ftfont_get_charset, ftfont_check_otf, ftfont_drive_otf):
      * ftxfont.c (ftxfont_draw):
      * image.c (xbm_load, xpm_load, jpeg_load_body):
      * keyboard.c (echo_add_key, menu_bar_items, tool_bar_items):
      * keymap.c (Fdescribe_buffer_bindings, describe_map):
      * lread.c (openp):
      * menu.c (digest_single_submenu, find_and_call_menu_selection)
      (find_and_return_menu_selection):
      * print.c (PRINTFINISH):
      * process.c (Fformat_network_address):
      * scroll.c (do_scrolling, do_direct_scrolling, scrolling_1):
      * search.c (search_buffer, Fmatch_data, Fregexp_quote):
      * sound.c (wav_play, au_play):
      * syntax.c (skip_chars):
      * term.c (tty_menu_activate, tty_menu_show):
      * textprop.c (get_char_property_and_overlay):
      * window.c (Fset_window_configuration):
      * xdisp.c (safe__call, next_overlay_change, vmessage)
      (compute_overhangs_and_x, draw_glyphs, note_mouse_highlight):
      * xfaces.c (face_at_buffer_position):
      * xmenu.c (x_menu_show):
      Use SAFE_ALLOCA etc. instead of plain alloca, since the
      allocation size isn't bounded.
      * callint.c (Fcall_interactively): Redo memory_full check
      so that it can be done at compile-time on some platforms.
      * coding.c (MAX_LOOKUP_MAX): New constant.
      (get_translation_table): Use it.
      * callproc.c (call_process): Use SAFE_NALLOCA instead of
      SAFE_ALLOCA, to catch integer overflows on size calculation.
      (exec_failed) [!DOS_NT]: New function.
      (child_setup) [!DOS_NT]: Use it.
      * editfns.c (Ftranspose_regions):
      Hoist USE_SAFE_ALLOC + SAFE_FREE out of 'if'.
      * editfns.c (check_translation):
      Allocate larger buffers on the heap.
      * eval.c (internal_lisp_condition_case):
      Check for MAX_ALLOCA overflow.
      * fns.c (sort_vector): Use SAFE_ALLOCA_LISP rather than Fmake_vector.
      (Fbase64_encode_region, Fbase64_decode_region):
      Avoid unnecessary calls to SAFE_FREE before 'error'.
      * buffer.c (mouse_face_overlay_overlaps):
      * editfns.c (Fget_pos_property, check_translation):
      * eval.c (Ffuncall):
      * font.c (font_unparse_xlfd, font_find_for_lface):
      * ftfont.c (ftfont_drive_otf):
      * keyboard.c (echo_add_key, read_decoded_event_from_main_queue)
      (menu_bar_items, tool_bar_items):
      * sound.c (Fplay_sound_internal):
      * xdisp.c (load_overlay_strings, dump_glyph_row):
      Use an ordinary auto buffer rather than alloca, since the
      allocation size is fixed and small.
      * ftfont.c: Include <c-strcase.h>.
      (matching_prefix): New function.
      (get_adstyle_property): Use it, to avoid need for alloca.
      * keyboard.c (echo_add_key):
      * keymap.c (describe_map): Use ptrdiff_t, not int.
      * keyboard.c (echo_add_key): Prefer sizeof to strlen.
      * keymap.c (Fdescribe_buffer_bindings): Use SBYTES, not SCHARS,
      when counting bytes.
      * lisp.h (xlispstrdupa): Remove, replacing with ...
      (SAFE_ALLOCA_STRING): ... new macro with different API.
      This fixes a portability problem, namely, alloca result
      passed to another function.  All uses changed.
      (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Check for MAX_ALLOCA,
      not MAX_ALLOCA - 1.
      * regex.c (REGEX_USE_SAFE_ALLOCA, REGEX_SAFE_FREE)
      (REGEX_ALLOCATE): New macros.
      (REGEX_REALLOCATE, REGEX_ALLOCATE_STACK, REGEX_REALLOCATE_STACK)
      (REGEX_FREE_STACK, FREE_VARIABLES, re_match_2_internal):
      Use them.
      * xdisp.c (message3): Use SAFE_ALLOCA_STRING rather than doing it
      by hand.
      (decode_mode_spec_coding): Store directly into buf rather than
      into an alloca temporary and copying the temporary to the buf.
      
      Fixes: debbugs:18410
      b3bf18b3