diff options
| author | Paul Eggert | 2018-08-05 18:41:20 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-05 19:36:09 -0700 |
| commit | 3a6abe65c1324361bf0efcb65df61d22a39cfaaf (patch) | |
| tree | 90ecb27f9ecbb8a0f8d9b24cf67a809b52b0b32d /src/search.c | |
| parent | d904cc83f3036db96107a3976cee1a0112547de6 (diff) | |
| download | emacs-3a6abe65c1324361bf0efcb65df61d22a39cfaaf.tar.gz emacs-3a6abe65c1324361bf0efcb65df61d22a39cfaaf.zip | |
Simplify regex-emacs code by assuming Emacs
* 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.
Diffstat (limited to 'src/search.c')
| -rw-r--r-- | src/search.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/search.c b/src/search.c index d4b03220412..f758bb9304a 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -59,8 +59,8 @@ static struct regexp_cache searchbufs[REGEXP_CACHE_SIZE]; | |||
| 59 | static struct regexp_cache *searchbuf_head; | 59 | static struct regexp_cache *searchbuf_head; |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | /* Every call to re_match, etc., must pass &search_regs as the regs | 62 | /* Every call to re_search, etc., must pass &search_regs as the regs |
| 63 | argument unless you can show it is unnecessary (i.e., if re_match | 63 | argument unless you can show it is unnecessary (i.e., if re_search |
| 64 | is certainly going to be called again before region-around-match | 64 | is certainly going to be called again before region-around-match |
| 65 | can be called). | 65 | can be called). |
| 66 | 66 | ||
| @@ -2189,8 +2189,8 @@ set_search_regs (ptrdiff_t beg_byte, ptrdiff_t nbytes) | |||
| 2189 | the match position. */ | 2189 | the match position. */ |
| 2190 | if (search_regs.num_regs == 0) | 2190 | if (search_regs.num_regs == 0) |
| 2191 | { | 2191 | { |
| 2192 | search_regs.start = xmalloc (2 * sizeof (regoff_t)); | 2192 | search_regs.start = xmalloc (2 * sizeof *search_regs.start); |
| 2193 | search_regs.end = xmalloc (2 * sizeof (regoff_t)); | 2193 | search_regs.end = xmalloc (2 * sizeof *search_regs.end); |
| 2194 | search_regs.num_regs = 2; | 2194 | search_regs.num_regs = 2; |
| 2195 | } | 2195 | } |
| 2196 | 2196 | ||
| @@ -3001,9 +3001,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) | |||
| 3001 | memory_full (SIZE_MAX); | 3001 | memory_full (SIZE_MAX); |
| 3002 | search_regs.start = | 3002 | search_regs.start = |
| 3003 | xpalloc (search_regs.start, &num_regs, length - num_regs, | 3003 | xpalloc (search_regs.start, &num_regs, length - num_regs, |
| 3004 | min (PTRDIFF_MAX, UINT_MAX), sizeof (regoff_t)); | 3004 | min (PTRDIFF_MAX, UINT_MAX), sizeof *search_regs.start); |
| 3005 | search_regs.end = | 3005 | search_regs.end = |
| 3006 | xrealloc (search_regs.end, num_regs * sizeof (regoff_t)); | 3006 | xrealloc (search_regs.end, num_regs * sizeof *search_regs.end); |
| 3007 | 3007 | ||
| 3008 | for (i = search_regs.num_regs; i < num_regs; i++) | 3008 | for (i = search_regs.num_regs; i < num_regs; i++) |
| 3009 | search_regs.start[i] = -1; | 3009 | search_regs.start[i] = -1; |
| @@ -3058,12 +3058,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) | |||
| 3058 | XSETFASTINT (marker, 0); | 3058 | XSETFASTINT (marker, 0); |
| 3059 | 3059 | ||
| 3060 | CHECK_NUMBER_COERCE_MARKER (marker); | 3060 | CHECK_NUMBER_COERCE_MARKER (marker); |
| 3061 | if ((XINT (from) < 0 | 3061 | if (PTRDIFF_MIN <= XINT (from) && XINT (from) <= PTRDIFF_MAX |
| 3062 | ? TYPE_MINIMUM (regoff_t) <= XINT (from) | 3062 | && PTRDIFF_MIN <= XINT (marker) |
| 3063 | : XINT (from) <= TYPE_MAXIMUM (regoff_t)) | 3063 | && XINT (marker) <= PTRDIFF_MAX) |
| 3064 | && (XINT (marker) < 0 | ||
| 3065 | ? TYPE_MINIMUM (regoff_t) <= XINT (marker) | ||
| 3066 | : XINT (marker) <= TYPE_MAXIMUM (regoff_t))) | ||
| 3067 | { | 3064 | { |
| 3068 | search_regs.start[i] = XINT (from); | 3065 | search_regs.start[i] = XINT (from); |
| 3069 | search_regs.end[i] = XINT (marker); | 3066 | search_regs.end[i] = XINT (marker); |