1. 25 Mar, 2019 1 commit
    • 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
  2. 01 Jan, 2019 1 commit
    • Paul Eggert's avatar
      Update more copyright years · a04bf151
      Paul Eggert authored
      Update some other copyright years automatically, by running:
      Run 'UPDATE_COPYRIGHT_YEAR=2019 \
      UPDATE_COPYRIGHT_USE_INTERVALS=1 \
      UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 admin/update-copyright'
      followed by 'admin/merge-gnulib'.
      a04bf151
  3. 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 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
      Use Gnulib regex for lib-src · d904cc83
      Paul Eggert authored
      Emacs regular expressions forked from everyone else long ago.
      This makes it official and should allow simplification later.
      etags.c now uses the glibc regex API, falling back on a
      Gnulib-supplied substitute lib/regex.c if necessary.
      Emacs proper now uses its own regular expression module.
      Although this patch may look dauntingly large, most of it
      was generated automatically by admin/merge-gnulib
      and contains an exact copy of the glibc regex source,
      and the by-hand changes do not grow the Emacs source code.
      * admin/merge-gnulib (GNULIB_MODULES): Add regex.
      (AVOIDED_MODULES): Add btowc, langinfo, lock, mbrtowc, mbsinit,
      nl_langinfo, wchar, wcrtomb, wctype-h.
      * lib-src/Makefile.in (regex-emacs.o): Remove; Gnulib does it now.
      (etags_deps, etags_libs): Remove regex-emacs.o.
      * lib-src/etags.c: Go back to including regex.h.
      (add_regex): Use unsigned char translation array,
      since glibc regex requires that.
      * lib/Makefile.in (not_emacs_OBJECTS, for_emacs_OBJECTS): New macros.
      (libegnu_a_OBJECTS): Use them, to avoid building e-regex.o.
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
      * lib/regcomp.c, lib/regex.c, lib/regex.h, lib/regex_internal.c:
      * lib/regex_internal.h, lib/regexec.c, m4/builtin-expect.m4:
      * m4/eealloc.m4, m4/glibc21.m4, m4/mbstate_t.m4, m4/regex.m4:
      New files, copied from Gnulib.
      * src/regex-emacs.h, src/conf_post.h:
      (RE_TRANSLATE_TYPE, RE_TRANSLATE, RE_TRANSLATE_P):
      Move from src/conf_post.h to src/regex-emacs.h,
      so that they don’t interfere with compiling lib/regex.c.
      d904cc83
    • 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
  4. 16 Jun, 2018 2 commits
    • 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
    • Daniel Colascione's avatar
      Tweak field ordering in re_pattern_buffer · 55bc3db6
      Daniel Colascione authored
      * src/regex.h (struct re_pattern_buffer): Reorder charset_unibyte
      field to keep bitfields together.
      55bc3db6
  5. 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
  6. 01 Jan, 2018 1 commit
  7. 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
  8. 30 Jul, 2017 1 commit
  9. 08 Jan, 2017 1 commit
    • 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
  10. 01 Jan, 2017 1 commit
  11. 25 Dec, 2016 1 commit
    • Paul Eggert's avatar
      regex.h now includes sys/types.h · 615cec1d
      Paul Eggert authored
      * src/dired.c, src/emacs.c, src/search.c, src/syntax.c, src/thread.h:
      Do not include sys/types.h; no longer needed.
      * src/regex.h: Include <sys/types.h>, as that's what Gnulib and
      glibc regex.h does, and POSIX has blessed this since 2008.
      615cec1d
  12. 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
  13. 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
  14. 19 Oct, 2016 1 commit
  15. 02 Aug, 2016 4 commits
    • 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
      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
  16. 01 Jan, 2016 1 commit
  17. 16 Oct, 2015 1 commit
    • Paul Eggert's avatar
      Make src headers idempotent and standalone · 55ba8c02
      Paul Eggert authored
      Redo src/*.h so that each include file is idempotent (that is, can
      be included multiple times with the latter inclusions having no
      effect) and standalone (that is, can be included by itself,
      with no include file other than config.h needed as a prerequisite).
      This is standard practice in GNU programs nowadays.
      * lwlib/lwlib-widget.h, src/buffer.h, src/category.h, src/character.h:
      * src/charset.h, src/coding.h, src/commands.h, src/disptab.h:
      * src/fontset.h, src/gnutls.h, src/indent.h, src/keymap.h, src/macros.h:
      * src/regex.h [emacs]:
      * src/syntax.h, src/systty.h, src/termhooks.h:
      Include lisp.h, for Lisp_Object.
      * src/buffer.h, src/category.h, src/cm.h, src/commands.h, src/disptab.h:
      * src/indent.h, src/intervals.h, src/keyboard.h, src/macros.h:
      * src/process.h, src/puresize.h, src/region-cache.h, src/syntax.h:
      * src/syssignal.h, src/sysstdio.h, src/systty.h, src/termchar.h:
      * src/termopts.h, src/tparam.h, src/unexec.h:
      Protect against multiple inclusion.
      * src/buffer.h: Include character.h, for STRING_CHAR.
      * src/emacsgtkfixed.h (struct frame):
      * src/fontset.h (struct face):
      * src/region-cache.h (struct buffer):
      * src/termhooks.h (struct glyph):
      * src/xsettings.h (struct x_display_info):
      Add possibly-forward decl.
      * src/syntax.h: Include buffer.h, for BVAR.
      * src/sysselect.h: Include lisp.h, for eassume.
      * src/termchar.h: Include <stdio.h>, for FILE.
      * src/widget.h: Include <X11/IntrinsicP.h>, for Widget.
      * src/xsettings.h: Include <X11/Xlib.h>, for XEvent.
      55ba8c02
  18. 17 Aug, 2015 1 commit
    • Paul Eggert's avatar
      Curved quotes in --batch diagnostics in non-UTF-8 · 7f2b98d0
      Paul Eggert authored
      When run with --batch, check that curved quotes are compatible with
      the system locale before outputting them in diagnostics.
      Problem reported by Eli Zaretskii in:
      http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00594.html
      * lisp/startup.el (command-line): Set internal--text-quoting-flag
      after the standard display table is initialized.
      * src/doc.c (default_to_grave_quoting_style): New function.
      (text_quoting_style): Use it.
      (text_quoting_flag): New static var, visible to Lisp as
      internal--text-quoting-flag.
      * src/emacs.c: Include <wchar.h> if available.
      (using_utf8): New function.
      (main): Use it to initialize text_quoting_flag.
      * src/regex.h (btowc) [WIDE_CHAR_SUPPORT && emacs]:
      Don't define, as it's not needed and it clashes with wchar.h.
      7f2b98d0
  19. 01 Jan, 2015 2 commits
  20. 01 Sep, 2014 1 commit
    • Paul Eggert's avatar
      Clean up extern decls a bit. · 1564080f
      Paul Eggert authored
      * configure.ac (WERROR_CFLAGS): Don't disable -Wnested-externs.
      While we're at it, don't disable -Wlogical-op either.
      * src/bytecode.c: Include blockinput.h and keyboard.h rather
      than rolling their APIs by hand.
      * src/emacs.c: Include regex.h and rely on its and lisp.h's API
      rather than rolling them by hand.
      * src/lastfile.c: Include lisp.h, to check this file's API.
      * src/lisp.h (lisp_eval_depth, my_edata, my_endbss, my_endbss_static):
      New decls.
      * src/regex.h (re_max_failures): New decl.
      * src/unexcw.c, src/unexmacosx.c, src/unexw32.c:
      Rely on lisp.h's API rather than rolling it by hand.
      * src/vm-limit.c (__after_morecore_hook, __morecore, real_morecore):
      Declare at top level, to pacify GCC -Wnested-externs.
      1564080f
  21. 01 Jan, 2014 1 commit
  22. 29 Oct, 2013 1 commit
    • Dmitry Antipov's avatar
      Prefer 'unsigned long' to 'long unsigned int' and 'unsigned long int'. · 2d9783e0
      Dmitry Antipov authored
      * ftxfont.c (ftxfont_get_gcs):
      * gtkutil.c (xg_set_widget_bg, xg_set_background_color):
      * xfaces.c (x_free_colors, x_free_dpy_colors)
      (x_create_gc, unload_color):
      * xselect.c (x_property_data_to_lisp):
      * xsettings.c (parse_settings):
      * xterm.c (x_copy_color, x_alloc_lighter_color, x_setup_relief_color)
      (get_bits_and_offset): Adjust definition.
      * frame.c (XParseGeometry): Adjust locals.
      * lisp.h (toplevel): Adjust EMACS_UINT type definition.
      * regex.h (toplevel): Likewise for reg_syntax_t.
      2d9783e0
  23. 10 Jul, 2013 1 commit
    • Paul Eggert's avatar
      Port to C89. · 29abe551
      Paul Eggert authored
      * lib-src/ebrowse.c (USAGE): Remove macro with too-long string literal ...
      (usage_message): ... and replace it with this new static constant
      containing multiple literals.  All uses changed.
      * lib-src/emacsclient.c (print_help_and_exit):
      Rewrite to avoid string literals longer than the C89 limits.
      (start_daemon_and_retry_set_socket):
      Rewrite to avoid non-constant array initializer.
      * lib-src/make-docfile.c (enum global_type): Omit trailing comma.
      * src/bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
      (B__dummy__): New dummy symbol, to pacify C89.
      * src/dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
      they can't grok varargs macros.
      * src/dispnew.c (add_window_display_history)
      (add_frame_display_history):
      * src/print.c (print_object):
      * src/xdisp.c (debug_method_add):
      Use %p printf format only for void pointers.
      * src/emacs.c (usage_message): New constant, replacing ...
      (USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
      (main): Adjust to usage reorg.
      * src/fns.c (syms_of_fns):
      * src/profiler.c (syms_of_profiler):
      Don't use non-constant struct initializers.
      * src/gnutls.h (gnutls_initstage_t):
      * src/lisp.h (enum Lisp_Fwd_Type):
      * src/lread.c (lisp_file_lexically_bound_p):
      * src/xsettings.c (anonymous enum):
      Remove trailing comma.
      * src/xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
      * src/lisp.h (ENUM_BF): Use unsigned if pedantic.
      (DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
      (DEFUN): Use it.
      * src/regex.c (const_re_char): New type, to pacify strict C89.
      All uses of 'const re_char' replaced to use it.
      * src/regex.h (_Restrict_): Rename from __restrict, to avoid clash
      with glibc when strict C89.  This change is imported from gnulib.
      All uses changed.
      (_Restrict_arr_): Rename from __restrict_arr, similarly.
      * src/sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
      Omit GNU_LINUX implementation, since it requires long long.
      * src/xterm.c (x_draw_underwave):
      Do not assume the traditional order of struct's members.
      (x_term_init): Rewrite to avoid the need for non-constant structure
      initializers.
      29abe551
  24. 24 Mar, 2013 1 commit
    • Andreas Schwab's avatar
      Reorder conditions that are written backwards · 908589fd
      Andreas Schwab authored
      * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are
      written backwards.
      * blockinput.h (input_blocked_p): Likewise.
      * bytecode.c (exec_byte_code): Likewise.
      * callproc.c (call_process_kill, call_process_cleanup)
      (Fcall_process): Likewise.
      * ccl.c (ccl_driver, resolve_symbol_ccl_program)
      (Fccl_execute_on_string): Likewise.
      * character.c (string_escape_byte8): Likewise.
      * charset.c (read_hex): Likewise.
      * cm.c (calccost): Likewise.
      * data.c (cons_to_unsigned): Likewise.
      * dired.c (directory_files_internal, file_name_completion):
      Likewise.
      * dispnew.c (scrolling_window, update_frame_1, Fsleep_for)
      (sit_for): Likewise.
      * doc.c (Fsubstitute_command_keys): Likewise.
      * doprnt.c (doprnt): Likewise.
      * editfns.c (hi_time, decode_time_components, Fformat): Likewise.
      * emacsgtkfixed.c: Likewise.
      * fileio.c (file_offset, Fwrite_region): Likewise.
      * floatfns.c (Fexpt, fmod_float): Likewise.
      * fns.c (larger_vector, make_hash_table, Fmake_hash_table):
      Likewise.
      * font.c (font_intern_prop): Likewise.
      * frame.c (x_set_alpha): Likewise.
      * gtkutil.c (get_utf8_string): Likewise.
      * indent.c (check_display_width): Likewise.
      * intervals.c (create_root_interval, rotate_right, rotate_left)
      (split_interval_right, split_interval_left)
      (adjust_intervals_for_insertion, delete_node)
      (interval_deletion_adjustment, adjust_intervals_for_deletion)
      (merge_interval_right, merge_interval_left, copy_intervals)
      (set_intervals_multibyte_1): Likewise.
      * keyboard.c (gobble_input, append_tool_bar_item): Likewise.
      * keymap.c (Fkey_description): Likewise.
      * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise.
      * lread.c (openp, read_integer, read1, string_to_number):
      Likewise.
      * menu.c (ensure_menu_items): Likewise.
      * minibuf.c (read_minibuf_noninteractive): Likewise.
      * print.c (printchar, strout): Likewise.
      * process.c (create_process, Faccept_process_output)
      (wait_reading_process_output, read_process_output, send_process)
      (wait_reading_process_output): Likewise.
      * profiler.c (make_log, handle_profiler_signal): Likewise.
      * regex.c (re_exec): Likewise.
      * regex.h: Likewise.
      * search.c (looking_at_1, Freplace_match): Likewise.
      * sysdep.c (get_child_status, procfs_ttyname)
      (procfs_get_total_memory): Likewise.
      * systime.h (EMACS_TIME_VALID_P): Likewise.
      * term.c (dissociate_if_controlling_tty): Likewise.
      * window.c (get_phys_cursor_glyph): Likewise.
      * xdisp.c (init_iterator, redisplay_internal, redisplay_window)
      (try_window_reusing_current_matrix, try_window_id, pint2hrstr):
      Likewise.
      * xfns.c (Fx_window_property): Likewise.
      * xmenu.c (set_frame_menubar): Likewise.
      * xselect.c (x_get_window_property, x_handle_dnd_message):
      Likewise.
      * xsmfns.c (smc_save_yourself_CB): Likewise.
      * xterm.c (x_scroll_bar_set_handle): Likewise.
      908589fd
  25. 01 Jan, 2013 1 commit
  26. 31 Dec, 2012 1 commit
  27. 15 Aug, 2012 1 commit
    • Tom Tromey's avatar
      This introduces a thread-state object and moves various C globals · 68b32482
      Tom Tromey authored
      there.  It also introduces #defines for these globals to avoid a
      monster patch.
      
      The #defines mean that this patch also has to rename a few fields
      whose names clash with the defines.
      
      There is currently just a single "thread"; so this patch does not
      impact Emacs behavior in any significant way.
      68b32482
  28. 21 May, 2012 1 commit
    • Paul Eggert's avatar
      Assume C89 or later. · 261cb4bb
      Paul Eggert authored
      * configure.in (AC_C_PROTOTYPES, AC_C_VOLATILE, AC_C_CONST)
      (POINTER_TYPE, PROTOTYPES): Remove.
      * admin/CPP-DEFINES: Remove NULL, const.
      * lib-src/etags.c (static, const): Remove macros.
      (PTR): Remove; all uses replaced with void *.  Omit needless casts.
      * src/alloc.c, src/buffer.c, lisp.h: Replace POINTER_TYPE with void.
      * alloc.c (overrun_check_malloc, overrun_check_realloc, xmalloc)
      (xrealloc):
      * buffer.c (mmap_free_1, mmap_enlarge): Omit needless casts.
      * editfns.c, fns.c, gmalloc.c, insdel.c, sysdep.c, termcap.c (NULL):
      * textprop.c, tparam.c (NULL): Remove.
      * ralloc.c, vm-limit.c (POINTER): Assume void * works.
      * regex.c (SIGN_EXTEND_CHAR): Assume signed char works.
      * regex.h (_RE_ARGS): Remove.  All uses rewritten to use prototypes.
      * unexelf.c (ElfBitsW): Assume c89 preprocessor or better.
      * xterm.c (input_signal_count): Assume volatile works.
      261cb4bb
  29. 11 Jan, 2012 1 commit
  30. 05 Jan, 2012 1 commit
  31. 05 Dec, 2011 1 commit