Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RSDuck committed Dec 12, 2020
1 parent d15f63a commit 91f0046
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import strutils2
type InstantiationInfo* = typeof(instantiationInfo())
template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)

template flushDot(conf, stdorr) =
template flushDot(conf, stdorr, isstdout) =
## safe to call multiple times
if conf.lastMsgWasDot:
if conf.lastMsgWasDot and conf.dotStdout == isstdout:
conf.lastMsgWasDot = false
write(stdorr, "\n")

Expand Down Expand Up @@ -305,12 +305,12 @@ proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) =
conf.writelnHook(s)
elif optStdout in conf.globalOptions or msgStdout in flags:
if eStdOut in conf.m.errorOutputs:
flushDot(conf, stdout)
flushDot(conf, stdout, true)
writeLine(stdout, s)
flushFile(stdout)
else:
if eStdErr in conf.m.errorOutputs:
flushDot(conf, stderr)
flushDot(conf, stderr, false)
writeLine(stderr, s)
# On Windows stderr is fully-buffered when piped, regardless of C std.
when defined(windows):
Expand Down Expand Up @@ -348,8 +348,9 @@ template callWritelnHook(args: varargs[string, `$`]) =

proc msgWrite(conf: ConfigRef; s: string) =
if conf.m.errorOutputs != {}:
conf.dotStdout = optStdout in conf.globalOptions
let stdOrr =
if optStdout in conf.globalOptions:
if conf.dotStdout:
stdout
else:
stderr
Expand All @@ -362,11 +363,11 @@ template styledMsgWriteln*(args: varargs[typed]) =
callIgnoringStyle(callWritelnHook, nil, args)
elif optStdout in conf.globalOptions:
if eStdOut in conf.m.errorOutputs:
flushDot(conf, stdout)
flushDot(conf, stdout, true)
callIgnoringStyle(writeLine, stdout, args)
flushFile(stdout)
elif eStdErr in conf.m.errorOutputs:
flushDot(conf, stderr)
flushDot(conf, stderr, false)
if optUseColors in conf.globalOptions:
callStyledWriteLineStderr(args)
else:
Expand Down
1 change: 1 addition & 0 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ type
projectFull*: AbsoluteFile # projectPath/projectName
projectIsStdin*: bool # whether we're compiling from stdin
lastMsgWasDot*: bool # the last compiler message was a single '.'
dotStdout*: bool # if the last message was a '.', whether it was output to stdout
projectMainIdx*: FileIndex # the canonical path id of the main module
projectMainIdx2*: FileIndex # consider merging with projectMainIdx
command*: string # the main command (e.g. cc, check, scan, etc)
Expand Down

0 comments on commit 91f0046

Please sign in to comment.