fixes c2nim regression; do not produce more newlines

This commit is contained in:
Andreas Rumpf 2017-10-19 13:29:05 +02:00
commit 186e7d49d3

View file

@ -37,8 +37,8 @@ type
inGenericParams: bool
checkAnon: bool # we're in a context that can contain sfAnon
inPragma: int
pendingNewlineCount: int
when defined(nimpretty):
pendingNewlineCount: int
origContent: string
@ -113,7 +113,10 @@ proc addTok(g: var TSrcGen, kind: TTokType, s: string) =
proc addPendingNL(g: var TSrcGen) =
if g.pendingNL >= 0:
when defined(nimpretty):
let newlines = repeat("\n", clamp(g.pendingNewlineCount, 1, 3))
else:
const newlines = "\n"
addTok(g, tkSpaces, newlines & spaces(g.pendingNL))
g.lineLen = g.pendingNL
g.pendingNL = - 1
@ -139,7 +142,7 @@ proc putNL(g: var TSrcGen) =
proc optNL(g: var TSrcGen, indent: int) =
g.pendingNL = indent
g.lineLen = indent
g.pendingNewlineCount = 0
when defined(nimpretty): g.pendingNewlineCount = 0
proc optNL(g: var TSrcGen) =
optNL(g, g.indent)
@ -147,7 +150,7 @@ proc optNL(g: var TSrcGen) =
proc optNL(g: var TSrcGen; a, b: PNode) =
g.pendingNL = g.indent
g.lineLen = g.indent
g.pendingNewlineCount = lineDiff(a, b)
when defined(nimpretty): g.pendingNewlineCount = lineDiff(a, b)
proc indentNL(g: var TSrcGen) =
inc(g.indent, IndentWidth)