diff --git a/tren.py b/tren.py index 6cfa514..a4dde77 100755 --- a/tren.py +++ b/tren.py @@ -9,7 +9,7 @@ BASENAME = PROGNAME.split(".py")[0] PROGENV = BASENAME.upper() INCLENV = PROGENV + "INCL" -RCSID = "$Id: tren.py,v 1.237 2010/08/30 02:06:42 tundra Exp $" +RCSID = "$Id: tren.py,v 1.238 2010/09/07 18:24:18 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -361,7 +361,7 @@ eBADLEN = "Bad line length '%s'!" eBADNEWOLD = "Bad -r argument '%s'! Requires exactly one new, old string separator (Default: " + DEFSEP + ")" eBADREGEX = "Invalid Regular Expression: %s" -eBADSLICE = "%s invalid slice format! Must be integer values in the form: n, start:end (start<=end), :n, n:, or :" +eBADSLICE = "%s invalid slice format! Must be integer values in the form: n, :n, n:, start:end, or :" eERROR = "ERROR" eEXECFAIL = "Renaming token: '%s', command '%s' Failed To Execute!" eFILEOPEN = "Cannot open file '%s': %s!" @@ -980,9 +980,6 @@ if (tend != SINGLEINST and tend < 0): tend = bound + tend - if tstart > tend: - ErrorMsg(eBADSLICE % "%d:%d" % (renrequest[TARGETSTART], renrequest[TARGETEND])) - # Condition and bounds check the target range as needed # Handle single position references @@ -1008,7 +1005,15 @@ # Handle slice range requests else: - lname, newname, rname = newname[:tstart], newname[tstart:tend], newname[tend:] + + # Out-Of-Bounds or invalid slice ranges will + # cause renaming request to be ignored as above + + if newname[tstart:tend]: + lname, newname, rname = newname[:tstart], newname[tstart:tend], newname[tend:] + + else: + lname, newname, rname = newname, "", "" # Handle conventional string replacement renaming requests @@ -1619,11 +1624,6 @@ else: rhs = int(rhs) - # In the case of an explicit range, make sure the start <= end - - if (lhs != None and rhs != None) and (lhs > rhs): - raise - # Process single indexes else: