Fix renderer's errors (#7742)

* Fix renderer's errors

* Same for filter_tmpl

* var -> let
This commit is contained in:
Dmitry Atamanov 2018-05-01 20:45:38 +03:00 • committed by Andreas Rumpf
commit 82275e3779
2 changed files with 9 additions and 6 deletions

View file

@ -42,7 +42,8 @@ proc newLine(p: var TTmplParser) =
proc scanPar(p: var TTmplParser, d: int) = proc scanPar(p: var TTmplParser, d: int) =
var i = d var i = d
while true: let hi = p.x.len - 1
while i <= hi:
case p.x[i] case p.x[i]
of '\0': break of '\0': break
of '(': inc(p.par) of '(': inc(p.par)

View file

@ -175,10 +175,11 @@ proc put(g: var TSrcGen, kind: TTokType, s: string) =
proc putComment(g: var TSrcGen, s: string) = proc putComment(g: var TSrcGen, s: string) =
if s.isNil: return if s.isNil: return
var i = 0 var i = 0
let hi = len(s) - 1
var isCode = (len(s) >= 2) and (s[1] != ' ') var isCode = (len(s) >= 2) and (s[1] != ' ')
var ind = g.lineLen var ind = g.lineLen
var com = "## " var com = "## "
while true: while i <= hi:
case s[i] case s[i]
of '\0': of '\0':
break break
@ -201,12 +202,12 @@ proc putComment(g: var TSrcGen, s: string) =
# gets too long: # gets too long:
# compute length of the following word: # compute length of the following word:
var j = i var j = i
while s[j] > ' ': inc(j) while j <= hi and s[j] > ' ': inc(j)
if not isCode and (g.lineLen + (j - i) > MaxLineLen): if not isCode and (g.lineLen + (j - i) > MaxLineLen):
put(g, tkComment, com) put(g, tkComment, com)
optNL(g, ind) optNL(g, ind)
com = "## " com = "## "
while s[i] > ' ': while i <= hi and s[i] > ' ':
add(com, s[i]) add(com, s[i])
inc(i) inc(i)
put(g, tkComment, com) put(g, tkComment, com)
@ -215,8 +216,9 @@ proc putComment(g: var TSrcGen, s: string) =
proc maxLineLength(s: string): int = proc maxLineLength(s: string): int =
if s.isNil: return 0 if s.isNil: return 0
var i = 0 var i = 0
let hi = len(s) - 1
var lineLen = 0 var lineLen = 0
while true: while i <= hi:
case s[i] case s[i]
of '\0': of '\0':
break break
@ -235,7 +237,7 @@ proc maxLineLength(s: string): int =
proc putRawStr(g: var TSrcGen, kind: TTokType, s: string) = proc putRawStr(g: var TSrcGen, kind: TTokType, s: string) =
var i = 0 var i = 0
var hi = len(s) - 1 let hi = len(s) - 1
var str = "" var str = ""
while i <= hi: while i <= hi:
case s[i] case s[i]