mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Fix reporting the last line on error if it doesn't end in \n.
If the last line of the file didn't end in LF, and an error was reported right in that line, two characters would be missing from that line in the output. Fixed.
This commit is contained in:
parent
697e80cb16
commit
95bd3209be
1 changed files with 4 additions and 2 deletions
6
main.py
6
main.py
|
@ -30,8 +30,10 @@ VERSION = '0.2.0beta'
|
|||
|
||||
|
||||
def ReportError(script, e):
|
||||
sys.stderr.write(script[fieldpos(script, '\n', e.lno):
|
||||
fieldpos(script, '\n', e.lno+1)-1] + '\n')
|
||||
lastpos = fieldpos(script, '\n', e.lno+1)-1
|
||||
assert lastpos != -1
|
||||
if lastpos < -1: lastpos = len(script) # may hit EOF
|
||||
sys.stderr.write(script[fieldpos(script, '\n', e.lno):lastpos] + '\n')
|
||||
sys.stderr.write(' ' * e.cno + '^\n')
|
||||
sys.stderr.write(e[0] + '\n')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue