Skip to content

Commit

Permalink
Finish RRI changes per points from Paolo Bonzini.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldrobbins committed Dec 26, 2011
1 parent d586094 commit 9229cd0
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 19 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2011-12-26 Arnold D. Robbins <arnold@skeeve.com>

Finish Rational Range Interpretation (!)

* dfa.c (match_mb_charset): Compare wide characters directly
instead of using wcscoll().
* regexec.c (check_node_accept_byte): Ditto.

Thanks to Paolo Bonzini for pointing these out.

2011-12-06 John Haque <j.eh@mchsi.com>

* debug.c (source_find): Fix misplaced call to efree.
Expand Down
11 changes: 2 additions & 9 deletions dfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2887,7 +2887,6 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx)
with which this operator match. */
int op_len; /* Length of the operator. */
char buffer[128];
wchar_t wcbuf[6];

/* Pointer to the structure to which we are currently refering. */
struct mb_char_classes *work_mbc;
Expand Down Expand Up @@ -2964,17 +2963,11 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx)
}
}

wcbuf[0] = wc;
wcbuf[1] = wcbuf[3] = wcbuf[5] = '\0';

/* match with a range? */
for (i = 0; i<work_mbc->nranges; i++)
{
wcbuf[2] = work_mbc->range_sts[i];
wcbuf[4] = work_mbc->range_ends[i];

if (wcscoll(wcbuf, wcbuf+2) >= 0 &&
wcscoll(wcbuf+4, wcbuf) >= 0)
if (work_mbc->range_sts[i] <= wc &&
wc <= work_mbc->range_ends[i])
goto charset_matched;
}

Expand Down
12 changes: 2 additions & 10 deletions regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3963,18 +3963,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
# endif /* _LIBC */
{
/* match with range expression? */
#if __GNUC__ >= 2
wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
#else
wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
cmp_buf[2] = wc;
#endif
for (i = 0; i < cset->nranges; ++i)
{
cmp_buf[0] = cset->range_starts[i];
cmp_buf[4] = cset->range_ends[i];
if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
&& wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
if (cset->range_starts[i] <= wc
&& wc <= cset->range_ends[i])
{
match_len = char_len;
goto check_node_accept_bytes_match;
Expand Down
5 changes: 5 additions & 0 deletions test/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2011-12-26 Arnold D. Robbins <arnold@skeeve.com>

* Makefile.am (rri1): New test.
* rri1.awk, rri1.in, rri1.ok: New files.

2011-12-06 Arnold D. Robbins <arnold@skeeve.com>

* Makefile.am: Rationalize the $(CMP) lines wherever possible.
Expand Down
10 changes: 10 additions & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ EXTRA_DIST = \
resplit.awk \
resplit.in \
resplit.ok \
rri1.awk \
rri1.in \
rri1.ok \
rs.awk \
rs.in \
rs.ok \
Expand Down Expand Up @@ -803,6 +806,7 @@ BASIC_TESTS = \
paramres paramtyp parse1 parsefld parseme pcntplus posix2008sub \
prdupval prec printf0 printf1 prmarscl prmreuse prt1eval prtoeval \
rand range1 rebt8b1 redfilnm regeq regrange reindops reparse resplit \
rri1 \
rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 rstest3 rstest4 \
rstest5 rswhite scalar sclforin sclifin sortempty splitargv \
splitarr splitdef splitvar splitwht strcat1 strnum1 strtod subamp \
Expand Down Expand Up @@ -1433,6 +1437,12 @@ exit:
@-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rri1::
@echo $@
@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

# Targets generated for other tests:
include Maketests

Expand Down
10 changes: 10 additions & 0 deletions test/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ EXTRA_DIST = \
resplit.awk \
resplit.in \
resplit.ok \
rri1.awk \
rri1.in \
rri1.ok \
rs.awk \
rs.in \
rs.ok \
Expand Down Expand Up @@ -987,6 +990,7 @@ BASIC_TESTS = \
paramres paramtyp parse1 parsefld parseme pcntplus posix2008sub \
prdupval prec printf0 printf1 prmarscl prmreuse prt1eval prtoeval \
rand range1 rebt8b1 redfilnm regeq regrange reindops reparse resplit \
rri1 \
rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 rstest3 rstest4 \
rstest5 rswhite scalar sclforin sclifin sortempty splitargv \
splitarr splitdef splitvar splitwht strcat1 strnum1 strtod subamp \
Expand Down Expand Up @@ -1782,6 +1786,12 @@ exit:
@echo $@
@-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@

rri1::
@echo $@
@[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \
AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@
Gt-dummy:
# file Maketests, generated from Makefile.am by the Gentests program
addcomma:
Expand Down
1 change: 1 addition & 0 deletions test/rri1.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/[d-f]/
1 change: 1 addition & 0 deletions test/rri1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
no match: �
Empty file added test/rri1.ok
Empty file.

0 comments on commit 9229cd0

Please sign in to comment.