diff --git a/tren.py b/tren.py index cd00a2b..5f51cd1 100755 --- a/tren.py +++ b/tren.py @@ -8,7 +8,7 @@ PROGNAME = "tren.py" BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() -RCSID = "$Id: tren.py,v 1.173 2010/03/08 16:41:23 tundra Exp $" +RCSID = "$Id: tren.py,v 1.174 2010/03/08 19:29:52 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -691,27 +691,40 @@ def __ResolveRenameTokens(self, target, renstring): - # Find all token delimiters + # Find all token delimiters but ignore any that might appear + # inside a command execution replacement token string. rentokens = [] - td = re.finditer(TOKDELIM, renstring) - - # Build list of begin/end delimiter pairs - odd = True - for i in td: + incmdexec = False - if odd: - rentokens.append([i.start()]) + i=0 + while i < len(renstring): - else: - rentokens[-1].append(i.start()) + if renstring[i] == TOKCMDEXEC: + incmdexec = not incmdexec - odd = not odd - + elif renstring[i] == TOKDELIM: + + if incmdexec: + pass + + elif odd: + + rentokens.append([i]) + odd = not odd + + else: + + rentokens[-1].append(i) + odd = not odd + + + i += 1 + # There must be an even number of token delimiters # or the renaming token is malformed - + if rentokens and len(rentokens[-1]) != 2: ErrorMsg(eTOKDELIM % renstring)