From 2619c30fe9d15e4c3ee8d855cac5847c2dd22093 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Sun, 29 Sep 2013 18:35:21 -0700 Subject: [PATCH] fix(script/demangle_cpptype): process line-by-line, instead of waiting for EOF --- script/demangle_cpptype.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/script/demangle_cpptype.py b/script/demangle_cpptype.py index 3036001e28..e809ef8bde 100755 --- a/script/demangle_cpptype.py +++ b/script/demangle_cpptype.py @@ -17,6 +17,7 @@ # It calls "c++filt" to do the work. # import re +import sys import subprocess import fileinput @@ -25,7 +26,7 @@ pattern = re.compile(pattern_str) cppfilt = "c++filt" cppfilt_option = "--types" -for line in fileinput.input(): +def process_line(line): result = pattern.match(line); if result == None: print line, @@ -36,3 +37,13 @@ for line in fileinput.input(): retval= p.wait() new_str = re.sub(pattern_str, r"\1" + ty + r"\3", line); print new_str, + +if len(sys.argv) > 1: + for line in fileinput.input(): + process_line(line) +else: + while True: + line = sys.stdin.readline() + if not line: + break + process_line(line)