407 |
And inputwcs[i] is the codepoint. */ |
And inputwcs[i] is the codepoint. */ |
408 |
static unsigned char const *buf_begin; /* reference to begin in dfaexec(). */ |
static unsigned char const *buf_begin; /* reference to begin in dfaexec(). */ |
409 |
static unsigned char const *buf_end; /* reference to end in dfaexec(). */ |
static unsigned char const *buf_end; /* reference to end in dfaexec(). */ |
|
static unsigned long buf_offset; /* Go fast. */ |
|
410 |
#endif /* MBS_SUPPORT */ |
#endif /* MBS_SUPPORT */ |
411 |
|
|
412 |
#ifdef MBS_SUPPORT |
#ifdef MBS_SUPPORT |
2373 |
#define SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p) \ |
#define SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p) \ |
2374 |
if (s == 0) \ |
if (s == 0) \ |
2375 |
{ \ |
{ \ |
2376 |
while (inputwcs[p - buf_begin + buf_offset] == 0 \ |
while (inputwcs[p - buf_begin] == 0 \ |
2377 |
&& mblen_buf[p - buf_begin + buf_offset] > 0\ |
&& mblen_buf[p - buf_begin] > 0 \ |
2378 |
&& p < buf_end) \ |
&& p < buf_end) \ |
2379 |
++p; \ |
++p; \ |
2380 |
if (p >= end) \ |
if (p >= end) \ |
2381 |
{ \ |
{ \ |
2382 |
|
free(mblen_buf); \ |
2383 |
|
free(inputwcs); \ |
2384 |
return (size_t) -1; \ |
return (size_t) -1; \ |
2385 |
} \ |
} \ |
2386 |
} |
} |
2473 |
wchar_t wc; |
wchar_t wc; |
2474 |
int mbclen; |
int mbclen; |
2475 |
|
|
2476 |
wc = inputwcs[index + buf_offset]; |
wc = inputwcs[index]; |
2477 |
mbclen = (mblen_buf[index + buf_offset] == 0)? 1 : mblen_buf[index + buf_offset]; |
mbclen = (mblen_buf[index] == 0)? 1 : mblen_buf[index]; |
2478 |
|
|
2479 |
/* Check context. */ |
/* Check context. */ |
2480 |
if (wc == (wchar_t)eolbyte) |
if (wc == (wchar_t)eolbyte) |
2523 |
int letter = 0; |
int letter = 0; |
2524 |
wchar_t wc; /* Current refering character. */ |
wchar_t wc; /* Current refering character. */ |
2525 |
|
|
2526 |
wc = inputwcs[index + buf_offset]; |
wc = inputwcs[index]; |
2527 |
|
|
2528 |
/* Check context. */ |
/* Check context. */ |
2529 |
if (wc == (wchar_t)eolbyte) |
if (wc == (wchar_t)eolbyte) |
2547 |
/* Assign the current refering operator to work_mbc. */ |
/* Assign the current refering operator to work_mbc. */ |
2548 |
work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]); |
work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]); |
2549 |
match = !work_mbc->invert; |
match = !work_mbc->invert; |
2550 |
match_len = (mblen_buf[index + buf_offset] == 0)? 1 : mblen_buf[index + buf_offset]; |
match_len = (mblen_buf[index] == 0)? 1 : mblen_buf[index]; |
2551 |
|
|
2552 |
/* match with a character class? */ |
/* match with a character class? */ |
2553 |
for (i = 0; i<work_mbc->nch_classes; i++) |
for (i = 0; i<work_mbc->nch_classes; i++) |
2662 |
|
|
2663 |
/* Calculate the length of the (single/multi byte) character |
/* Calculate the length of the (single/multi byte) character |
2664 |
to which p points. */ |
to which p points. */ |
2665 |
*mbclen = (mblen_buf[*pp - buf_begin + buf_offset] == 0)? 1 |
*mbclen = (mblen_buf[*pp - buf_begin] == 0)? 1 |
2666 |
: mblen_buf[*pp - buf_begin + buf_offset]; |
: mblen_buf[*pp - buf_begin]; |
2667 |
|
|
2668 |
/* Calculate the state which can be reached from the state `s' by |
/* Calculate the state which can be reached from the state `s' by |
2669 |
consuming `*mbclen' single bytes from the buffer. */ |
consuming `*mbclen' single bytes from the buffer. */ |
2757 |
`maxlen' bytes. */ |
`maxlen' bytes. */ |
2758 |
rs = transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows); |
rs = transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows); |
2759 |
|
|
2760 |
wc = inputwcs[*pp - mbclen - buf_begin + buf_offset]; |
wc = inputwcs[*pp - mbclen - buf_begin]; |
2761 |
s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); |
s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); |
2762 |
realloc_trans_if_necessary(d, s1); |
realloc_trans_if_necessary(d, s1); |
2763 |
|
|
2775 |
&follows); |
&follows); |
2776 |
} |
} |
2777 |
|
|
2778 |
wc = inputwcs[*pp - mbclen - buf_begin + buf_offset]; |
wc = inputwcs[*pp - mbclen - buf_begin]; |
2779 |
s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); |
s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); |
2780 |
realloc_trans_if_necessary(d, s1); |
realloc_trans_if_necessary(d, s1); |
2781 |
} |
} |
2829 |
if (MB_CUR_MAX > 1) |
if (MB_CUR_MAX > 1) |
2830 |
{ |
{ |
2831 |
int remain_bytes, i; |
int remain_bytes, i; |
|
buf_begin -= buf_offset; |
|
|
if (buf_begin <= (unsigned char const *)begin && end <= buf_end) { |
|
|
buf_offset = (unsigned char const *)begin - buf_begin; |
|
|
buf_begin = begin; |
|
|
buf_end = end; |
|
|
goto go_fast; |
|
|
} |
|
|
|
|
|
buf_offset = 0; |
|
2832 |
buf_begin = begin; |
buf_begin = begin; |
2833 |
buf_end = end; |
buf_end = end; |
2834 |
|
|
2835 |
/* initialize mblen_buf, and inputwcs. */ |
/* initialize mblen_buf, and inputwcs. */ |
2836 |
REALLOC(mblen_buf, unsigned char, end - (unsigned char const *)begin + 2); |
MALLOC(mblen_buf, unsigned char, end - (unsigned char const *)begin + 2); |
2837 |
REALLOC(inputwcs, wchar_t, end - (unsigned char const *)begin + 2); |
MALLOC(inputwcs, wchar_t, end - (unsigned char const *)begin + 2); |
2838 |
memset(&mbs, 0, sizeof(mbstate_t)); |
memset(&mbs, 0, sizeof(mbstate_t)); |
2839 |
remain_bytes = 0; |
remain_bytes = 0; |
2840 |
for (i = 0; i < end - (unsigned char const *)begin + 1; i++) |
for (i = 0; i < end - (unsigned char const *)begin + 1; i++) |
2866 |
mblen_buf[i] = 0; |
mblen_buf[i] = 0; |
2867 |
inputwcs[i] = 0; /* sentinel */ |
inputwcs[i] = 0; /* sentinel */ |
2868 |
} |
} |
|
go_fast: |
|
2869 |
#endif /* MBS_SUPPORT */ |
#endif /* MBS_SUPPORT */ |
2870 |
|
|
2871 |
for (;;) |
for (;;) |
2904 |
{ |
{ |
2905 |
if (p == end) |
if (p == end) |
2906 |
{ |
{ |
2907 |
|
#ifdef MBS_SUPPORT |
2908 |
|
if (MB_CUR_MAX > 1) |
2909 |
|
{ |
2910 |
|
free(mblen_buf); |
2911 |
|
free(inputwcs); |
2912 |
|
} |
2913 |
|
#endif /* MBS_SUPPORT */ |
2914 |
return (size_t) -1; |
return (size_t) -1; |
2915 |
} |
} |
2916 |
s = 0; |
s = 0; |
2921 |
{ |
{ |
2922 |
if (backref) |
if (backref) |
2923 |
*backref = (d->states[s].backref != 0); |
*backref = (d->states[s].backref != 0); |
2924 |
|
#ifdef MBS_SUPPORT |
2925 |
|
if (MB_CUR_MAX > 1) |
2926 |
|
{ |
2927 |
|
free(mblen_buf); |
2928 |
|
free(inputwcs); |
2929 |
|
} |
2930 |
|
#endif /* MBS_SUPPORT */ |
2931 |
return (char const *) p - begin; |
return (char const *) p - begin; |
2932 |
} |
} |
2933 |
|
|