aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpp.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-10-09 10:47:24 +0200
committerMattias Andrée <maandree@operamail.com>2013-10-09 10:47:24 +0200
commit646274a0abeafe9f65ace6fc70da3235b82a75ab (patch)
tree9c41f3c2b346da8d185a1fb1c6dd7b4a065f9bc9 /src/gpp.py
parentderp (diff)
downloadgpp-646274a0abeafe9f65ace6fc70da3235b82a75ab.tar.gz
gpp-646274a0abeafe9f65ace6fc70da3235b82a75ab.tar.bz2
gpp-646274a0abeafe9f65ace6fc70da3235b82a75ab.tar.xz
error fixes
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/gpp.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/gpp.py b/src/gpp.py
index b14e538..5828a7b 100644
--- a/src/gpp.py
+++ b/src/gpp.py
@@ -23,25 +23,7 @@ def pp(line):
dollar = False
quote = []
for c in line:
- if len(quote) > 0:
- if esc:
- esc = False
- elif dollar:
- dollar = False
- if c == '(':
- quote.append(')')
- elif c == '{':
- quote.append('}')
- elif c == quote[-1]:
- quote[:] = quote[:-1]
- elif (quote[-1] in ')}') and (c in '\'"`'):
- quote.append(c)
- elif (c == '\\') and (quote[-1] != "'"):
- esc = True
- elif c == '$':
- dollar = True
- rc += c
- elif brackets > 0:
+ if brackets > 0:
if esc:
esc = False
elif (c == ')') or (c == '}'):
@@ -56,13 +38,31 @@ def pp(line):
rc += c
elif symb:
symb = False
- if c == symbol:
+ if (c == '(') or (c == '{'):
+ brackets += 1
+ rc += '\'"$' + c
+ else:
rc += c
elif c == symbol:
symb = True
- elif (c == '(') or (c == '{'):
- brackets += 1
- rc += '\'"$' + c
+ elif len(quote) > 0:
+ if esc:
+ esc = False
+ elif dollar:
+ dollar = False
+ if c == '(':
+ quote.append(')')
+ elif c == '{':
+ quote.append('}')
+ elif c == quote[-1]:
+ quote[:] = quote[:-1]
+ elif (quote[-1] in ')}') and (c in '\'"`'):
+ quote.append(c)
+ elif (c == '\\') and (quote[-1] != "'"):
+ esc = True
+ elif c == '$':
+ dollar = True
+ rc += c
elif (c == '"') or (c == "'") or (c == '`'):
quote.append(c)
rc += c
@@ -82,7 +82,7 @@ for lineno in range(len(data)):
bashed.append(line)
else:
line = '\'%s\'' % line.replace('\'', '\'\\\'\'')
- bashed.append('echo $\'\\e%i\\e\' %s' % (lineno, pp(line)))
+ bashed.append('echo $\'\\e%i\\e\'%s' % (lineno, pp(line)))
bashed = '\n'.join(bashed).encode(encoding)
bash = Popen(["bash"], stdin = PIPE, stdout = PIPE, stderr = sys.stderr)