Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix nim-lang#16334

* rename isstdout -> isStdout

* separate lastMsgWasDot for stdout and stderr

* simplify logic
  • Loading branch information
RSDuck authored and ardek66 committed Mar 26, 2021
1 parent 2232ec2 commit 819b159
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 9 additions & 5 deletions compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ import strutils2
type InstantiationInfo* = typeof(instantiationInfo())
template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)

template flushDot(conf, stdorr) =
template toStdOrrKind(stdOrr): untyped =
if stdOrr == stdout: stdOrrStdout else: stdOrrStderr

template flushDot(conf, stdOrr) =
## safe to call multiple times
if conf.lastMsgWasDot:
conf.lastMsgWasDot = false
write(stdorr, "\n")
let stdOrrKind = stdOrr.toStdOrrKind()
if stdOrrKind in conf.lastMsgWasDot:
conf.lastMsgWasDot.excl stdOrrKind
write(stdOrr, "\n")

proc toCChar*(c: char; result: var string) =
case c
Expand Down Expand Up @@ -357,7 +361,7 @@ proc msgWrite(conf: ConfigRef; s: string) =
stderr
write(stdOrr, s)
flushFile(stdOrr)
conf.lastMsgWasDot = true # subsequent writes need `flushDot`
conf.lastMsgWasDot.incl stdOrr.toStdOrrKind() # subsequent writes need `flushDot`

template styledMsgWriteln*(args: varargs[typed]) =
if not isNil(conf.writelnHook):
Expand Down
6 changes: 5 additions & 1 deletion compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ type
ProfileData* = ref object
data*: TableRef[TLineInfo, ProfileInfo]

StdOrrKind* = enum
stdOrrStdout
stdOrrStderr

ConfigRef* = ref object ## every global configuration
## fields marked with '*' are subject to
## the incremental compilation mechanisms
Expand Down Expand Up @@ -304,7 +308,7 @@ type
projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/
projectFull*: AbsoluteFile # projectPath/projectName
projectIsStdin*: bool # whether we're compiling from stdin
lastMsgWasDot*: bool # the last compiler message was a single '.'
lastMsgWasDot*: set[StdOrrKind] # the last compiler message was a single '.'
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 819b159

Please sign in to comment.