diff options
author | stanton <stanton> | 1999-06-17 19:30:25 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-06-17 19:30:25 (GMT) |
commit | 36fade5673a2b490fdbcdb5e782dcd8c906304d2 (patch) | |
tree | 12cb78e0f616e3bb360eafc126717bad52f22606 | |
parent | e544512a2dd0604f3824a9f9532fe64b4d30606c (diff) | |
download | tcl-36fade5673a2b490fdbcdb5e782dcd8c906304d2.zip tcl-36fade5673a2b490fdbcdb5e782dcd8c906304d2.tar.gz tcl-36fade5673a2b490fdbcdb5e782dcd8c906304d2.tar.bz2 |
* generic/regcomp.c: lint
* tests/reg.test:
* generic/regex.h:
* generic/regc_lex.c: Added REG_BOSONLY flag to allow Expect to
iterate through a string an only find matches that start at the
current position within the string.
-rw-r--r-- | generic/regc_lex.c | 6 | ||||
-rw-r--r-- | generic/regcomp.c | 2 | ||||
-rw-r--r-- | generic/regex.h | 1 | ||||
-rw-r--r-- | tests/reg.test | 5 |
4 files changed, 12 insertions, 2 deletions
diff --git a/generic/regc_lex.c b/generic/regc_lex.c index d07fe72..e20b222 100644 --- a/generic/regc_lex.c +++ b/generic/regc_lex.c @@ -283,6 +283,12 @@ struct vars *v; /* remember flavor of last token */ v->lasttype = v->nexttype; + /* REG_BOSONLY */ + if (v->nexttype == EMPTY && (v->cflags®_BOSONLY)) { + /* at start of a REG_BOSONLY RE */ + RETV(SBEGIN, 0); /* same as \A */ + } + /* if we're nested and we've hit end, return to outer level */ if (v->savenow != NULL && ATEOS()) { v->now = v->savenow; diff --git a/generic/regcomp.c b/generic/regcomp.c index 26b937e..b292012 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -533,7 +533,7 @@ struct nfa *nfa; /* add implicit .* in front */ rainbow(nfa, v->cm, PLAIN, COLORLESS, pre, pre); - /* and ^* and \Z* too -- not always necessary, but harmless */ + /* and ^* and \A* too -- not always necessary, but harmless */ newarc(nfa, PLAIN, nfa->bos[0], pre, pre); newarc(nfa, PLAIN, nfa->bos[1], pre, pre); } diff --git a/generic/regex.h b/generic/regex.h index 26be33c..0016005 100644 --- a/generic/regex.h +++ b/generic/regex.h @@ -223,6 +223,7 @@ typedef struct { #define REG_NEWLINE 000300 /* newlines are line terminators */ #define REG_PEND 000400 /* ugh -- backward-compatibility hack */ #define REG_EXPECT 001000 /* report details on partial/limited matches */ +#define REG_BOSONLY 002000 /* temporary kludge for BOS-only matches */ #define REG_DUMP 004000 /* none of your business :-) */ #define REG_FAKEEC 010000 /* none of your business :-) */ #define REG_PROGRESS 020000 /* none of your business :-) */ diff --git a/tests/reg.test b/tests/reg.test index 40efbdb..4b51248 100644 --- a/tests/reg.test +++ b/tests/reg.test @@ -6,7 +6,7 @@ # # Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. # -# RCS: @(#) $Id: reg.test,v 1.3 1999/06/02 01:53:32 stanton Exp $ +# RCS: @(#) $Id: reg.test,v 1.4 1999/06/17 19:30:26 stanton Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -932,6 +932,9 @@ m 3 N a?b* bb bb m 4 & a*b aab aab m 5 & ^a*b aaaab aaaab m 6 &M {[0-6][1-2][0-3][0-6][1-6][0-6]} 010010 010010 +# temporary REG_BOSONLY kludge +m 7 s abc abcd abc +f 8 s abc xabcd |