fix infinite loop (closes #3)

This commit is contained in:
Radovan Garabík 2015-03-16 15:09:12 +01:00
parent 1a2ff5c22d
commit 91f9c1b453
3 changed files with 9 additions and 2 deletions

View File

@ -24,7 +24,7 @@ regexp=(inet6?|netmask|broadcast)
colours=cyan
=======
#flags
regexp=(?<=[,<])[^,]*(?=[,>])
regexp=(?<=[,<])[^,]+?(?=[,>])
colours=blue
=======
# mtu

1
debian/changelog vendored
View File

@ -2,6 +2,7 @@ grc (1.8-1) unstable; urgency=low
* added support for Ki, Gi, Ti for df (thanks to Juraj Bednár)
* added example aliases for bash (thanks to Juraj Bednár)
* fix infinite loop if regexp matches but does not consume anything
-- Radovan Garabík <garabik@kassiopeia.juls.savba.sk> Mon, 16 Mar 2015 14:38:42 +0100

8
grcat
View File

@ -185,7 +185,13 @@ while 1:
break
if currcount == "more":
prevcount = "more"
pos = m.end(0)
newpos = m.end(0)
# special case, if the regexp matched but did not consume anything,
# advance the position by 1 to escape endless loop
if newpos == pos:
pos += 1
else:
pos = newpos
else:
prevcount = "once"
pos = len(line)