Skip to content

Commit c3e39f9

Browse files
committed
bugfixes
1 parent fe2212f commit c3e39f9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

console.nim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ proc sendBreak*(c: Console) =
394394
proc extractFilePosition*(b: Buffer): (string, int, int) =
395395
## Line is -1 if not an interpretable file position.
396396
template parseNumber(line) =
397-
while b[i] in Digits:
397+
while i < b.len and b[i] in Digits:
398398
line = line * 10 + (b[i].ord - '0'.ord)
399399
inc i
400400

@@ -404,32 +404,32 @@ proc extractFilePosition*(b: Buffer): (string, int, int) =
404404
var i = b.cursor
405405
while i > 0 and b[i-1] != '\L': dec i
406406
result = ("", -1, -1)
407-
while b[i] == ' ': inc i
407+
while i < b.len and b[i] == ' ': inc i
408408
while i < b.len and b[i] != ' ':
409409
if b[i] == '(': break
410-
elif b[i] == ':' and b[i+1] != '\\': break
410+
elif b[i] == ':' and i+1 < b.len and b[i+1] != '\\': break
411411
result[0].add b[i]
412412
inc i
413413
var line, col: int
414-
if b[i] == '(' and b[i+1] in Digits:
414+
if i+1 < b.len and b[i] == '(' and b[i+1] in Digits:
415415
inc i
416416
parseNumber(line)
417-
if b[i] == ',':
417+
if i < b.len and b[i] == ',':
418418
inc i
419419
while b[i] == ' ': inc i
420420
parseNumber(col)
421421
else:
422422
col = -1
423-
if b[i] == ')':
423+
if i < b.len and b[i] == ')':
424424
result[1] = line
425425
result[2] = col
426-
elif b[i] == ':' and b[i+1] in Digits:
426+
elif i+1 < b.len and b[i] == ':' and b[i+1] in Digits:
427427
inc i
428428
parseNumber(line)
429-
if b[i] == ':':
429+
if i < b.len and b[i] == ':':
430430
inc i
431431
parseNumber(col)
432-
if b[i] == ':':
432+
if i < b.len and b[i] == ':':
433433
result[1] = line
434434
result[2] = col
435435

0 commit comments

Comments
 (0)