From: Luke Kenneth Casson Leighton Date: Sun, 23 May 2021 21:13:47 +0000 (+0100) Subject: read all lines in advance, in case of in-place overwrite X-Git-Tag: xlen-bcd~569 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55cbfb92d1ca477c8a33c09aa824a4c0c1454a3e;p=openpower-isa.git read all lines in advance, in case of in-place overwrite --- 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)