diff options
author | Michael Voronin <survivor.mail@gmail.com> | 2018-05-03 17:12:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-03 17:12:01 +0300 |
commit | 5ea967d97a30f0084883d4efa81b05bea3e5d148 (patch) | |
tree | 05ea0e3624f6720c2f5af28b5a70c87c85feafc7 /compiler/renderer.nim | |
parent | 3949c9f977378ea3ab2b3c750f4dc2bc8d853022 (diff) | |
parent | 5564289b577c620cbd775f477b7fc8b6507adbfa (diff) | |
download | Nim-5ea967d97a30f0084883d4efa81b05bea3e5d148.tar.gz |
Merge pull request #3 from nim-lang/devel
pull #3
Diffstat (limited to 'compiler/renderer.nim')
-rw-r--r-- | compiler/renderer.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 2a65a10a8..95a622d4e 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -175,10 +175,11 @@ proc put(g: var TSrcGen, kind: TTokType, s: string) = proc putComment(g: var TSrcGen, s: string) = if s.isNil: return var i = 0 + let hi = len(s) - 1 var isCode = (len(s) >= 2) and (s[1] != ' ') var ind = g.lineLen var com = "## " - while true: + while i <= hi: case s[i] of '\0': break @@ -201,12 +202,12 @@ proc putComment(g: var TSrcGen, s: string) = # gets too long: # compute length of the following word: 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): put(g, tkComment, com) optNL(g, ind) com = "## " - while s[i] > ' ': + while i <= hi and s[i] > ' ': add(com, s[i]) inc(i) put(g, tkComment, com) @@ -215,8 +216,9 @@ proc putComment(g: var TSrcGen, s: string) = proc maxLineLength(s: string): int = if s.isNil: return 0 var i = 0 + let hi = len(s) - 1 var lineLen = 0 - while true: + while i <= hi: case s[i] of '\0': break @@ -235,7 +237,7 @@ proc maxLineLength(s: string): int = proc putRawStr(g: var TSrcGen, kind: TTokType, s: string) = var i = 0 - var hi = len(s) - 1 + let hi = len(s) - 1 var str = "" while i <= hi: case s[i] @@ -1064,6 +1066,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = if n.len > 1: let opr = if n[0].kind == nkIdent: n[0].ident elif n[0].kind == nkSym: n[0].sym.name + elif n[0].kind in {nkOpenSymChoice, nkClosedSymChoice}: n[0][0].sym.name else: nil if n[1].kind == nkPrefix or (opr != nil and renderer.isKeyword(opr)): put(g, tkSpaces, Space) |