From c66400b2f1566088f508cd04758956761876515b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 12 Oct 2014 01:09:34 +0200 Subject: how did I miss testing that it still worked with non-ASCII MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/gpp.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gpp.py b/src/gpp.py index cd3910b..7d3f4f0 100755 --- a/src/gpp.py +++ b/src/gpp.py @@ -155,8 +155,11 @@ def pp(line): esc = False dollar = False quote = [] - for i in range(len(line)): + n = len(line) + i = 0 + while i < n: c = line[i] + i += 1 if brackets > 0: if esc: esc = False @@ -180,8 +183,9 @@ def pp(line): rc.append(ord('"')) rc.append(ord('$')) rc.append(c) - elif line[i : i + symlen] == symbol: + elif line[i - 1 : i + symlen - 1] == symbol: symb = True + i += symlen - 1 elif len(quote) > 0: if esc: esc = False @@ -214,7 +218,7 @@ for _ in range(iterations): for lineno in range(len(data)): line = data[lineno] if (len(line) > symlen) and (line[:symlen] == symbol) and (line[symlen] in (ord('<'), ord('>'))): - bashed.append(line[2:]) + bashed.append(line[symlen + 1:]) entered = line[symlen] == ord('<') elif entered: bashed.append(line) -- cgit v1.2.3-70-g09d2