aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.c
diff options
context:
space:
mode:
authorRichard M. Stallman1995-04-09 19:14:40 +0000
committerRichard M. Stallman1995-04-09 19:14:40 +0000
commit85e36d2b62818790cc609cfe8a981ed2c50c8354 (patch)
tree03f188188fe8f77462b1023a4755d0a163f7e28c /src/regex.c
parent98a4349ced3fe72635dc03ba49da3e1a9424b54e (diff)
downloademacs-85e36d2b62818790cc609cfe8a981ed2c50c8354.tar.gz
emacs-85e36d2b62818790cc609cfe8a981ed2c50c8354.zip
(re_match_2_internal): Eliminate cast of ptr to int.
(PUSH_FAILURE_ITEM, POP_FAILURE_ITEM): Macros deleted. (PUSH_FAILURE_INT, POP_FAILURE_INT): New macros. (PUSH_FAILURE_POINTER, POP_FAILURE_POINTER): New macros. (re_match_2_internal): Rename label `succeed' to `succeed_label'.
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/regex.c b/src/regex.c
index e02f0fefb4e..fc370b351f7 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1009,19 +1009,28 @@ typedef struct
1009 : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ 1009 : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \
1010 1)) 1010 1))
1011 1011
1012/* This pushes an item onto the failure stack. Must be a four-byte 1012/* Push a pointer value onto the failure stack.
1013 value. Assumes the variable `fail_stack'. Probably should only 1013 Assumes the variable `fail_stack'. Probably should only
1014 be called from within `PUSH_FAILURE_POINT'. */ 1014 be called from within `PUSH_FAILURE_POINT'. */
1015#define PUSH_FAILURE_ITEM(item) \ 1015#define PUSH_FAILURE_POINTER(item) \
1016 fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item 1016 fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) (item)
1017
1018/* This pushes an integer-valued item onto the failure stack.
1019 Assumes the variable `fail_stack'. Probably should only
1020 be called from within `PUSH_FAILURE_POINT'. */
1021#define PUSH_FAILURE_INT(item) \
1022 fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) (EMACS_INT) (item)
1023
1024/* The complement operation. Assumes `fail_stack' is nonempty. */
1025#define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail]
1017 1026
1018/* The complement operation. Assumes `fail_stack' is nonempty. */ 1027/* The complement operation. Assumes `fail_stack' is nonempty. */
1019#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] 1028#define POP_FAILURE_INT() (EMACS_INT) fail_stack.stack[--fail_stack.avail]
1020 1029
1021/* Used to omit pushing failure point id's when we're not debugging. */ 1030/* Used to omit pushing failure point id's when we're not debugging. */
1022#ifdef DEBUG 1031#ifdef DEBUG
1023#define DEBUG_PUSH PUSH_FAILURE_ITEM 1032#define DEBUG_PUSH PUSH_FAILURE_INT
1024#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () 1033#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT ()
1025#else 1034#else
1026#define DEBUG_PUSH(item) 1035#define DEBUG_PUSH(item)
1027#define DEBUG_POP(item_addr) 1036#define DEBUG_POP(item_addr)
@@ -1074,10 +1083,10 @@ typedef struct
1074 DEBUG_STATEMENT (num_regs_pushed++); \ 1083 DEBUG_STATEMENT (num_regs_pushed++); \
1075 \ 1084 \
1076 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ 1085 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
1077 PUSH_FAILURE_ITEM (regstart[this_reg]); \ 1086 PUSH_FAILURE_POINTER (regstart[this_reg]); \
1078 \ 1087 \
1079 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ 1088 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
1080 PUSH_FAILURE_ITEM (regend[this_reg]); \ 1089 PUSH_FAILURE_POINTER (regend[this_reg]); \
1081 \ 1090 \
1082 DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ 1091 DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \
1083 DEBUG_PRINT2 (" match_null=%d", \ 1092 DEBUG_PRINT2 (" match_null=%d", \
@@ -1088,24 +1097,24 @@ typedef struct
1088 DEBUG_PRINT2 (" ever_matched=%d", \ 1097 DEBUG_PRINT2 (" ever_matched=%d", \
1089 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ 1098 EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
1090 DEBUG_PRINT1 ("\n"); \ 1099 DEBUG_PRINT1 ("\n"); \
1091 PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ 1100 PUSH_FAILURE_POINTER (reg_info[this_reg].word); \
1092 } \ 1101 } \
1093 \ 1102 \
1094 DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ 1103 DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\
1095 PUSH_FAILURE_ITEM (lowest_active_reg); \ 1104 PUSH_FAILURE_INT (lowest_active_reg); \
1096 \ 1105 \
1097 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ 1106 DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\
1098 PUSH_FAILURE_ITEM (highest_active_reg); \ 1107 PUSH_FAILURE_INT (highest_active_reg); \
1099 \ 1108 \
1100 DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ 1109 DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
1101 DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ 1110 DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
1102 PUSH_FAILURE_ITEM (pattern_place); \ 1111 PUSH_FAILURE_POINTER (pattern_place); \
1103 \ 1112 \
1104 DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ 1113 DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
1105 DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ 1114 DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
1106 size2); \ 1115 size2); \
1107 DEBUG_PRINT1 ("'\n"); \ 1116 DEBUG_PRINT1 ("'\n"); \
1108 PUSH_FAILURE_ITEM (string_place); \ 1117 PUSH_FAILURE_POINTER (string_place); \
1109 \ 1118 \
1110 DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ 1119 DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
1111 DEBUG_PUSH (failure_id); \ 1120 DEBUG_PUSH (failure_id); \
@@ -1167,7 +1176,7 @@ typedef struct
1167 /* If the saved string location is NULL, it came from an \ 1176 /* If the saved string location is NULL, it came from an \
1168 on_failure_keep_string_jump opcode, and we want to throw away the \ 1177 on_failure_keep_string_jump opcode, and we want to throw away the \
1169 saved NULL, thus retaining our current position in the string. */ \ 1178 saved NULL, thus retaining our current position in the string. */ \
1170 string_temp = POP_FAILURE_ITEM (); \ 1179 string_temp = POP_FAILURE_POINTER (); \
1171 if (string_temp != NULL) \ 1180 if (string_temp != NULL) \
1172 str = (const char *) string_temp; \ 1181 str = (const char *) string_temp; \
1173 \ 1182 \
@@ -1175,28 +1184,28 @@ typedef struct
1175 DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ 1184 DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
1176 DEBUG_PRINT1 ("'\n"); \ 1185 DEBUG_PRINT1 ("'\n"); \
1177 \ 1186 \
1178 pat = (unsigned char *) POP_FAILURE_ITEM (); \ 1187 pat = (unsigned char *) POP_FAILURE_POINTER (); \
1179 DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ 1188 DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \
1180 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ 1189 DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
1181 \ 1190 \
1182 /* Restore register info. */ \ 1191 /* Restore register info. */ \
1183 high_reg = (unsigned) POP_FAILURE_ITEM (); \ 1192 high_reg = (unsigned) POP_FAILURE_INT (); \
1184 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ 1193 DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
1185 \ 1194 \
1186 low_reg = (unsigned) POP_FAILURE_ITEM (); \ 1195 low_reg = (unsigned) POP_FAILURE_INT (); \
1187 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ 1196 DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
1188 \ 1197 \
1189 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ 1198 for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
1190 { \ 1199 { \
1191 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ 1200 DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
1192 \ 1201 \
1193 reg_info[this_reg].word = POP_FAILURE_ITEM (); \ 1202 reg_info[this_reg].word = POP_FAILURE_POINTER (); \
1194 DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ 1203 DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \
1195 \ 1204 \
1196 regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ 1205 regend[this_reg] = (const char *) POP_FAILURE_POINTER (); \
1197 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ 1206 DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
1198 \ 1207 \
1199 regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ 1208 regstart[this_reg] = (const char *) POP_FAILURE_POINTER (); \
1200 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ 1209 DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
1201 } \ 1210 } \
1202 \ 1211 \
@@ -3685,7 +3694,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
3685 } 3694 }
3686 } /* d != end_match_2 */ 3695 } /* d != end_match_2 */
3687 3696
3688 succeed: 3697 succeed_label:
3689 DEBUG_PRINT1 ("Accepting match.\n"); 3698 DEBUG_PRINT1 ("Accepting match.\n");
3690 3699
3691 /* If caller wants register contents data back, do it. */ 3700 /* If caller wants register contents data back, do it. */
@@ -3784,7 +3793,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
3784 3793
3785 case succeed: 3794 case succeed:
3786 DEBUG_PRINT1 ("EXECUTING succeed.\n"); 3795 DEBUG_PRINT1 ("EXECUTING succeed.\n");
3787 goto succeed; 3796 goto succeed_label;
3788 3797
3789 /* Match the next n pattern characters exactly. The following 3798 /* Match the next n pattern characters exactly. The following
3790 byte in the pattern defines n, and the n bytes after that 3799 byte in the pattern defines n, and the n bytes after that
@@ -4030,7 +4039,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
4030 regstart[r] = old_regstart[r]; 4039 regstart[r] = old_regstart[r];
4031 4040
4032 /* xx why this test? */ 4041 /* xx why this test? */
4033 if ((int) old_regend[r] >= (int) regstart[r]) 4042 if (old_regend[r] >= regstart[r])
4034 regend[r] = old_regend[r]; 4043 regend[r] = old_regend[r];
4035 } 4044 }
4036 } 4045 }