@ -44,7 +44,7 @@
static void
tre_fill_pmatch ( size_t nmatch , regmatch_t pmatch [ ] , int cflags ,
const tre_tnfa_t * tnfa , int * tags , in t match_eo ) ;
const tre_tnfa_t * tnfa , regoff_t * tags , regoff_ t match_eo ) ;
/***********************************************************************
from tre - match - utils . h
@ -97,7 +97,7 @@ tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
/* Returns 1 if `t1' wins `t2', 0 otherwise. */
static int
tre_tag_order ( int num_tags , tre_tag_direction_t * tag_directions ,
int * t1 , in t * t2 )
regoff_t * t1 , regoff_ t * t2 )
{
int i ;
for ( i = 0 ; i < num_tags ; i + + )
@ -157,25 +157,25 @@ tre_neg_char_classes_match(tre_ctype_t *classes, tre_cint_t wc, int icase)
typedef struct {
tre_tnfa_transition_t * state ;
in t * tags ;
regoff_ t * tags ;
} tre_tnfa_reach_t ;
typedef struct {
in t pos ;
in t * * tags ;
regoff_ t pos ;
regoff_ t * * tags ;
} tre_reach_pos_t ;
static reg_errcode_t
tre_tnfa_run_parallel ( const tre_tnfa_t * tnfa , const void * string ,
in t * match_tags , int eflags ,
in t * match_end_ofs )
regoff_ t * match_tags , int eflags ,
regoff_ t * match_end_ofs )
{
/* State variables required by GET_NEXT_WCHAR. */
tre_char_t prev_c = 0 , next_c = 0 ;
const char * str_byte = string ;
in t pos = - 1 ;
in t pos_add_next = 1 ;
regoff_ t pos = - 1 ;
regoff_ t pos_add_next = 1 ;
# ifdef TRE_MBSTATE
mbstate_t mbstate ;
# endif /* TRE_MBSTATE */
@ -191,10 +191,10 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
int * tag_i ;
int num_tags , i ;
in t match_eo = - 1 ; /* end offset of match (-1 if no match found yet) */
regoff_ t match_eo = - 1 ; /* end offset of match (-1 if no match found yet) */
int new_match = 0 ;
in t * tmp_tags = NULL ;
in t * tmp_iptr ;
regoff_ t * tmp_tags = NULL ;
regoff_ t * tmp_iptr ;
# ifdef TRE_MBSTATE
memset ( & mbstate , ' \0 ' , sizeof ( mbstate ) ) ;
@ -214,7 +214,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
/* Ensure that tbytes and xbytes*num_states cannot overflow, and that
* they don ' t contribute more than 1 / 8 of SIZE_MAX to total_bytes . */
if ( num_tags > SIZE_MAX / ( 8 * sizeof ( in t) * tnfa - > num_states ) )
if ( num_tags > SIZE_MAX / ( 8 * sizeof ( regoff_ t) * tnfa - > num_states ) )
goto error_exit ;
/* Likewise check rbytes. */
@ -229,7 +229,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
tbytes = sizeof ( * tmp_tags ) * num_tags ;
rbytes = sizeof ( * reach_next ) * ( tnfa - > num_states + 1 ) ;
pbytes = sizeof ( * reach_pos ) * tnfa - > num_states ;
xbytes = sizeof ( in t) * num_tags ;
xbytes = sizeof ( regoff_ t) * num_tags ;
total_bytes =
( sizeof ( long ) - 1 ) * 4 /* for alignment paddings */
+ ( rbytes + xbytes * tnfa - > num_states ) * 2 + tbytes + pbytes ;
@ -490,12 +490,12 @@ error_exit:
*/
typedef struct {
in t pos ;
regoff_ t pos ;
const char * str_byte ;
tre_tnfa_transition_t * state ;
int state_id ;
int next_c ;
in t * tags ;
regoff_ t * tags ;
# ifdef TRE_MBSTATE
mbstate_t mbstate ;
# endif /* TRE_MBSTATE */
@ -591,13 +591,13 @@ typedef struct tre_backtrack_struct {
static reg_errcode_t
tre_tnfa_run_backtrack ( const tre_tnfa_t * tnfa , const void * string ,
in t * match_tags , int eflags , in t * match_end_ofs )
regoff_ t * match_tags , int eflags , regoff_ t * match_end_ofs )
{
/* State variables required by GET_NEXT_WCHAR. */
tre_char_t prev_c = 0 , next_c = 0 ;
const char * str_byte = string ;
in t pos = 0 ;
in t pos_add_next = 1 ;
regoff_ t pos = 0 ;
regoff_ t pos_add_next = 1 ;
# ifdef TRE_MBSTATE
mbstate_t mbstate ;
# endif /* TRE_MBSTATE */
@ -610,15 +610,16 @@ tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
started from . */
int next_c_start ;
const char * str_byte_start ;
in t pos_start = - 1 ;
regoff_ t pos_start = - 1 ;
# ifdef TRE_MBSTATE
mbstate_t mbstate_start ;
# endif /* TRE_MBSTATE */
/* End offset of best match so far, or -1 if no match found yet. */
in t match_eo = - 1 ;
regoff_ t match_eo = - 1 ;
/* Tag arrays. */
int * next_tags , * tags = NULL ;
int * next_tags ;
regoff_t * tags = NULL ;
/* Current TNFA state. */
tre_tnfa_transition_t * state ;
int * states_seen = NULL ;
@ -768,8 +769,9 @@ tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
/* This is a back reference state. All transitions leaving from
this state have the same back reference " assertion " . Instead
of reading the next character , we match the back reference . */
int so , eo , bt = trans_i - > u . backref ;
int bt_len ;
regoff_t so , eo ;
int bt = trans_i - > u . backref ;
regoff_t bt_len ;
int result ;
/* Get the substring we need to match against. Remember to
@ -926,7 +928,7 @@ tre_tnfa_run_backtrack(const tre_tnfa_t *tnfa, const void *string,
endpoint values . */
static void
tre_fill_pmatch ( size_t nmatch , regmatch_t pmatch [ ] , int cflags ,
const tre_tnfa_t * tnfa , int * tags , in t match_eo )
const tre_tnfa_t * tnfa , regoff_t * tags , regoff_ t match_eo )
{
tre_submatch_data_t * submatch_data ;
unsigned int i , j ;
@ -996,7 +998,7 @@ regexec(const regex_t *restrict preg, const char *restrict string,
{
tre_tnfa_t * tnfa = ( void * ) preg - > TRE_REGEX_T_FIELD ;
reg_errcode_t status ;
in t * tags = NULL , eo ;
regoff_ t * tags = NULL , eo ;
if ( tnfa - > cflags & REG_NOSUB ) nmatch = 0 ;
if ( tnfa - > num_tags > 0 & & nmatch > 0 )
{