From ab273d8948d88df7269358973f8151513b00a40f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 13 Feb 2017 08:46:05 +0100 Subject: Fix -n and escaped symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- COPYING | 2 +- doc/man/gpp.1 | 2 +- src/gpp.py | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/COPYING b/COPYING index 63a681e..0054035 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ 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 diff --git a/doc/man/gpp.1 b/doc/man/gpp.1 index d64ef9d..d7ba2e5 100644 --- a/doc/man/gpp.1 +++ b/doc/man/gpp.1 @@ -123,7 +123,7 @@ Full documentation available locally via: info \(aq(gpp)\(aq Principal author, Mattias Andrée. See the COPYING file for the full list of authors. .SH LICENSE -Copyright \(co 2013, 2014, 2015 Mattias Andrée +Copyright \(co 2013, 2014, 2015, 2017 Mattias Andrée .br License GPLv3+: GNU GPL version 3 or later . .br 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('\\')) -- cgit v1.2.3-70-g09d2