• 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
thread.h 9.65 KB