X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=regex.c;h=ac6ede9ebe925b43b3115da012fc45a34d7722e5;hp=ddd42284013d3ec8d20f07e5ac24e8ddf34f177d;hb=5945a5016adb82ec9a29c9f7741cea269484e608;hpb=0d23a37d51884266b694d3a94300ddb5c3faf4fa diff --git a/regex.c b/regex.c index ddd4228..ac6ede9 100644 --- a/regex.c +++ b/regex.c @@ -177,29 +177,29 @@ enum { MUTT_ALNUM = static int ctype (const char *name) { - if (0 == mutt_strcmp (name, "alnum")) + if (0 == strcmp (name, "alnum")) return MUTT_ALNUM; - if (0 == mutt_strcmp (name, "alpha")) + if (0 == strcmp (name, "alpha")) return MUTT_ALPHA; - if (0 == mutt_strcmp (name, "blank")) + if (0 == strcmp (name, "blank")) return MUTT_BLANK; - if (0 == mutt_strcmp (name, "cntrl")) + if (0 == strcmp (name, "cntrl")) return MUTT_CNTRL; - if (0 == mutt_strcmp (name, "digit")) + if (0 == strcmp (name, "digit")) return MUTT_DIGIT; - if (0 == mutt_strcmp (name, "graph")) + if (0 == strcmp (name, "graph")) return MUTT_GRAPH; - if (0 == mutt_strcmp (name, "lower")) + if (0 == strcmp (name, "lower")) return MUTT_LOWER; - if (0 == mutt_strcmp (name, "print")) + if (0 == strcmp (name, "print")) return MUTT_PRINT; - if (0 == mutt_strcmp (name, "punct")) + if (0 == strcmp (name, "punct")) return MUTT_PUNCT; - if (0 == mutt_strcmp (name, "space")) + if (0 == strcmp (name, "space")) return MUTT_SPACE; - if (0 == mutt_strcmp (name, "upper")) + if (0 == strcmp (name, "upper")) return MUTT_UPPER; - if (0 == mutt_strcmp (name, "xdigit")) + if (0 == strcmp (name, "xdigit")) return MUTT_XDIGIT; return MUTT_INVALID; } @@ -313,7 +313,7 @@ static void init_syntax_once () #define REGEX_ALLOCATE malloc #define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) -#define REGEX_FREE free +#define REGEX_mem_free free #else /* not REGEX_MALLOC */ @@ -346,7 +346,7 @@ char *alloca (); destination) /* No need to do anything to free, after alloca. */ -#define REGEX_FREE(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */ +#define REGEX_mem_free(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */ #endif /* not REGEX_MALLOC */ @@ -358,7 +358,7 @@ char *alloca (); r_alloc (&failure_stack_ptr, (size)) #define REGEX_REALLOCATE_STACK(source, osize, nsize) \ r_re_alloc (&failure_stack_ptr, (nsize)) -#define REGEX_FREE_STACK(ptr) \ +#define REGEX_mem_free_STACK(ptr) \ r_alloc_free (&failure_stack_ptr) #else /* not using relocating allocator */ @@ -367,7 +367,7 @@ char *alloca (); #define REGEX_ALLOCATE_STACK malloc #define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize) -#define REGEX_FREE_STACK free +#define REGEX_mem_free_STACK free #else /* not REGEX_MALLOC */ @@ -376,7 +376,7 @@ char *alloca (); #define REGEX_REALLOCATE_STACK(source, osize, nsize) \ REGEX_REALLOCATE (source, osize, nsize) /* No need to explicitly free anything. */ -#define REGEX_FREE_STACK(arg) +#define REGEX_mem_free_STACK(arg) #endif /* not REGEX_MALLOC */ #endif /* not using relocating allocator */ @@ -397,7 +397,7 @@ char *alloca (); #define BYTEWIDTH 8 /* In bits. */ -#define STREQ(s1, s2) ((mutt_strcmp (s1, s2) == 0)) +#define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) #undef MAX #undef MIN @@ -1156,7 +1156,7 @@ typedef struct { fail_stack.avail = 0; \ } while (0) -#define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack) +#define RESET_FAIL_STACK() REGEX_mem_free_STACK (fail_stack.stack) #else #define INIT_FAIL_STACK() \ do { \ @@ -1808,7 +1808,7 @@ static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type examined nor set. */ /* Return, freeing storage we allocated. */ -#define FREE_STACK_RETURN(value) \ +#define mem_free_STACK_RETURN(value) \ return (free (compile_stack.stack), value) /* __MEM_CHECKED__ */ #ifndef HAVE_ISCTYPE @@ -1946,7 +1946,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } if (!bufp->buffer) - FREE_STACK_RETURN (REG_ESPACE); + mem_free_STACK_RETURN (REG_ESPACE); bufp->allocated = INIT_BUF_SIZE; } @@ -1998,7 +1998,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* If there is no previous pattern... */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) - FREE_STACK_RETURN (REG_BADRPT); + mem_free_STACK_RETURN (REG_BADRPT); else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto normal_char; } @@ -2029,7 +2029,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) else if (syntax & RE_BK_PLUS_QM && c == '\\') { if (p == pend) - FREE_STACK_RETURN (REG_EESCAPE); + mem_free_STACK_RETURN (REG_EESCAPE); PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) { @@ -2123,7 +2123,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) boolean had_char_class = false; if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ @@ -2154,14 +2154,14 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* Read in characters and ranges, setting map bits. */ for (;;) { if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { if (p == pend) - FREE_STACK_RETURN (REG_EESCAPE); + mem_free_STACK_RETURN (REG_EESCAPE); PATFETCH (c1); SET_LIST_BIT (c1); @@ -2177,7 +2177,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* Look ahead to see if it's a range when the last thing was a character class. */ if (had_char_class && c == '-' && *p != ']') - FREE_STACK_RETURN (REG_ERANGE); + mem_free_STACK_RETURN (REG_ERANGE); /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the @@ -2189,7 +2189,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) reg_errcode_t ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) - FREE_STACK_RETURN (ret); + mem_free_STACK_RETURN (ret); } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ @@ -2200,7 +2200,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) - FREE_STACK_RETURN (ret); + mem_free_STACK_RETURN (ret); } /* See if we're at the beginning of a possible character @@ -2214,7 +2214,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* If pattern is `[[:'. */ if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); for (;;) { PATFETCH (c); @@ -2237,14 +2237,14 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) wt = ctype (str); if (wt == 0) - FREE_STACK_RETURN (REG_ECTYPE); + mem_free_STACK_RETURN (REG_ECTYPE); /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); for (ch = 0; ch < 1 << BYTEWIDTH; ++ch) { if (isctype (ch, wt)) @@ -2272,14 +2272,14 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) boolean is_xdigit = STREQ (str, "xdigit"); if (!IS_CHAR_CLASS (str)) - FREE_STACK_RETURN (REG_ECTYPE); + mem_free_STACK_RETURN (REG_ECTYPE); /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) - FREE_STACK_RETURN (REG_EBRACK); + mem_free_STACK_RETURN (REG_EBRACK); for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { /* This was split into 3 if's to @@ -2367,7 +2367,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) case '\\': if (p == pend) - FREE_STACK_RETURN (REG_EESCAPE); + mem_free_STACK_RETURN (REG_EESCAPE); /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would @@ -2431,7 +2431,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) { goto normal_backslash; } else { - FREE_STACK_RETURN (REG_ERPAREN); + mem_free_STACK_RETURN (REG_ERPAREN); } } @@ -2452,7 +2452,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) { goto normal_char; } else { - FREE_STACK_RETURN (REG_ERPAREN); + mem_free_STACK_RETURN (REG_ERPAREN); } } @@ -2558,7 +2558,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else - FREE_STACK_RETURN (REG_EBRACE); + mem_free_STACK_RETURN (REG_EBRACE); } GET_UNSIGNED_NUMBER (lower_bound); @@ -2577,12 +2577,12 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else - FREE_STACK_RETURN (REG_BADBR); + mem_free_STACK_RETURN (REG_BADBR); } if (!(syntax & RE_NO_BK_BRACES)) { if (c != '\\') - FREE_STACK_RETURN (REG_EBRACE); + mem_free_STACK_RETURN (REG_EBRACE); PATFETCH (c); } @@ -2591,7 +2591,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else - FREE_STACK_RETURN (REG_BADBR); + mem_free_STACK_RETURN (REG_BADBR); } /* We just parsed a valid interval. */ @@ -2599,7 +2599,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) /* If it's invalid to have no preceding re. */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) - FREE_STACK_RETURN (REG_BADRPT); + mem_free_STACK_RETURN (REG_BADRPT); else if (syntax & RE_CONTEXT_INDEP_OPS) laststart = b; else @@ -2783,7 +2783,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) c1 = c - '0'; if (c1 > regnum) - FREE_STACK_RETURN (REG_ESUBREG); + mem_free_STACK_RETURN (REG_ESUBREG); /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, (regnum_t) c1)) @@ -2850,7 +2850,7 @@ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); if (!COMPILE_STACK_EMPTY) - FREE_STACK_RETURN (REG_EPAREN); + mem_free_STACK_RETURN (REG_EPAREN); /* If we don't want backtracking, force success the first time we reach the end of the compiled pattern. */ @@ -3634,22 +3634,22 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, /* Free everything we malloc. */ #ifdef MATCH_MAY_ALLOCATE -#define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL -#define FREE_VARIABLES() \ +#define mem_free_VAR(var) if (var) REGEX_mem_free (var); var = NULL +#define mem_free_VARIABLES() \ do { \ - REGEX_FREE_STACK (fail_stack.stack); \ - FREE_VAR (regstart); \ - FREE_VAR (regend); \ - FREE_VAR (old_regstart); \ - FREE_VAR (old_regend); \ - FREE_VAR (best_regstart); \ - FREE_VAR (best_regend); \ - FREE_VAR (reg_info); \ - FREE_VAR (reg_dummy); \ - FREE_VAR (reg_info_dummy); \ + REGEX_mem_free_STACK (fail_stack.stack); \ + mem_free_VAR (regstart); \ + mem_free_VAR (regend); \ + mem_free_VAR (old_regstart); \ + mem_free_VAR (old_regend); \ + mem_free_VAR (best_regstart); \ + mem_free_VAR (best_regend); \ + mem_free_VAR (reg_info); \ + mem_free_VAR (reg_dummy); \ + mem_free_VAR (reg_info_dummy); \ } while (0) #else -#define FREE_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */ +#define mem_free_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */ #endif /* not MATCH_MAY_ALLOCATE */ /* These values must meet several constraints. They must not be valid @@ -3887,13 +3887,13 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) if (!(regstart && regend && old_regstart && old_regend && reg_info && best_regstart && best_regend && reg_dummy && reg_info_dummy)) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -2; } } else { /* We must initialize all our variables to NULL, so that - `FREE_VARIABLES' doesn't try to free them. */ + `mem_free_VARIABLES' doesn't try to free them. */ regstart = regend = old_regstart = old_regend = best_regstart = best_regend = reg_dummy = NULL; reg_info = reg_info_dummy = (register_info_type *) NULL; @@ -3902,7 +3902,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) /* The starting position is bogus. */ if (pos < 0 || pos > size1 + size2) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -1; } @@ -4047,7 +4047,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -2; } bufp->regs_allocated = REGS_REALLOCATE; @@ -4060,7 +4060,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) RETALLOC (regs->start, regs->num_regs, regoff_t); RETALLOC (regs->end, regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) { - FREE_VARIABLES (); + mem_free_VARIABLES (); return -2; } } @@ -4113,7 +4113,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); - FREE_VARIABLES (); + mem_free_VARIABLES (); return mcnt; } @@ -5054,7 +5054,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) if (best_regs_set) goto restore_best_regs; - FREE_VARIABLES (); + mem_free_VARIABLES (); return -1; /* Failure to match. */ } /* re_match_2 */ @@ -5390,7 +5390,7 @@ re_comp (s) /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; - ret = regex_compile (s, mutt_strlen (s), re_syntax_options, &re_comp_buf); + ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); if (!ret) return NULL; @@ -5407,7 +5407,7 @@ int re_exec (s) const char *s; { - const int len = mutt_strlen (s); + const int len = strlen (s); return 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); @@ -5504,8 +5504,8 @@ int regcomp (preg, pattern, cflags) preg->no_sub = !!(cflags & REG_NOSUB); /* POSIX says a null character in the pattern terminates it, so we - can use mutt_strlen here in compiling the pattern. */ - ret = regex_compile (pattern, mutt_strlen (pattern), syntax, preg); + can use strlen here in compiling the pattern. */ + ret = regex_compile (pattern, strlen (pattern), syntax, preg); /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ @@ -5540,7 +5540,7 @@ int regexec (preg, string, nmatch, pmatch, eflags) int ret; struct re_registers regs; regex_t private_preg; - int len = mutt_strlen (string); + int len = strlen (string); boolean want_reg_info = !preg->no_sub && nmatch > 0; private_preg = *preg; @@ -5609,7 +5609,7 @@ size_t regerror (errcode, preg, errbuf, errbuf_size) msg = gettext (re_error_msgid[errcode]); - msg_size = mutt_strlen (msg) + 1; /* Includes the null. */ + msg_size = strlen (msg) + 1; /* Includes the null. */ if (errbuf_size != 0) { if (msg_size > errbuf_size) {