@@ -103,6 +103,7 @@ static const REOpCode reopcode_info[REOP_COUNT] = {
103
103
#define RE_HEADER_FLAGS 0
104
104
#define RE_HEADER_CAPTURE_COUNT 1
105
105
#define RE_HEADER_STACK_SIZE 2
106
+ #define RE_HEADER_BYTECODE_LEN 3
106
107
107
108
#define RE_HEADER_LEN 7
108
109
@@ -280,7 +281,7 @@ static __maybe_unused void lre_dump_bytecode(const uint8_t *buf,
280
281
assert (buf_len >= RE_HEADER_LEN );
281
282
282
283
re_flags = buf [0 ];
283
- bc_len = get_u32 (buf + 3 );
284
+ bc_len = get_u32 (buf + RE_HEADER_BYTECODE_LEN );
284
285
assert (bc_len + RE_HEADER_LEN <= buf_len );
285
286
printf ("flags: 0x%x capture_count=%d stack_size=%d\n" ,
286
287
re_flags , buf [1 ], buf [2 ]);
@@ -1896,7 +1897,8 @@ uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
1896
1897
1897
1898
s -> byte_code .buf [RE_HEADER_CAPTURE_COUNT ] = s -> capture_count ;
1898
1899
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 );
1900
1902
1901
1903
/* add the named groups if needed */
1902
1904
if (s -> group_names .size > (s -> capture_count - 1 )) {
@@ -2554,8 +2556,8 @@ const char *lre_get_groupnames(const uint8_t *bc_buf)
2554
2556
uint32_t re_bytecode_len ;
2555
2557
if ((lre_get_flags (bc_buf ) & LRE_FLAG_NAMED_GROUPS ) == 0 )
2556
2558
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 );
2559
2561
}
2560
2562
2561
2563
void lre_byte_swap (uint8_t * buf , size_t len , BOOL is_byte_swapped )
0 commit comments