Skip to content

Commit

Permalink
Merge pull request #1194 from blackwhale/named-matches-fix
Browse files Browse the repository at this point in the history
Fix a bug in CTFE branch of std.regex parser
  • Loading branch information
dnadlinger committed Mar 11, 2013
2 parents 0a8aecf + be25fd0 commit ab10ad4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions std/regex.d
Expand Up @@ -1062,21 +1062,9 @@ struct Parser(R, bool CTFE = false)
nglob = groupStack.top++;
enforce(groupStack.top <= maxGroupNumber, "limit on submatches is exceeded");
auto t = NamedGroup(name, nglob);

if(__ctfe)
{
size_t ind;
for(ind = 0; ind < dict.length; ind++)
if(t.name >= dict[ind].name)
break;
insertInPlaceAlt(dict, ind, t);
}
else
{
auto d = assumeSorted!"a.name < b.name"(dict);
auto ind = d.lowerBound(t).length;
insertInPlaceAlt(dict, ind, t);
}
auto d = assumeSorted!"a.name < b.name"(dict);
auto ind = d.lowerBound(t).length;
insertInPlaceAlt(dict, ind, t);
put(Bytecode(IR.GroupStart, nglob));
break;
case '<':
Expand Down Expand Up @@ -7659,6 +7647,18 @@ else
auto m2 = match("1234", rx_2);
assert(equal(m2.front, ["1234", "3", "4"]));
}

// bugzilla 9280
unittest
{
string tomatch = "a!b@c";
static r = regex(r"^(?P<nick>.*?)!(?P<ident>.*?)@(?P<host>.*?)$");
auto nm = match(tomatch, r);
assert(nm);
auto c = nm.captures;
assert(c[1] == "a");
assert(c["nick"] == "a");
}
}

}//version(unittest)

0 comments on commit ab10ad4

Please sign in to comment.