diff options
author | RSDuck <RSDuck@users.noreply.github.com> | 2020-12-14 13:28:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 13:28:03 +0100 |
commit | b6443c96a0114994fe43e266b358b24c183c1017 (patch) | |
tree | 0d42375dc3595bce949b210403776be83876ec83 /compiler | |
parent | 5e8e948ffce951d8284fe38489cd880255e56e7b (diff) | |
download | Nim-b6443c96a0114994fe43e266b358b24c183c1017.tar.gz |
fix #16334 (#16335)
* fix #16334 * rename isstdout -> isStdout * separate lastMsgWasDot for stdout and stderr * simplify logic
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/msgs.nim | 14 | ||||
-rw-r--r-- | compiler/options.nim | 6 |
2 files changed, 14 insertions, 6 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 1a005788e..d027ce960 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -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 @@ -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): diff --git a/compiler/options.nim b/compiler/options.nim index bf0a9a4ee..73c4c627d 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -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 @@ -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) |