コード例 #1
0
ファイル: regexp.c プロジェクト: charliesome/slash
SLVAL
sl_regexp_match_after(sl_vm_t* vm, SLVAL self)
{
    sl_regexp_match_t* match = get_regexp_match(vm, self);
    int index = cap_index(vm, self, sl_make_int(vm, 0));
    sl_string_t* str = (sl_string_t*)sl_get_ptr(match->match_string);
    return sl_make_string(vm, str->buff + match->captures[index + 1], str->buff_len - match->captures[index + 1]);
}
コード例 #2
0
ファイル: regexp.c プロジェクト: charliesome/slash
SLVAL
sl_regexp_match_byte_offset(sl_vm_t* vm, SLVAL self, SLVAL i)
{
    sl_regexp_match_t* match = get_regexp_match(vm, self);
    int index = cap_index(vm, self, i);
    if(index < 0) {
        return vm->lib.nil;
    }
    return sl_make_int(vm, match->captures[index]);
}
コード例 #3
0
ファイル: regexp.c プロジェクト: charliesome/slash
SLVAL
sl_regexp_match_offset(sl_vm_t* vm, SLVAL self, SLVAL i)
{
    sl_regexp_match_t* match = get_regexp_match(vm, self);
    int index = cap_index(vm, self, i);
    if(index < 0) {
        return vm->lib.nil;
    }
    int offset = match->captures[index];
    return sl_make_int(vm, sl_string_index_for_byte_offset(vm, match->match_string, offset));
}
コード例 #4
0
ファイル: regexp.c プロジェクト: charliesome/slash
SLVAL
sl_regexp_match_index(sl_vm_t* vm, SLVAL self, SLVAL i)
{
    sl_regexp_match_t* match = get_regexp_match(vm, self);
    int index = cap_index(vm, self, i);
    if(index < 0) {
        return vm->lib.nil;
    }
    sl_string_t* str = (sl_string_t*)sl_get_ptr(match->match_string);
    return sl_make_string(vm, str->buff + match->captures[index], match->captures[index + 1] - match->captures[index]);
}
コード例 #5
0
ファイル: regexp.c プロジェクト: charliesome/slash
SLVAL
sl_regexp_match_capture(sl_vm_t* vm, SLVAL self, SLVAL i)
{
    sl_regexp_match_t* match = get_regexp_match(vm, self);
    int index = cap_index(vm, self, i);
    if(index < 0) {
        return vm->lib.nil;
    }
    int start = sl_string_index_for_byte_offset(vm, match->match_string, match->captures[index]);
    int end = sl_string_index_for_byte_offset(vm, match->match_string, match->captures[index + 1]);
    SLVAL off_len[] = { sl_make_int(vm, start), sl_make_int(vm, end - start) };
    return sl_make_array(vm, 2, off_len);
}
コード例 #6
0
ファイル: control.c プロジェクト: BackupTheBerlios/wl530g-svn
/*
**	dump_test_stats(test_list, status, ch)
**
**	Dump the statistics about the last test
*/
void
dump_test_stats(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, j;
	char tbuf[32];
	int x[32];

	put_crlf();
	if (tx_source && tx_source->caps_done) {
		cap_index(tx_source->caps_done, x);
		if (x[0] >= 0) {
			sprintf(temp, "Caps summary for (%s)",
				tx_source->caps_done);
			ptextln(temp);
			for (i = 0; x[i] >= 0; i++) {
				show_cap_results(x[i]);
			}
			put_crlf();
		}
	}
	sprintf(tbuf, "%011u", usec_run_time);
	sprintf(temp, "Test time: %d.%s, characters per second %d, characters %d",
		usec_run_time / 1000000, &tbuf[5], tx_cps, tx_characters);
	ptextln(temp);
	for (i = 0; i < txp; i++) {
		if ((j = get_string_cap_byvalue(tx_cap[i])) >= 0) {
			sprintf(tbuf, "(%s)", strnames[j]);
		} else {
			strcpy(tbuf, "(?)");
		}
		sprintf(temp, "%8d  %3d  $<%3d>  %8s %s",
			tx_count[i], tx_affected[i], tx_delay[i],
			tbuf, expand(tx_cap[i]));
		putln(temp);
	}
	generic_done_message(t, state, ch);
}