text/re/mtre/regexec.c
/* Fills the POSIX.2 regmatch_t array according to the TNFA tag and match
   endpoint values. */
Fills the POSIX.2 regmatch_t array according to the TNFA tag and match
endpoint values.
Fills the POSIX . 2 regmatch_t array according to the TNFA tag and match endpoint values .
static void tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[],
		const tre_tnfa_t *tnfa, regoff_t *tags, regoff_t match_eo)
{
	const tre_submatch_data_t *submatch_data;
	unsigned int               i;
	unsigned int               j;
	int                       *parents;
	if (pmatch == NULL || nmatch == 0)
		return;
	i = 0;
	if (match_eo >= 0) {
		submatch_data = tnfa->submatch_data;
		while (i < tnfa->num_submatches && i < nmatch) {
			if (submatch_data[i].so_tag == tnfa->end_tag) {
				pmatch[i].rm_so = match_eo;
			} else if (tags == NULL) {
				pmatch[i].rm_so = -1;
			} else {
				pmatch[i].rm_so = tags[submatch_data[i].so_tag];
			}
			if (submatch_data[i].eo_tag == tnfa->end_tag) {
				pmatch[i].rm_eo = match_eo;
			} else if (tags == NULL) {
				pmatch[i].rm_eo = -1;
			} else {
				pmatch[i].rm_eo = tags[submatch_data[i].eo_tag];
			}
			if (pmatch[i].rm_so == -1 || pmatch[i].rm_eo == -1) {
				pmatch[i].rm_so = pmatch[i].rm_eo = -1;
			}
			i++;
		}
		i = 0;
		while (i < tnfa->num_submatches && i < nmatch) {
			parents = submatch_data[i].parents;
			if (parents != NULL) {
				for (j = 0; parents[j] >= 0; j++) {
					if (pmatch[i].rm_so < pmatch[parents[j]].rm_so || pmatch[i].rm_eo > pmatch[parents[j]].rm_eo) {
						pmatch[i].rm_so = pmatch[i].rm_eo = -1;
					}
				}
			}
			i++;
		}
	}
	while (i < nmatch) {
		pmatch[i].rm_so = -1;
		pmatch[i].rm_eo = -1;
		i++;
	}
}
static void tre_fill_pmatch ( size_t nmatch , regmatch_t pmatch [ ] , const tre_tnfa_t * tnfa , regoff_t * tags , regoff_t match_eo ) { const tre_submatch_data_t * submatch_data ; unsigned int i ; unsigned int j ; int * parents ; if ( pmatch == NULL || nmatch == 0 ) return ; i = 0 ; if ( match_eo >= 0 ) { submatch_data = tnfa -> submatch_data ; while ( i < tnfa -> num_submatches && i < nmatch ) { if ( submatch_data [ i ] . so_tag == tnfa -> end_tag ) { pmatch [ i ] . rm_so = match_eo ; } else if ( tags == NULL ) { pmatch [ i ] . rm_so = -1 ; } else { pmatch [ i ] . rm_so = tags [ submatch_data [ i ] . so_tag ] ; } if ( submatch_data [ i ] . eo_tag == tnfa -> end_tag ) { pmatch [ i ] . rm_eo = match_eo ; } else if ( tags == NULL ) { pmatch [ i ] . rm_eo = -1 ; } else { pmatch [ i ] . rm_eo = tags [ submatch_data [ i ] . eo_tag ] ; } if ( pmatch [ i ] . rm_so == -1 || pmatch [ i ] . rm_eo == -1 ) { pmatch [ i ] . rm_so = pmatch [ i ] . rm_eo = -1 ; } i ++ ; } i = 0 ; while ( i < tnfa -> num_submatches && i < nmatch ) { parents = submatch_data [ i ] . parents ; if ( parents != NULL ) { for ( j = 0 ; parents [ j ] >= 0 ; j ++ ) { if ( pmatch [ i ] . rm_so < pmatch [ parents [ j ] ] . rm_so || pmatch [ i ] . rm_eo > pmatch [ parents [ j ] ] . rm_eo ) { pmatch [ i ] . rm_so = pmatch [ i ] . rm_eo = -1 ; } } } i ++ ; } } while ( i < nmatch ) { pmatch [ i ] . rm_so = -1 ; pmatch [ i ] . rm_eo = -1 ; i ++ ; } }
Fills the POSIX.2 regmatch_t array according to the TNFA tag and match
endpoint values.
Fills the POSIX . 2 regmatch_t array according to the TNFA tag and match endpoint values .
/* Construct submatch offsets from the tags. */ /* If either of the endpoints were not used, this submatch
			   was not part of the match. */ /* Reset all submatches that are not within all of their parent submatches. */