mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 15:04:59 +00:00
remove default argument for readLines (#12807) [backport]
(cherry picked from commit c949b81efd)
This commit is contained in:
@@ -143,7 +143,7 @@ proc registerAdditionalOps*(c: PCtx) =
|
||||
wrap1s(fileExists, osop)
|
||||
wrapDangerous(writeFile, ioop)
|
||||
wrap1s(readFile, ioop)
|
||||
wrap2si(readLines, ioop)
|
||||
wrap2si(staticReadLines, ioop)
|
||||
systemop getCurrentExceptionMsg
|
||||
systemop getCurrentException
|
||||
registerCallback c, "stdlib.*.staticWalkDir", proc (a: VmArgs) {.nimcall.} =
|
||||
|
||||
@@ -686,10 +686,10 @@ proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], benign.} =
|
||||
sysFatal(IOError, "cannot open: " & filename)
|
||||
|
||||
|
||||
proc readLines*(filename: string, n = 1.Natural): seq[TaintedString] =
|
||||
## read `n` lines from the file named `filename`. Raises an IO exception
|
||||
proc staticReadLines*(filename: string, n: Natural): seq[TaintedString] =
|
||||
## Compile time read `n` lines from the file named `filename`. Raises an IO exception
|
||||
## in case of an error. Raises EOF if file does not contain at least `n` lines.
|
||||
## Available at compile time. A line of text may be delimited by ``LF`` or ``CRLF``.
|
||||
## A line of text may be delimited by ``LF`` or ``CRLF``.
|
||||
## The newline character(s) are not part of the returned strings.
|
||||
var f: File
|
||||
if open(f, filename):
|
||||
|
||||
@@ -13,7 +13,7 @@ static:
|
||||
writeFile(filename, mytext)
|
||||
const myfile_str = staticRead(filename)
|
||||
const myfile_str2 = readFile(filename)
|
||||
const myfile_str_seq = readLines(filename, 3)
|
||||
const myfile_str_seq = staticReadLines(filename, 3)
|
||||
|
||||
static:
|
||||
doAssert myfile_str == mytext
|
||||
|
||||
Reference in New Issue
Block a user