Skip to content

Commit

Permalink
aiml: fix match() bug
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Mar 18, 2013
1 parent 1f0ff1c commit 141a804
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions aiml/PatternMgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,22 @@ def star(self, starType, pattern, that, topic, index):
# pattern again, the star has ended.
# FIXED: for pattch "* A B", "A C A B" will match
# and this is a bug
#if patMatch[j+1] == words[k]:
if patMatch[j+1:] == words[k:]:
end = k - 1
i = k
break
if patMatch[j+1] == words[k]:
tj = j+1 + 1
tk = k + 1
ok = True
while tj < len(patMatch) and tk < len(words):
if patMatch[tj] in [self._STAR, self._UNDERSCORE]:
break
if patMatch[tj] != words[tk]:
ok = False
break
tj += 1
tk += 1
if ok:
end = k - 1
i = k
break
# If we just finished processing the star we cared
# about, we exit the loop early.
if foundTheRightStar:
Expand Down

0 comments on commit 141a804

Please sign in to comment.