aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpp.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-02-13 08:46:05 +0100
committerMattias Andrée <maandree@kth.se>2017-02-13 08:46:11 +0100
commitab273d8948d88df7269358973f8151513b00a40f (patch)
tree2a5695352cbf4615d78ea57dc994df5bb2d06bd8 /src/gpp.py
parentupdate dist (diff)
downloadgpp-ab273d8948d88df7269358973f8151513b00a40f.tar.gz
gpp-ab273d8948d88df7269358973f8151513b00a40f.tar.bz2
gpp-ab273d8948d88df7269358973f8151513b00a40f.tar.xz
Fix -n and escaped symbols
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/gpp.py')
-rwxr-xr-xsrc/gpp.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gpp.py b/src/gpp.py
index ce35380..7d537fe 100755
--- a/src/gpp.py
+++ b/src/gpp.py
@@ -3,7 +3,7 @@
copyright = '''
gpp – Bash-based general-purpose preprocessor
-Copyright © 2013, 2014, 2015 Mattias Andrée (maandree@member.fsf.org)
+Copyright © 2013, 2014, 2015, 2017 Mattias Andrée (maandree@member.fsf.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -93,7 +93,7 @@ if iterations < 1:
data = None
with open(input_file, 'rb') as file:
data = file.read()
- with open(write_file, 'wb') as file:
+ with open(output_file, 'wb') as file:
file.write(data)
file.flush()
sys.exit(0)
@@ -178,6 +178,11 @@ def pp(line):
elif c == ord('\\'):
esc = True
rc.append(c)
+ elif line[i - 1 : i + symlen - 1] == symbol:
+ if symb:
+ rc += symbol
+ symb = not symb
+ i += symlen - 1
elif symb:
symb = False
if c in (ord('('), ord('{')):
@@ -192,9 +197,6 @@ def pp(line):
rc.append(ord('\\'))
rc.append(c)
rc.append(c)
- elif line[i - 1 : i + symlen - 1] == symbol:
- symb = True
- i += symlen - 1
elif c == ord('\''):
rc.append(c)
rc.append(ord('\\'))