Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions re.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,22 +399,7 @@ static int matchone(regex_t p, char c)

static int matchstar(regex_t p, regex_t* pattern, const char* text, int* matchlength)
{
int prelen = *matchlength;
const char* prepoint = text;
while ((text[0] != '\0') && matchone(p, *text))
{
text++;
(*matchlength)++;
}
while (text >= prepoint)
{
if (matchpattern(pattern, text--, matchlength))
return 1;
(*matchlength)--;
}

*matchlength = prelen;
return 0;
return matchplus(p, pattern, text, matchlength) || matchpattern(pattern, text, matchlength);
}

static int matchplus(regex_t p, regex_t* pattern, const char* text, int* matchlength)
Expand All @@ -423,15 +408,14 @@ static int matchplus(regex_t p, regex_t* pattern, const char* text, int* matchle
while ((text[0] != '\0') && matchone(p, *text))
{
text++;
(*matchlength)++;
}
while (text > prepoint)
for (; text > prepoint; text--)
{
if (matchpattern(pattern, text--, matchlength))
if (matchpattern(pattern, text, matchlength)) {
*matchlength += text - prepoint;
return 1;
(*matchlength)--;
}
}

return 0;
}

Expand Down