Skip to content

Commit a063021

Browse files
committed
Use named constant for regexp bytecode size field
1 parent 9539e3c commit a063021

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libregexp.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static const REOpCode reopcode_info[REOP_COUNT] = {
103103
#define RE_HEADER_FLAGS 0
104104
#define RE_HEADER_CAPTURE_COUNT 1
105105
#define RE_HEADER_STACK_SIZE 2
106+
#define RE_HEADER_BYTECODE_LEN 3
106107

107108
#define RE_HEADER_LEN 7
108109

@@ -280,7 +281,7 @@ static __maybe_unused void lre_dump_bytecode(const uint8_t *buf,
280281
assert(buf_len >= RE_HEADER_LEN);
281282

282283
re_flags= buf[0];
283-
bc_len = get_u32(buf + 3);
284+
bc_len = get_u32(buf + RE_HEADER_BYTECODE_LEN);
284285
assert(bc_len + RE_HEADER_LEN <= buf_len);
285286
printf("flags: 0x%x capture_count=%d stack_size=%d\n",
286287
re_flags, buf[1], buf[2]);
@@ -1896,7 +1897,8 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
18961897

18971898
s->byte_code.buf[RE_HEADER_CAPTURE_COUNT] = s->capture_count;
18981899
s->byte_code.buf[RE_HEADER_STACK_SIZE] = stack_size;
1899-
put_u32(s->byte_code.buf + 3, s->byte_code.size - RE_HEADER_LEN);
1900+
put_u32(s->byte_code.buf + RE_HEADER_BYTECODE_LEN,
1901+
s->byte_code.size - RE_HEADER_LEN);
19001902

19011903
/* add the named groups if needed */
19021904
if (s->group_names.size > (s->capture_count - 1)) {
@@ -2554,8 +2556,8 @@ const char *lre_get_groupnames(const uint8_t *bc_buf)
25542556
uint32_t re_bytecode_len;
25552557
if ((lre_get_flags(bc_buf) & LRE_FLAG_NAMED_GROUPS) == 0)
25562558
return NULL;
2557-
re_bytecode_len = get_u32(bc_buf + 3);
2558-
return (const char *)(bc_buf + 7 + re_bytecode_len);
2559+
re_bytecode_len = get_u32(bc_buf + RE_HEADER_BYTECODE_LEN);
2560+
return (const char *)(bc_buf + RE_HEADER_LEN + re_bytecode_len);
25592561
}
25602562

25612563
void lre_byte_swap(uint8_t *buf, size_t len, BOOL is_byte_swapped)

0 commit comments

Comments
 (0)