Merge pull request #759 from zielmicha/stdmsg

Write tracebacks to stderr instead of stdout.
This commit is contained in:
Andreas Rumpf 2013-12-20 09:42:39 -08:00
commit 259d205ff6
8 changed files with 84 additions and 41 deletions

View file

@ -1951,15 +1951,13 @@ when not defined(JS): #and not defined(NimrodVM):
## The standard output stream.
stderr* {.importc: "stderr", header: "<stdio.h>".}: TFile
## The standard error stream.
##
## Note: In my opinion, this should not be used -- the concept of a
## separate error stream is a design flaw of UNIX. A separate *message
## stream* is a good idea, but since it is named ``stderr`` there are few
## programs out there that distinguish properly between ``stdout`` and
## ``stderr``. So, that's what you get if you don't name your variables
## appropriately. It also annoys people if redirection
## via ``>output.txt`` does not work because the program writes
## to ``stderr``.
when defined(useStdoutAsStdmsg):
template stdmsg*: TFile = stdout
else:
template stdmsg*: TFile = stderr
## Template which expands to either stdout or stderr depending on
## `useStdoutAsStdmsg` compile-time switch.
proc Open*(f: var TFile, filename: string,
mode: TFileMode = fmRead, bufSize: int = -1): Bool {.tags: [].}