X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/2a64315a111fb4da67e9c40c9b69045c4f63d619..8fb3179241c11eef948f612d959521ac31af1560:/src/regex.c diff --git a/src/regex.c b/src/regex.c index 46065dda9e..0187a103b3 100644 --- a/src/regex.c +++ b/src/regex.c @@ -2,9 +2,7 @@ 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the internationalization features.) - Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + Copyright (C) 1993-2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -196,18 +194,12 @@ even if config.h says that we can. */ # undef REL_ALLOC -# if defined STDC_HEADERS || defined _LIBC -# include -# else -char *malloc (); -char *realloc (); -# endif +# include /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ void * -xmalloc (size) - size_t size; +xmalloc (size_t size) { register void *val; val = (void *) malloc (size); @@ -220,9 +212,7 @@ xmalloc (size) } void * -xrealloc (block, size) - void *block; - size_t size; +xrealloc (void *block, size_t size) { register void *val; /* We must call malloc explicitly when BLOCK is 0, since some @@ -248,37 +238,16 @@ xrealloc (block, size) # endif # define realloc xrealloc -/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow. - If nothing else has been done, use the method below. */ -# ifdef INHIBIT_STRING_HEADER -# if !(defined HAVE_BZERO && defined HAVE_BCOPY) -# if !defined bzero && !defined bcopy -# undef INHIBIT_STRING_HEADER -# endif +/* This is the normal way of making sure we have memcpy, memcmp and memset. */ +# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC +# include +# else +# include +# ifndef memcmp +# define memcmp(s1, s2, n) bcmp (s1, s2, n) # endif -# endif - -/* This is the normal way of making sure we have memcpy, memcmp and bzero. - This is used in most programs--a few other programs avoid this - by defining INHIBIT_STRING_HEADER. */ -# ifndef INHIBIT_STRING_HEADER -# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC -# include -# ifndef bzero -# ifndef _LIBC -# define bzero(s, n) (memset (s, '\0', n), (s)) -# else -# define bzero(s, n) __bzero (s, n) -# endif -# endif -# else -# include -# ifndef memcmp -# define memcmp(s1, s2, n) bcmp (s1, s2, n) -# endif -# ifndef memcpy -# define memcpy(d, s, n) (bcopy (s, d, n), (d)) -# endif +# ifndef memcpy +# define memcpy(d, s, n) (bcopy (s, d, n), (d)) # endif # endif @@ -456,7 +425,7 @@ extern char *re_syntax_table; static char re_syntax_table[CHAR_SET_SIZE]; static void -init_syntax_once () +init_syntax_once (void) { register int c; static int done = 0; @@ -464,7 +433,7 @@ init_syntax_once () if (done) return; - bzero (re_syntax_table, sizeof re_syntax_table); + memset (re_syntax_table, 0, sizeof re_syntax_table); for (c = 0; c < CHAR_SET_SIZE; ++c) if (ISALNUM (c)) @@ -892,14 +861,14 @@ extract_number_and_incr (destination, source) do \ { \ re_wchar_t range_start, range_end; \ - re_char *p; \ + re_char *rtp; \ re_char *range_table_end \ = CHARSET_RANGE_TABLE_END ((range_table), (count)); \ \ - for (p = (range_table); p < range_table_end; p += 2 * 3) \ + for (rtp = (range_table); rtp < range_table_end; rtp += 2 * 3) \ { \ - EXTRACT_CHARACTER (range_start, p); \ - EXTRACT_CHARACTER (range_end, p + 3); \ + EXTRACT_CHARACTER (range_start, rtp); \ + EXTRACT_CHARACTER (range_end, rtp + 3); \ \ if (range_start <= (c) && (c) <= range_end) \ { \ @@ -1321,8 +1290,7 @@ reg_syntax_t re_syntax_options; defined in regex.h. We return the old syntax. */ reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; +re_set_syntax (reg_syntax_t syntax) { reg_syntax_t ret = re_syntax_options; @@ -1335,8 +1303,7 @@ WEAK_ALIAS (__re_set_syntax, re_set_syntax) static re_char *whitespace_regexp; void -re_set_whitespace_regexp (regexp) - const char *regexp; +re_set_whitespace_regexp (const char *regexp) { whitespace_regexp = (re_char *) regexp; } @@ -1588,22 +1555,22 @@ do { \ /* Pop a saved register off the stack. */ #define POP_FAILURE_REG_OR_COUNT() \ do { \ - int reg = POP_FAILURE_INT (); \ - if (reg == -1) \ + int pfreg = POP_FAILURE_INT (); \ + if (pfreg == -1) \ { \ /* It's a counter. */ \ /* Here, we discard `const', making re_match non-reentrant. */ \ unsigned char *ptr = (unsigned char*) POP_FAILURE_POINTER (); \ - reg = POP_FAILURE_INT (); \ - STORE_NUMBER (ptr, reg); \ - DEBUG_PRINT3 (" Pop counter %p = %d\n", ptr, reg); \ + pfreg = POP_FAILURE_INT (); \ + STORE_NUMBER (ptr, pfreg); \ + DEBUG_PRINT3 (" Pop counter %p = %d\n", ptr, pfreg); \ } \ else \ { \ - regend[reg] = POP_FAILURE_POINTER (); \ - regstart[reg] = POP_FAILURE_POINTER (); \ + regend[pfreg] = POP_FAILURE_POINTER (); \ + regstart[pfreg] = POP_FAILURE_POINTER (); \ DEBUG_PRINT4 (" Pop reg %d (spanning %p -> %p)\n", \ - reg, regstart[reg], regend[reg]); \ + pfreg, regstart[pfreg], regend[pfreg]); \ } \ } while (0) @@ -2149,10 +2116,9 @@ struct range_table_work_area /* Map a string to the char class it names (if any). */ re_wctype_t -re_wctype (str) - re_char *str; +re_wctype (const re_char *str) { - const char *string = str; + const char *string = (const char *) str; if (STREQ (string, "alnum")) return RECC_ALNUM; else if (STREQ (string, "alpha")) return RECC_ALPHA; else if (STREQ (string, "word")) return RECC_WORD; @@ -2175,9 +2141,7 @@ re_wctype (str) /* True if CH is in the char class CC. */ boolean -re_iswctype (ch, cc) - int ch; - re_wctype_t cc; +re_iswctype (int ch, re_wctype_t cc) { switch (cc) { @@ -2207,8 +2171,7 @@ re_iswctype (ch, cc) /* Return a bit-pattern to use in the range-table bits to match multibyte chars of class CC. */ static int -re_wctype_to_bit (cc) - re_wctype_t cc; +re_wctype_to_bit (re_wctype_t cc) { switch (cc) { @@ -2232,8 +2195,7 @@ re_wctype_to_bit (cc) /* Actually extend the space in WORK_AREA. */ static void -extend_range_table_work_area (work_area) - struct range_table_work_area *work_area; +extend_range_table_work_area (struct range_table_work_area *work_area) { work_area->allocated += 16 * sizeof (int); if (work_area->table) @@ -2557,18 +2519,11 @@ do { \ } while (0) static reg_errcode_t -regex_compile (pattern, size, syntax, bufp) - re_char *pattern; - size_t size; - reg_syntax_t syntax; - struct re_pattern_buffer *bufp; +regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp) { /* We fetch characters from PATTERN here. */ register re_wchar_t c, c1; - /* A random temporary spot in PATTERN. */ - re_char *p1; - /* Points to the end of the buffer, where we should append. */ register unsigned char *b; @@ -2616,9 +2571,6 @@ regex_compile (pattern, size, syntax, bufp) /* If the object matched can contain multibyte characters. */ const boolean multibyte = RE_MULTIBYTE_P (bufp); - /* If a target of matching can contain multibyte characters. */ - const boolean target_multibyte = RE_TARGET_MULTIBYTE_P (bufp); - /* Nonzero if we have pushed down into a subpattern. */ int in_subpattern = 0; @@ -2742,7 +2694,7 @@ regex_compile (pattern, size, syntax, bufp) main_pend = pend; main_pattern = pattern; p = pattern = whitespace_regexp; - pend = p + strlen (p); + pend = p + strlen ((const char *) p); break; } @@ -2936,6 +2888,8 @@ regex_compile (pattern, size, syntax, bufp) case '[': { + re_char *p1; + CLEAR_RANGE_TABLE_WORK_USED (range_table_work); if (p == pend) FREE_STACK_RETURN (REG_EBRACK); @@ -2959,7 +2913,7 @@ regex_compile (pattern, size, syntax, bufp) BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); + memset (b, 0, (1 << BYTEWIDTH) / BYTEWIDTH); /* charset_not matches newline according to a syntax bit. */ if ((re_opcode_t) b[-2] == charset_not @@ -2971,7 +2925,7 @@ regex_compile (pattern, size, syntax, bufp) { boolean escaped_char = false; const unsigned char *p2 = p; - re_wchar_t ch, c2; + re_wchar_t ch; if (p == pend) FREE_STACK_RETURN (REG_EBRACK); @@ -3034,10 +2988,7 @@ regex_compile (pattern, size, syntax, bufp) them). */ if (c == ':' && *p == ']') { - re_wctype_t cc; - int limit; - - cc = re_wctype (str); + re_wctype_t cc = re_wctype (str); if (cc == 0) FREE_STACK_RETURN (REG_ECTYPE); @@ -3875,10 +3826,7 @@ regex_compile (pattern, size, syntax, bufp) /* Store OP at LOC followed by two-byte integer parameter ARG. */ static void -store_op1 (op, loc, arg) - re_opcode_t op; - unsigned char *loc; - int arg; +store_op1 (re_opcode_t op, unsigned char *loc, int arg) { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg); @@ -3888,10 +3836,7 @@ store_op1 (op, loc, arg) /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ static void -store_op2 (op, loc, arg1, arg2) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; +store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg1); @@ -3903,11 +3848,7 @@ store_op2 (op, loc, arg1, arg2) for OP followed by two-byte integer parameter ARG. */ static void -insert_op1 (op, loc, arg, end) - re_opcode_t op; - unsigned char *loc; - int arg; - unsigned char *end; +insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) { register unsigned char *pfrom = end; register unsigned char *pto = end + 3; @@ -3922,11 +3863,7 @@ insert_op1 (op, loc, arg, end) /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ static void -insert_op2 (op, loc, arg1, arg2, end) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; - unsigned char *end; +insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end) { register unsigned char *pfrom = end; register unsigned char *pto = end + 5; @@ -3943,9 +3880,7 @@ insert_op2 (op, loc, arg1, arg2, end) least one character before the ^. */ static boolean -at_begline_loc_p (pattern, p, syntax) - re_char *pattern, *p; - reg_syntax_t syntax; +at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) { re_char *prev = p - 2; boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; @@ -3967,9 +3902,7 @@ at_begline_loc_p (pattern, p, syntax) at least one character after the $, i.e., `P < PEND'. */ static boolean -at_endline_loc_p (p, pend, syntax) - re_char *p, *pend; - reg_syntax_t syntax; +at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) { re_char *next = p; boolean next_backslash = *next == '\\'; @@ -3989,9 +3922,7 @@ at_endline_loc_p (p, pend, syntax) false if it's not. */ static boolean -group_in_compile_stack (compile_stack, regnum) - compile_stack_type compile_stack; - regnum_t regnum; +group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) { int this_element; @@ -4015,10 +3946,7 @@ group_in_compile_stack (compile_stack, regnum) Return -1 if fastmap was not updated accurately. */ static int -analyse_first (p, pend, fastmap, multibyte) - re_char *p, *pend; - char *fastmap; - const int multibyte; +analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte) { int j, k; boolean not; @@ -4060,7 +3988,6 @@ analyse_first (p, pend, fastmap, multibyte) { case succeed: return 1; - continue; case duplicate: /* If the first character has to match a backreference, that means @@ -4144,7 +4071,7 @@ analyse_first (p, pend, fastmap, multibyte) && match_any_multibyte_characters == false) { /* Set fastmap[I] to 1 where I is a leading code of each - multibyte characer in the range table. */ + multibyte character in the range table. */ int c, count; unsigned char lc1, lc2; @@ -4330,15 +4257,14 @@ analyse_first (p, pend, fastmap, multibyte) Returns 0 if we succeed, -2 if an internal error. */ int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; +re_compile_fastmap (struct re_pattern_buffer *bufp) { char *fastmap = bufp->fastmap; int analysis; assert (fastmap && bufp->buffer); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ + memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ analysis = analyse_first (bufp->buffer, bufp->buffer + bufp->used, @@ -4361,11 +4287,7 @@ re_compile_fastmap (bufp) freeing the old data. */ void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; +re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, unsigned int num_regs, regoff_t *starts, regoff_t *ends) { if (num_regs) { @@ -4389,11 +4311,7 @@ WEAK_ALIAS (__re_set_registers, re_set_registers) doesn't let you say where to stop matching. */ int -re_search (bufp, string, size, startpos, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, startpos, range; - struct re_registers *regs; +re_search (struct re_pattern_buffer *bufp, const char *string, int size, int startpos, int range, struct re_registers *regs) { return re_search_2 (bufp, NULL, 0, string, size, startpos, range, regs, size); @@ -4434,14 +4352,7 @@ WEAK_ALIAS (__re_search, re_search) stack overflow). */ int -re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *str1, *str2; - int size1, size2; - int startpos; - int range; - struct re_registers *regs; - int stop; +re_search_2 (struct re_pattern_buffer *bufp, const char *str1, int size1, const char *str2, int size2, int startpos, int range, struct re_registers *regs, int stop) { int val; re_char *string1 = (re_char*) str1; @@ -4641,7 +4552,6 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop) if (multibyte) { re_char *p = POS_ADDR_VSTRING (startpos); - re_char *pend = STOP_ADDR_VSTRING (startpos); int len = BYTES_BY_CHAR_HEAD (*p); range -= len; @@ -4775,8 +4685,7 @@ static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2, /* If the operation is a match against one or more chars, return a pointer to the next operation, else return NULL. */ static re_char * -skip_one_char (p) - re_char *p; +skip_one_char (const re_char *p) { switch (SWITCH_ENUM_CAST (*p++)) { @@ -4818,8 +4727,7 @@ skip_one_char (p) /* Jump over non-matching operations. */ static re_char * -skip_noops (p, pend) - re_char *p, *pend; +skip_noops (const re_char *p, const re_char *pend) { int mcnt; while (p < pend) @@ -4846,9 +4754,7 @@ skip_noops (p, pend) /* Non-zero if "p1 matches something" implies "p2 fails". */ static int -mutually_exclusive_p (bufp, p1, p2) - struct re_pattern_buffer *bufp; - re_char *p1, *p2; +mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2) { re_opcode_t op2; const boolean multibyte = RE_MULTIBYTE_P (bufp); @@ -5053,11 +4959,8 @@ mutually_exclusive_p (bufp, p1, p2) /* re_match is like re_match_2 except it takes only a single string. */ int -re_match (bufp, string, size, pos, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, pos; - struct re_registers *regs; +re_match (struct re_pattern_buffer *bufp, const char *string, + int size, int pos, struct re_registers *regs) { int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size, pos, regs, size); @@ -5086,13 +4989,7 @@ Lisp_Object re_match_object; matched substring. */ int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; +re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1, const char *string2, int size2, int pos, struct re_registers *regs, int stop) { int result; @@ -5114,18 +5011,11 @@ WEAK_ALIAS (__re_match_2, re_match_2) /* This is a separate function so that we can force an alloca cleanup afterwards. */ static int -re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - re_char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; +re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int size1, const re_char *string2, int size2, int pos, struct re_registers *regs, int stop) { /* General temporaries. */ int mcnt; size_t reg; - boolean not; /* Just past the end of the corresponding string. */ re_char *end1, *end2; @@ -5565,7 +5455,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) else do { - int pat_charlen, buf_charlen; + int pat_charlen; int pat_ch, buf_ch; PREFETCH (); @@ -5723,8 +5613,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) if (!not) goto fail; d += len; - break; } + break; /* The beginning of a group is represented by start_memory. @@ -6106,46 +5996,48 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) case wordbound: case notwordbound: - not = (re_opcode_t) *(p - 1) == notwordbound; - DEBUG_PRINT2 ("EXECUTING %swordbound.\n", not?"not":""); + { + boolean not = (re_opcode_t) *(p - 1) == notwordbound; + DEBUG_PRINT2 ("EXECUTING %swordbound.\n", not?"not":""); - /* We SUCCEED (or FAIL) in one of the following cases: */ + /* We SUCCEED (or FAIL) in one of the following cases: */ - /* Case 1: D is at the beginning or the end of string. */ - if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d)) - not = !not; - else - { - /* C1 is the character before D, S1 is the syntax of C1, C2 - is the character at D, and S2 is the syntax of C2. */ - re_wchar_t c1, c2; - int s1, s2; - int dummy; + /* Case 1: D is at the beginning or the end of string. */ + if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d)) + not = !not; + else + { + /* C1 is the character before D, S1 is the syntax of C1, C2 + is the character at D, and S2 is the syntax of C2. */ + re_wchar_t c1, c2; + int s1, s2; + int dummy; #ifdef emacs - int offset = PTR_TO_OFFSET (d - 1); - int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); - UPDATE_SYNTAX_TABLE (charpos); + int offset = PTR_TO_OFFSET (d - 1); + int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); + UPDATE_SYNTAX_TABLE (charpos); #endif - GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); - s1 = SYNTAX (c1); + GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); + s1 = SYNTAX (c1); #ifdef emacs - UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); + UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); #endif - PREFETCH_NOLIMIT (); - GET_CHAR_AFTER (c2, d, dummy); - s2 = SYNTAX (c2); - - if (/* Case 2: Only one of S1 and S2 is Sword. */ - ((s1 == Sword) != (s2 == Sword)) - /* Case 3: Both of S1 and S2 are Sword, and macro - WORD_BOUNDARY_P (C1, C2) returns nonzero. */ - || ((s1 == Sword) && WORD_BOUNDARY_P (c1, c2))) - not = !not; - } - if (not) - break; - else - goto fail; + PREFETCH_NOLIMIT (); + GET_CHAR_AFTER (c2, d, dummy); + s2 = SYNTAX (c2); + + if (/* Case 2: Only one of S1 and S2 is Sword. */ + ((s1 == Sword) != (s2 == Sword)) + /* Case 3: Both of S1 and S2 are Sword, and macro + WORD_BOUNDARY_P (C1, C2) returns nonzero. */ + || ((s1 == Sword) && WORD_BOUNDARY_P (c1, c2))) + not = !not; + } + if (not) + break; + else + goto fail; + } case wordbeg: DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); @@ -6325,25 +6217,27 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) case syntaxspec: case notsyntaxspec: - not = (re_opcode_t) *(p - 1) == notsyntaxspec; - mcnt = *p++; - DEBUG_PRINT3 ("EXECUTING %ssyntaxspec %d.\n", not?"not":"", mcnt); - PREFETCH (); -#ifdef emacs { - int offset = PTR_TO_OFFSET (d); - int pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset); - UPDATE_SYNTAX_TABLE (pos1); - } + boolean not = (re_opcode_t) *(p - 1) == notsyntaxspec; + mcnt = *p++; + DEBUG_PRINT3 ("EXECUTING %ssyntaxspec %d.\n", not?"not":"", mcnt); + PREFETCH (); +#ifdef emacs + { + int offset = PTR_TO_OFFSET (d); + int pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset); + UPDATE_SYNTAX_TABLE (pos1); + } #endif - { - int len; - re_wchar_t c; + { + int len; + re_wchar_t c; - GET_CHAR_AFTER (c, d, len); - if ((SYNTAX (c) != (enum syntaxcode) mcnt) ^ not) - goto fail; - d += len; + GET_CHAR_AFTER (c, d, len); + if ((SYNTAX (c) != (enum syntaxcode) mcnt) ^ not) + goto fail; + d += len; + } } break; @@ -6368,18 +6262,21 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) case categoryspec: case notcategoryspec: - not = (re_opcode_t) *(p - 1) == notcategoryspec; - mcnt = *p++; - DEBUG_PRINT3 ("EXECUTING %scategoryspec %d.\n", not?"not":"", mcnt); - PREFETCH (); { - int len; - re_wchar_t c; + boolean not = (re_opcode_t) *(p - 1) == notcategoryspec; + mcnt = *p++; + DEBUG_PRINT3 ("EXECUTING %scategoryspec %d.\n", + not?"not":"", mcnt); + PREFETCH (); - GET_CHAR_AFTER (c, d, len); - if ((!CHAR_HAS_CATEGORY (c, mcnt)) ^ not) - goto fail; - d += len; + { + int len; + re_wchar_t c; + GET_CHAR_AFTER (c, d, len); + if ((!CHAR_HAS_CATEGORY (c, mcnt)) ^ not) + goto fail; + d += len; + } } break; @@ -6451,11 +6348,8 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) bytes; nonzero otherwise. */ static int -bcmp_translate (s1, s2, len, translate, target_multibyte) - re_char *s1, *s2; - register int len; - RE_TRANSLATE_TYPE translate; - const int target_multibyte; +bcmp_translate (const re_char *s1, const re_char *s2, register int len, + RE_TRANSLATE_TYPE translate, const int target_multibyte) { register re_char *p1 = s1, *p2 = s2; re_char *p1_end = s1 + len; @@ -6496,10 +6390,7 @@ bcmp_translate (s1, s2, len, translate, target_multibyte) We call regex_compile to do the actual compilation. */ const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - size_t length; - struct re_pattern_buffer *bufp; +re_compile_pattern (const char *pattern, size_t length, struct re_pattern_buffer *bufp) { reg_errcode_t ret; @@ -6627,10 +6518,8 @@ re_exec (s) the return codes and their meanings.) */ int -regcomp (preg, pattern, cflags) - regex_t *__restrict preg; - const char *__restrict pattern; - int cflags; +regcomp (regex_t *__restrict preg, const char *__restrict pattern, + int cflags) { reg_errcode_t ret; reg_syntax_t syntax @@ -6712,12 +6601,8 @@ WEAK_ALIAS (__regcomp, regcomp) We return 0 if we find a match and REG_NOMATCH if not. */ int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *__restrict preg; - const char *__restrict string; - size_t nmatch; - regmatch_t pmatch[__restrict_arr]; - int eflags; +regexec (const regex_t *__restrict preg, const char *__restrict string, + size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) { int ret; struct re_registers regs; @@ -6789,11 +6674,7 @@ WEAK_ALIAS (__regexec, regexec) error with msvc8 compiler. */ size_t -regerror (err_code, preg, errbuf, errbuf_size) - int err_code; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; +regerror (int err_code, const regex_t *preg, char *errbuf, size_t errbuf_size) { const char *msg; size_t msg_size; @@ -6829,8 +6710,7 @@ WEAK_ALIAS (__regerror, regerror) /* Free dynamically allocated space used by PREG. */ void -regfree (preg) - regex_t *preg; +regfree (regex_t *preg) { free (preg->buffer); preg->buffer = NULL; @@ -6848,6 +6728,3 @@ regfree (preg) WEAK_ALIAS (__regfree, regfree) #endif /* not emacs */ - -/* arch-tag: 4ffd68ba-2a9e-435b-a21a-018990f9eeb2 - (do not change this comment) */