From 55cbfb92d1ca477c8a33c09aa824a4c0c1454a3e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 23 May 2021 22:13:47 +0100 Subject: [PATCH] read all lines in advance, in case of in-place overwrite --- src/openpower/sv/trans/svp64.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openpower/sv/trans/svp64.py b/src/openpower/sv/trans/svp64.py index ee3bcb05..274016a1 100644 --- a/src/openpower/sv/trans/svp64.py +++ b/src/openpower/sv/trans/svp64.py @@ -681,6 +681,8 @@ def asm_process(): if len(args) == 0: infile = sys.stdin outfile = sys.stdout + # read the whole lot in advance in case of in-place + lines = list(infile.readlines()) elif len(args) != 2: print ("pysvp64asm [infile | -] [outfile | -]") exit(0) @@ -689,6 +691,9 @@ def asm_process(): infile = sys.stdin else: infile = open(args[0], "r") + # read the whole lot in advance in case of in-place overwrite + lines = list(infile.readlines()) + if args[1] == '--': outfile = sys.stdout else: @@ -696,7 +701,7 @@ def asm_process(): # read the line, look for "sv", process it isa = SVP64Asm([]) - for line in infile.readlines(): + for line in lines: ls = line.split("#") if len(ls) != 2: outfile.write(line) -- 2.30.2