mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
resolved conflicts with master
This commit is contained in:
@@ -699,7 +699,18 @@ proc formatNamedVars*(frmt: string, varnames: openArray[string],
|
||||
|
||||
|
||||
proc defaultConfig*(): PStringTable =
|
||||
## creates a default configuration for HTML generation.
|
||||
## Returns a default configuration for embedded HTML generation.
|
||||
##
|
||||
## The returned ``PStringTable`` contains the paramters used by the HTML
|
||||
## engine to build the final output. For information on what these parameters
|
||||
## are and their purpose, please look up the file ``config/nimdoc.cfg``
|
||||
## bundled with the compiler.
|
||||
##
|
||||
## The only difference between the contents of that file and the values
|
||||
## provided by this proc is the ``doc.file`` variable. The ``doc.file``
|
||||
## variable of the configuration file contains HTML to build standalone
|
||||
## pages, while this proc returns just the content for procs like
|
||||
## ``rstToHtml`` to generate the bare minimum HTML.
|
||||
result = newStringTable(modeStyleInsensitive)
|
||||
|
||||
template setConfigVar(key, val: expr) =
|
||||
|
||||
@@ -233,8 +233,11 @@ proc asyncSockHandleWrite(h: PObject) =
|
||||
let sock = PAsyncSocket(h)
|
||||
try:
|
||||
let bytesSent = sock.socket.sendAsync(sock.sendBuffer)
|
||||
assert bytesSent > 0
|
||||
if bytesSent != sock.sendBuffer.len:
|
||||
if bytesSent == 0:
|
||||
# Apparently the socket cannot be written to. Even though select
|
||||
# just told us that it can be... This used to be an assert. Just
|
||||
# do nothing instead.
|
||||
elif bytesSent != sock.sendBuffer.len:
|
||||
sock.sendBuffer = sock.sendBuffer[bytesSent .. -1]
|
||||
elif bytesSent == sock.sendBuffer.len:
|
||||
sock.sendBuffer = ""
|
||||
|
||||
@@ -220,9 +220,8 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse =
|
||||
inc(linei, le)
|
||||
if line[linei] != ':': httpError("invalid headers")
|
||||
inc(linei) # Skip :
|
||||
linei += skipWhitespace(line, linei)
|
||||
|
||||
result.headers[name] = line[linei.. -1]
|
||||
result.headers[name] = line[linei.. -1].strip()
|
||||
if not fullyRead:
|
||||
httpError("Connection was closed before full request has been made")
|
||||
if getBody:
|
||||
|
||||
@@ -387,6 +387,14 @@ proc existsDir*(dir: string): bool {.rtl, extern: "nos$1", tags: [FReadDir].} =
|
||||
var res: TStat
|
||||
return stat(dir, res) >= 0'i32 and S_ISDIR(res.st_mode)
|
||||
|
||||
proc fileExists*(filename: string): bool {.inline.} =
|
||||
## Synonym for existsFile
|
||||
existsFile(filename)
|
||||
|
||||
proc dirExists*(dir: string): bool {.inline.} =
|
||||
## Synonym for existsDir
|
||||
existsDir(dir)
|
||||
|
||||
proc getLastModificationTime*(file: string): TTime {.rtl, extern: "nos$1".} =
|
||||
## Returns the `file`'s last modification time.
|
||||
when defined(posix):
|
||||
|
||||
@@ -132,6 +132,10 @@ proc toUTF8*(c: TRune): string {.rtl, extern: "nuc$1".} =
|
||||
result = newString(1)
|
||||
result[0] = chr(i)
|
||||
|
||||
proc `$`*(rune: TRune): string =
|
||||
## converts a rune to a string
|
||||
rune.toUTF8
|
||||
|
||||
proc `$`*(runes: seq[TRune]): string =
|
||||
## converts a sequence of runes to a string
|
||||
result = ""
|
||||
|
||||
@@ -2708,7 +2708,23 @@ proc locals*(): TObject {.magic: "Locals", noSideEffect.} =
|
||||
## in the current scope. This is quite fast as it does not rely
|
||||
## on any debug or runtime information. Note that in constrast to what
|
||||
## the official signature says, the return type is not ``TObject`` but a
|
||||
## tuple of a structure that depends on the current scope.
|
||||
## tuple of a structure that depends on the current scope. Example:
|
||||
##
|
||||
## .. code-block:: nimrod
|
||||
## proc testLocals() =
|
||||
## var
|
||||
## a = "something"
|
||||
## b = 4
|
||||
## c = locals()
|
||||
## d = "super!"
|
||||
##
|
||||
## b = 1
|
||||
## for name, value in fieldPairs(c):
|
||||
## echo "name ", name, " with value ", value
|
||||
## echo "B is ", b
|
||||
## # -> name a with value something
|
||||
## # -> name b with value 4
|
||||
## # -> B is 1
|
||||
discard
|
||||
|
||||
when not defined(booting):
|
||||
@@ -2719,4 +2735,3 @@ when not defined(booting):
|
||||
|
||||
template isStatic*(x): expr = compiles(static(x))
|
||||
# checks whether `x` is a value known at compile-time
|
||||
|
||||
|
||||
Reference in New Issue
Block a user