Merge pull request #2961 from Perelandric/rename_writeLn
Renamed writeln to writeLine. Issue #2958
This commit is contained in:
commit
e74012b396
71 changed files with 815 additions and 801 deletions
|
|
@ -369,7 +369,7 @@ iterator split*(s: string, sep: Regex): string =
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for word in split("00232this02939is39an22example111", re"\d+"):
|
||||
## writeln(stdout, word)
|
||||
## writeLine(stdout, word)
|
||||
##
|
||||
## Results in:
|
||||
##
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ proc defaultMsgHandler*(filename: string, line, col: int, msgkind: MsgKind,
|
|||
let a = messages[msgkind] % arg
|
||||
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
|
||||
if mc == mcError: raise newException(EParseError, message)
|
||||
else: writeln(stdout, message)
|
||||
else: writeLine(stdout, message)
|
||||
|
||||
proc defaultFindFile*(filename: string): string {.procvar.} =
|
||||
if existsFile(filename): result = filename
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
## # generate content:
|
||||
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
||||
## write(stdout, "<html><head><title>Test</title></head><body>\n")
|
||||
## writeln(stdout, "your name: " & myData["name"])
|
||||
## writeln(stdout, "your password: " & myData["password"])
|
||||
## writeln(stdout, "</body></html>")
|
||||
## writeLine(stdout, "your name: " & myData["name"])
|
||||
## writeLine(stdout, "your password: " & myData["password"])
|
||||
## writeLine(stdout, "</body></html>")
|
||||
|
||||
import strutils, os, strtabs, cookies
|
||||
|
||||
|
|
|
|||
|
|
@ -132,12 +132,12 @@ method log*(logger: Logger, level: Level, args: varargs[string, `$`]) {.
|
|||
method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
|
||||
## Logs to the console using ``logger`` only.
|
||||
if level >= logger.levelThreshold:
|
||||
writeln(stdout, substituteLog(logger.fmtStr, level, args))
|
||||
writeLine(stdout, substituteLog(logger.fmtStr, level, args))
|
||||
|
||||
method log*(logger: FileLogger, level: Level, args: varargs[string, `$`]) =
|
||||
## Logs to a file using ``logger`` only.
|
||||
if level >= logger.levelThreshold:
|
||||
writeln(logger.f, substituteLog(logger.fmtStr, level, args))
|
||||
writeLine(logger.f, substituteLog(logger.fmtStr, level, args))
|
||||
|
||||
proc defaultFilename*(): string =
|
||||
## Returns the default filename for a logger.
|
||||
|
|
@ -228,7 +228,7 @@ method log*(logger: RollingFileLogger, level: Level, args: varargs[string, `$`])
|
|||
logger.curLine = 0
|
||||
logger.f = open(logger.baseName, logger.baseMode, bufSize = logger.bufSize)
|
||||
|
||||
writeln(logger.f, substituteLog(logger.fmtStr, level, args))
|
||||
writeLine(logger.f, substituteLog(logger.fmtStr, level, args))
|
||||
logger.curLine.inc
|
||||
|
||||
# --------
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ proc writeProfile() {.noconv.} =
|
|||
var f: File
|
||||
if open(f, filename, fmWrite):
|
||||
sort(profileData, cmpEntries)
|
||||
writeln(f, "total executions of each stack trace:")
|
||||
writeLine(f, "total executions of each stack trace:")
|
||||
var entries = 0
|
||||
for i in 0..high(profileData):
|
||||
if profileData[i] != nil: inc entries
|
||||
|
|
@ -175,13 +175,13 @@ proc writeProfile() {.noconv.} =
|
|||
for i in 0..min(100, entries-1):
|
||||
if profileData[i].total > 1:
|
||||
inc sum, profileData[i].total
|
||||
writeln(f, "Entry: ", i+1, "/", entries, " Calls: ",
|
||||
writeLine(f, "Entry: ", i+1, "/", entries, " Calls: ",
|
||||
profileData[i].total // totalCalls, " [sum: ", sum, "; ",
|
||||
sum // totalCalls, "]")
|
||||
for ii in 0..high(StackTrace):
|
||||
let procname = profileData[i].st[ii]
|
||||
if isNil(procname): break
|
||||
writeln(f, " ", procname, " ", perProc[$procname] // totalCalls)
|
||||
writeLine(f, " ", procname, " ", perProc[$procname] // totalCalls)
|
||||
close(f)
|
||||
echo "... done"
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1323,7 +1323,7 @@ proc ra(n: SqlNode, s: var string, indent: int) =
|
|||
# where: x.name == y.name
|
||||
#db.select(fromm = [t1, t2], where = t1.name == t2.name):
|
||||
#for x, y, z in db.select(fromm = a, b where = a.name == b.name):
|
||||
# writeln x, y, z
|
||||
# writeLine x, y, z
|
||||
|
||||
proc renderSQL*(n: SqlNode): string =
|
||||
## Converts an SQL abstract syntax tree to its string representation.
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ iterator split*(s: string, sep: Peg): string =
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for word in split("00232this02939is39an22example111", peg"\d+"):
|
||||
## writeln(stdout, word)
|
||||
## writeLine(stdout, word)
|
||||
##
|
||||
## Results in:
|
||||
##
|
||||
|
|
|
|||
|
|
@ -117,7 +117,12 @@ proc write*(s: Stream, x: string) =
|
|||
## terminating zero is written.
|
||||
writeData(s, cstring(x), x.len)
|
||||
|
||||
proc writeln*(s: Stream, args: varargs[string, `$`]) =
|
||||
proc writeLn*(s: Stream, args: varargs[string, `$`]) {.deprecated.} =
|
||||
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
|
||||
for str in args: write(s, str)
|
||||
write(s, "\n")
|
||||
|
||||
proc writeLine*(s: Stream, args: varargs[string, `$`]) =
|
||||
## writes one or more strings to the the stream `s` followed
|
||||
## by a new line. No length field or terminating zero is written.
|
||||
for str in args: write(s, str)
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for word in split(" this is an example "):
|
||||
## writeln(stdout, word)
|
||||
## writeLine(stdout, word)
|
||||
##
|
||||
## ...generates this output:
|
||||
##
|
||||
|
|
@ -220,7 +220,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for word in split(";;this;is;an;;example;;;", {';'}):
|
||||
## writeln(stdout, word)
|
||||
## writeLine(stdout, word)
|
||||
##
|
||||
## ...produces the same output as the first example. The code:
|
||||
##
|
||||
|
|
@ -228,7 +228,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
|||
## let date = "2012-11-20T22:08:08.398990"
|
||||
## let separators = {' ', '-', ':', 'T'}
|
||||
## for number in split(date, separators):
|
||||
## writeln(stdout, number)
|
||||
## writeLine(stdout, number)
|
||||
##
|
||||
## ...results in:
|
||||
##
|
||||
|
|
@ -259,7 +259,7 @@ iterator split*(s: string, sep: char): string =
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for word in split(";;this;is;an;;example;;;", ';'):
|
||||
## writeln(stdout, word)
|
||||
## writeLine(stdout, word)
|
||||
##
|
||||
## Results in:
|
||||
##
|
||||
|
|
@ -309,7 +309,7 @@ iterator splitLines*(s: string): string =
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for line in splitLines("\nthis\nis\nan\n\nexample\n"):
|
||||
## writeln(stdout, line)
|
||||
## writeLine(stdout, line)
|
||||
##
|
||||
## Results in:
|
||||
##
|
||||
|
|
@ -571,7 +571,7 @@ iterator tokenize*(s: string, seps: set[char] = Whitespace): tuple[
|
|||
##
|
||||
## .. code-block:: nim
|
||||
## for word in tokenize(" this is an example "):
|
||||
## writeln(stdout, word)
|
||||
## writeLine(stdout, word)
|
||||
##
|
||||
## Results in:
|
||||
##
|
||||
|
|
|
|||
|
|
@ -430,8 +430,8 @@ macro styledEcho*(m: varargs[expr]): stmt =
|
|||
case item.kind
|
||||
of nnkStrLit..nnkTripleStrLit:
|
||||
if i == m.len - 1:
|
||||
# optimize if string literal is last, just call writeln
|
||||
result.add(newCall(bindSym"writeln", bindSym"stdout", item))
|
||||
# optimize if string literal is last, just call writeLine
|
||||
result.add(newCall(bindSym"writeLine", bindSym"stdout", item))
|
||||
if reset: result.add(newCall(bindSym"resetAttributes"))
|
||||
return
|
||||
else:
|
||||
|
|
@ -470,7 +470,7 @@ when not defined(testing) and isMainModule:
|
|||
writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore})
|
||||
setBackGroundColor(bgCyan, true)
|
||||
setForeGroundColor(fgBlue)
|
||||
writeln(stdout, "ordinary text")
|
||||
writeLine(stdout, "ordinary text")
|
||||
|
||||
styledEcho("styled text ", {styleBright, styleBlink, styleUnderscore})
|
||||
|
||||
|
|
|
|||
|
|
@ -898,7 +898,7 @@ proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
|
|||
##
|
||||
## .. code-block:: Nim
|
||||
## var s: set[range['a'..'z']] = {'a'..'c'}
|
||||
## writeln(stdout, 'b' in s)
|
||||
## writeLine(stdout, 'b' in s)
|
||||
##
|
||||
## If ``in`` had been declared as ``[T](elem: T, s: set[T])`` then ``T`` would
|
||||
## have been bound to ``char``. But ``s`` is not compatible to type
|
||||
|
|
@ -2269,7 +2269,7 @@ proc echo*(x: varargs[expr, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
|
|||
## Special built-in that takes a variable number of arguments. Each argument
|
||||
## is converted to a string via ``$``, so it works for user-defined
|
||||
## types that have an overloaded ``$`` operator.
|
||||
## It is roughly equivalent to ``writeln(stdout, x); flushFile(stdout)``, but
|
||||
## It is roughly equivalent to ``writeLine(stdout, x); flushFile(stdout)``, but
|
||||
## available for the JavaScript target too.
|
||||
##
|
||||
## Unlike other IO operations this is guaranteed to be thread-safe as
|
||||
|
|
@ -2526,7 +2526,11 @@ when not defined(JS): #and not defined(NimrodVM):
|
|||
## Returns ``false`` if the end of the file has been reached, ``true``
|
||||
## otherwise. If ``false`` is returned `line` contains no new data.
|
||||
|
||||
proc writeln*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
||||
proc writeLn*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
||||
tags: [WriteIOEffect], benign, deprecated.}
|
||||
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
|
||||
|
||||
proc writeLine*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
||||
tags: [WriteIOEffect], benign.}
|
||||
## writes the values `x` to `f` and then writes "\n".
|
||||
## May throw an IO exception.
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ proc dbgRepr(p: pointer, typ: PNimType): string =
|
|||
proc writeVariable(stream: File, slot: VarSlot) =
|
||||
write(stream, slot.name)
|
||||
write(stream, " = ")
|
||||
writeln(stream, dbgRepr(slot.address, slot.typ))
|
||||
writeLine(stream, dbgRepr(slot.address, slot.typ))
|
||||
|
||||
proc listFrame(stream: File, f: PFrame) =
|
||||
write(stream, EndbBeg)
|
||||
|
|
@ -125,7 +125,7 @@ proc listFrame(stream: File, f: PFrame) =
|
|||
write(stream, f.len)
|
||||
write(stream, " slots):\n")
|
||||
for i in 0 .. f.len-1:
|
||||
writeln(stream, getLocal(f, i).name)
|
||||
writeLine(stream, getLocal(f, i).name)
|
||||
write(stream, EndbEnd)
|
||||
|
||||
proc listLocals(stream: File, f: PFrame) =
|
||||
|
|
@ -141,7 +141,7 @@ proc listGlobals(stream: File) =
|
|||
write(stream, EndbBeg)
|
||||
write(stream, "| Globals:\n")
|
||||
for i in 0 .. getGlobalLen()-1:
|
||||
writeln(stream, getGlobal(i).name)
|
||||
writeLine(stream, getGlobal(i).name)
|
||||
write(stream, EndbEnd)
|
||||
|
||||
proc debugOut(msg: cstring) =
|
||||
|
|
|
|||
|
|
@ -208,10 +208,15 @@ proc endOfFile(f: File): bool =
|
|||
ungetc(c, f)
|
||||
return c < 0'i32
|
||||
|
||||
proc writeln[Ty](f: File, x: varargs[Ty, `$`]) =
|
||||
proc writeLn[Ty](f: File, x: varargs[Ty, `$`]) =
|
||||
for i in items(x): write(f, i)
|
||||
write(f, "\n")
|
||||
|
||||
proc writeLine[Ty](f: File, x: varargs[Ty, `$`]) =
|
||||
for i in items(x): write(f, i)
|
||||
write(f, "\n")
|
||||
|
||||
|
||||
proc rawEcho(x: string) {.inline, compilerproc.} = write(stdout, x)
|
||||
proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue