diff --git a/twander.py b/twander.py index f3a3bcc..fabf5bf 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.170 2005/01/25 07:22:18 tundra Exp $" +RCSID = "$Id: twander.py,v 3.171 2005/01/25 08:08:24 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -1223,14 +1223,15 @@ # Steps 1-3 - saveliteral = [] + saveliteral = {} index = 0 for matchtest in (REPROMPT, REYESNO): for match in matchtest.finditer(cleanline): + fakefield = FAKEFIELD + str(index) found=match.group() - saveliteral.append(found) - cleanline = cleanline.replace(found, FAKEFIELD+str(index)) + saveliteral[fakefield] = found + cleanline = cleanline.replace(found, fakefield) index += 1 @@ -1238,30 +1239,17 @@ fields = cleanline.split() - # Step 5: Now restore the strings we want to preserve literally + # Step 5: Now restore the strings we want to preserve literally (if any) - if saveliteral: + # Scan through each field, replacing fake entries with the original text. + + for fake in saveliteral.keys(): index = 0 - while index < len(fields): - - field = fields[index] - - # The third field can start with a forced refresh indicator - # Ignore this for our purposes here - - if index == 2 and field.startswith(REFRESHAFTER): - field = field[1:] - - if field.startswith(FAKEFIELD): - try: - fields[index] = saveliteral[int(field[-1])] - except: - WrnMsg(wBADCMD % (num, file)) - fields = [] - + if fields[index].count(fake): + fields[index] = fields[index].replace(fake, saveliteral[fake]) index += 1 - + # Make a copy of the fields which is guaranteed to have at # least two fields for use in the variable declaration tests.