diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/impure/re.nim | 2 | ||||
-rw-r--r-- | lib/packages/docutils/rst.nim | 2 | ||||
-rw-r--r-- | lib/pure/cgi.nim | 6 | ||||
-rw-r--r-- | lib/pure/logging.nim | 6 | ||||
-rw-r--r-- | lib/pure/nimprof.nim | 6 | ||||
-rw-r--r-- | lib/pure/parsesql.nim | 2 | ||||
-rw-r--r-- | lib/pure/pegs.nim | 2 | ||||
-rw-r--r-- | lib/pure/streams.nim | 7 | ||||
-rw-r--r-- | lib/pure/strutils.nim | 12 | ||||
-rw-r--r-- | lib/pure/terminal.nim | 6 | ||||
-rw-r--r-- | lib/system.nim | 10 | ||||
-rw-r--r-- | lib/system/endb.nim | 6 | ||||
-rw-r--r-- | lib/system/sysio.nim | 7 |
13 files changed, 44 insertions, 30 deletions
diff --git a/lib/impure/re.nim b/lib/impure/re.nim index 5f9371f28..0df8d4a9c 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -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: ## diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index ae3ed8feb..2fbde632e 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -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 diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim index e8977b80b..cfd768f91 100644 --- a/lib/pure/cgi.nim +++ b/lib/pure/cgi.nim @@ -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 diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index b28298dfa..7a900daae 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -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 # -------- diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim index 765d1e341..cfe6bc40d 100644 --- a/lib/pure/nimprof.nim +++ b/lib/pure/nimprof.nim @@ -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: diff --git a/lib/pure/parsesql.nim b/lib/pure/parsesql.nim index 91917b1c5..cfa60094d 100644 --- a/lib/pure/parsesql.nim +++ b/lib/pure/parsesql.nim @@ -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. diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index e165d7dca..28f6a17e6 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -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: ## diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 50b5c219a..8aa8d35d8 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -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) diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 317da9a0a..93fcf4d3d 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -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: ## diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 2efdf72d5..b6d99e429 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -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}) diff --git a/lib/system.nim b/lib/system.nim index 2beb5b88d..34531eb46 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -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. diff --git a/lib/system/endb.nim b/lib/system/endb.nim index ef2664796..cba11ac5e 100644 --- a/lib/system/endb.nim +++ b/lib/system/endb.nim @@ -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) = diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 3f860655e..5464ee126 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -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") |