mirror of https://github.com/Hilbis/Hilbish
fix: add newline at the beginning of file buffer when there is shebang
this makes the line count in error messages line up properlylua5.4
parent
8a34783fee
commit
e6563fbd8b
|
@ -71,15 +71,16 @@ func DoFile(rtm *rt.Runtime, path string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var buf []byte
|
||||||
if c == byte('#') {
|
if c == byte('#') {
|
||||||
// shebang - skip that line
|
// shebang - skip that line
|
||||||
_, err := reader.ReadBytes('\n')
|
_, err := reader.ReadBytes('\n')
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
buf = []byte{'\n'}
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf []byte
|
|
||||||
for {
|
for {
|
||||||
line, err := reader.ReadBytes('\n')
|
line, err := reader.ReadBytes('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue