fixes #7293
This commit is contained in:
parent
1b760dcd66
commit
5c8332d871
1 changed files with 3 additions and 3 deletions
|
|
@ -2295,7 +2295,7 @@ proc addf*(s: var string, formatstr: string, a: varargs[string, `$`]) {.
|
||||||
case formatstr[i+1] # again we use the fact that strings
|
case formatstr[i+1] # again we use the fact that strings
|
||||||
# are zero-terminated here
|
# are zero-terminated here
|
||||||
of '#':
|
of '#':
|
||||||
if num >% a.high: invalidFormatString()
|
if num > a.high: invalidFormatString()
|
||||||
add s, a[num]
|
add s, a[num]
|
||||||
inc i, 2
|
inc i, 2
|
||||||
inc num
|
inc num
|
||||||
|
|
@ -2311,7 +2311,7 @@ proc addf*(s: var string, formatstr: string, a: varargs[string, `$`]) {.
|
||||||
j = j * 10 + ord(formatstr[i]) - ord('0')
|
j = j * 10 + ord(formatstr[i]) - ord('0')
|
||||||
inc(i)
|
inc(i)
|
||||||
let idx = if not negative: j-1 else: a.len-j
|
let idx = if not negative: j-1 else: a.len-j
|
||||||
if idx >% a.high: invalidFormatString()
|
if idx < 0 or idx > a.high: invalidFormatString()
|
||||||
add s, a[idx]
|
add s, a[idx]
|
||||||
of '{':
|
of '{':
|
||||||
var j = i+2
|
var j = i+2
|
||||||
|
|
@ -2328,7 +2328,7 @@ proc addf*(s: var string, formatstr: string, a: varargs[string, `$`]) {.
|
||||||
inc(j)
|
inc(j)
|
||||||
if isNumber == 1:
|
if isNumber == 1:
|
||||||
let idx = if not negative: k-1 else: a.len-k
|
let idx = if not negative: k-1 else: a.len-k
|
||||||
if idx >% a.high: invalidFormatString()
|
if idx < 0 or idx > a.high: invalidFormatString()
|
||||||
add s, a[idx]
|
add s, a[idx]
|
||||||
else:
|
else:
|
||||||
var x = findNormalized(substr(formatstr, i+2, j-1), a)
|
var x = findNormalized(substr(formatstr, i+2, j-1), a)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue