diff options
| author | Richard M. Stallman | 1995-05-02 16:27:24 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-05-02 16:27:24 +0000 |
| commit | d0b490f571ad2441f68c21e2bc3ad2e799ca1438 (patch) | |
| tree | 008faf6ccf79cc0708a03bfb952e3066ef023382 /src | |
| parent | c63f69527768e3e52d4ac8cd86f7cbee7d4e3a1a (diff) | |
| download | emacs-d0b490f571ad2441f68c21e2bc3ad2e799ca1438.tar.gz emacs-d0b490f571ad2441f68c21e2bc3ad2e799ca1438.zip | |
(union fail_stack_elt): New union.
(fail_stack_elt_t): Use that union.
(PUSH_PATTERN_OP, PUSH_FAILURE_POINTER, PUSH_FAILURE_INT)
(POP_FAILURE_POINTER, POP_FAILURE_INT): Corresponding changes.
(re_compile_fastmap): Corresponding changes.
(PUSH_FAILURE_ELT): New macro.
(FAIL_STACK_TOP): Macro deleted.
(WIDE_INT): Macro deleted.
(PUSH_FAILURE_POINT): Use PUSH_FAILURE_ELT.
(POP_FAILURE_ELT): New macro.
(POP_FAILURE_POINT): Use POP_FAILURE_ELT.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/src/regex.c b/src/regex.c index c17ff8cd0b7..d191df63f53 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -49,8 +49,6 @@ | |||
| 49 | #include "buffer.h" | 49 | #include "buffer.h" |
| 50 | #include "syntax.h" | 50 | #include "syntax.h" |
| 51 | 51 | ||
| 52 | #define WIDE_INT EMACS_INT | ||
| 53 | |||
| 54 | #else /* not emacs */ | 52 | #else /* not emacs */ |
| 55 | 53 | ||
| 56 | #ifdef STDC_HEADERS | 54 | #ifdef STDC_HEADERS |
| @@ -60,11 +58,6 @@ char *malloc (); | |||
| 60 | char *realloc (); | 58 | char *realloc (); |
| 61 | #endif | 59 | #endif |
| 62 | 60 | ||
| 63 | /* This isn't right--it needs to check for machines with 64-bit pointers | ||
| 64 | and do something different. But I don't know what, and I don't | ||
| 65 | need to deal with it right now. -- rms. */ | ||
| 66 | #define WIDE_INT int | ||
| 67 | |||
| 68 | /* We used to test for `BSTRING' here, but only GCC and Emacs define | 61 | /* We used to test for `BSTRING' here, but only GCC and Emacs define |
| 69 | `BSTRING', as far as I know, and neither of them use this code. */ | 62 | `BSTRING', as far as I know, and neither of them use this code. */ |
| 70 | #ifndef INHIBIT_STRING_HEADER | 63 | #ifndef INHIBIT_STRING_HEADER |
| @@ -990,7 +983,13 @@ int re_max_failures = 20000000; | |||
| 990 | int re_max_failures = 2000; | 983 | int re_max_failures = 2000; |
| 991 | #endif | 984 | #endif |
| 992 | 985 | ||
| 993 | typedef unsigned char *fail_stack_elt_t; | 986 | union fail_stack_elt |
| 987 | { | ||
| 988 | unsigned char *pointer; | ||
| 989 | int integer; | ||
| 990 | }; | ||
| 991 | |||
| 992 | typedef union fail_stack_elt fail_stack_elt_t; | ||
| 994 | 993 | ||
| 995 | typedef struct | 994 | typedef struct |
| 996 | { | 995 | { |
| @@ -1002,7 +1001,6 @@ typedef struct | |||
| 1002 | #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) | 1001 | #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) |
| 1003 | #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) | 1002 | #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) |
| 1004 | #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) | 1003 | #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) |
| 1005 | #define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) | ||
| 1006 | 1004 | ||
| 1007 | 1005 | ||
| 1008 | /* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ | 1006 | /* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ |
| @@ -1048,34 +1046,39 @@ typedef struct | |||
| 1048 | 1))) | 1046 | 1))) |
| 1049 | 1047 | ||
| 1050 | 1048 | ||
| 1051 | /* Push PATTERN_OP on FAIL_STACK. | 1049 | /* Push pointer POINTER on FAIL_STACK. |
| 1052 | |||
| 1053 | Return 1 if was able to do so and 0 if ran out of memory allocating | 1050 | Return 1 if was able to do so and 0 if ran out of memory allocating |
| 1054 | space to do so. */ | 1051 | space to do so. */ |
| 1055 | #define PUSH_PATTERN_OP(pattern_op, fail_stack) \ | 1052 | #define PUSH_PATTERN_OP(POINTER, FAIL_STACK) \ |
| 1056 | ((FAIL_STACK_FULL () \ | 1053 | ((FAIL_STACK_FULL () \ |
| 1057 | && !DOUBLE_FAIL_STACK (fail_stack)) \ | 1054 | && !DOUBLE_FAIL_STACK (FAIL_STACK)) \ |
| 1058 | ? 0 \ | 1055 | ? 0 \ |
| 1059 | : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ | 1056 | : ((FAIL_STACK).stack[(FAIL_STACK).avail++].pointer = POINTER, \ |
| 1060 | 1)) | 1057 | 1)) |
| 1061 | 1058 | ||
| 1062 | /* Push a pointer value onto the failure stack. | 1059 | /* Push a pointer value onto the failure stack. |
| 1063 | Assumes the variable `fail_stack'. Probably should only | 1060 | Assumes the variable `fail_stack'. Probably should only |
| 1064 | be called from within `PUSH_FAILURE_POINT'. */ | 1061 | be called from within `PUSH_FAILURE_POINT'. */ |
| 1065 | #define PUSH_FAILURE_POINTER(item) \ | 1062 | #define PUSH_FAILURE_POINTER(item) \ |
| 1066 | fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) (item) | 1063 | fail_stack.stack[fail_stack.avail++].pointer = (unsigned char *) (item) |
| 1067 | 1064 | ||
| 1068 | /* This pushes an integer-valued item onto the failure stack. | 1065 | /* This pushes an integer-valued item onto the failure stack. |
| 1069 | Assumes the variable `fail_stack'. Probably should only | 1066 | Assumes the variable `fail_stack'. Probably should only |
| 1070 | be called from within `PUSH_FAILURE_POINT'. */ | 1067 | be called from within `PUSH_FAILURE_POINT'. */ |
| 1071 | #define PUSH_FAILURE_INT(item) \ | 1068 | #define PUSH_FAILURE_INT(item) \ |
| 1072 | fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) (WIDE_INT) (item) | 1069 | fail_stack.stack[fail_stack.avail++].integer = (item) |
| 1073 | 1070 | ||
| 1074 | /* The complement operation. Assumes `fail_stack' is nonempty. */ | 1071 | /* Push a fail_stack_elt_t value onto the failure stack. |
| 1075 | #define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail] | 1072 | Assumes the variable `fail_stack'. Probably should only |
| 1073 | be called from within `PUSH_FAILURE_POINT'. */ | ||
| 1074 | #define PUSH_FAILURE_ELT(item) \ | ||
| 1075 | fail_stack.stack[fail_stack.avail++] = (item) | ||
| 1076 | 1076 | ||
| 1077 | /* The complement operation. Assumes `fail_stack' is nonempty. */ | 1077 | /* These three POP... operations complement the three PUSH... operations. |
| 1078 | #define POP_FAILURE_INT() (WIDE_INT) fail_stack.stack[--fail_stack.avail] | 1078 | All assume that `fail_stack' is nonempty. */ |
| 1079 | #define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail].pointer | ||
| 1080 | #define POP_FAILURE_INT() fail_stack.stack[--fail_stack.avail].integer | ||
| 1081 | #define POP_FAILURE_ELT() fail_stack.stack[--fail_stack.avail] | ||
| 1079 | 1082 | ||
| 1080 | /* Used to omit pushing failure point id's when we're not debugging. */ | 1083 | /* Used to omit pushing failure point id's when we're not debugging. */ |
| 1081 | #ifdef DEBUG | 1084 | #ifdef DEBUG |
| @@ -1147,7 +1150,7 @@ typedef struct | |||
| 1147 | DEBUG_PRINT2 (" ever_matched=%d", \ | 1150 | DEBUG_PRINT2 (" ever_matched=%d", \ |
| 1148 | EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ | 1151 | EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ |
| 1149 | DEBUG_PRINT1 ("\n"); \ | 1152 | DEBUG_PRINT1 ("\n"); \ |
| 1150 | PUSH_FAILURE_POINTER (reg_info[this_reg].word); \ | 1153 | PUSH_FAILURE_ELT (reg_info[this_reg].word); \ |
| 1151 | } \ | 1154 | } \ |
| 1152 | \ | 1155 | \ |
| 1153 | DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ | 1156 | DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ |
| @@ -1249,7 +1252,7 @@ typedef struct | |||
| 1249 | { \ | 1252 | { \ |
| 1250 | DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ | 1253 | DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ |
| 1251 | \ | 1254 | \ |
| 1252 | reg_info[this_reg].word = POP_FAILURE_POINTER (); \ | 1255 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ |
| 1253 | DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ | 1256 | DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ |
| 1254 | \ | 1257 | \ |
| 1255 | regend[this_reg] = (const char *) POP_FAILURE_POINTER (); \ | 1258 | regend[this_reg] = (const char *) POP_FAILURE_POINTER (); \ |
| @@ -1266,8 +1269,7 @@ typedef struct | |||
| 1266 | 1269 | ||
| 1267 | 1270 | ||
| 1268 | /* Structure for per-register (a.k.a. per-group) information. | 1271 | /* Structure for per-register (a.k.a. per-group) information. |
| 1269 | This must not be longer than one word, because we push this value | 1272 | Other register information, such as the |
| 1270 | onto the failure stack. Other register information, such as the | ||
| 1271 | starting and ending positions (which are addresses), and the list of | 1273 | starting and ending positions (which are addresses), and the list of |
| 1272 | inner groups (which is a bits list) are maintained in separate | 1274 | inner groups (which is a bits list) are maintained in separate |
| 1273 | variables. | 1275 | variables. |
| @@ -1276,6 +1278,7 @@ typedef struct | |||
| 1276 | the compiler will pack our bit fields into something that fits into | 1278 | the compiler will pack our bit fields into something that fits into |
| 1277 | the type of `word', i.e., is something that fits into one item on the | 1279 | the type of `word', i.e., is something that fits into one item on the |
| 1278 | failure stack. */ | 1280 | failure stack. */ |
| 1281 | |||
| 1279 | typedef union | 1282 | typedef union |
| 1280 | { | 1283 | { |
| 1281 | fail_stack_elt_t word; | 1284 | fail_stack_elt_t word; |
| @@ -2895,7 +2898,7 @@ re_compile_fastmap (bufp) | |||
| 2895 | /* Reset for next path. */ | 2898 | /* Reset for next path. */ |
| 2896 | path_can_be_null = true; | 2899 | path_can_be_null = true; |
| 2897 | 2900 | ||
| 2898 | p = fail_stack.stack[--fail_stack.avail]; | 2901 | p = fail_stack.stack[--fail_stack.avail].pointer; |
| 2899 | 2902 | ||
| 2900 | continue; | 2903 | continue; |
| 2901 | } | 2904 | } |
| @@ -3047,7 +3050,7 @@ re_compile_fastmap (bufp) | |||
| 3047 | 3050 | ||
| 3048 | /* If what's on the stack is where we are now, pop it. */ | 3051 | /* If what's on the stack is where we are now, pop it. */ |
| 3049 | if (!FAIL_STACK_EMPTY () | 3052 | if (!FAIL_STACK_EMPTY () |
| 3050 | && fail_stack.stack[fail_stack.avail - 1] == p) | 3053 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) |
| 3051 | fail_stack.avail--; | 3054 | fail_stack.avail--; |
| 3052 | 3055 | ||
| 3053 | continue; | 3056 | continue; |