version 0.8.5: bugfixes; compiler now maintained in Nimrod
This commit is contained in:
parent
196ef92c86
commit
90119066ad
30 changed files with 1248 additions and 3819 deletions
|
|
@ -339,3 +339,37 @@ proc writeContentType*() =
|
|||
write(stdout, "Content-type: text/html\n\n")
|
||||
system.stackTraceNewLine = "<br />\n"
|
||||
|
||||
proc setCookie*(name, value: string) =
|
||||
## Sets a cookie.
|
||||
write(stdout, "Set-Cookie: ", name, "=", value, "\n")
|
||||
|
||||
var
|
||||
cookies: PStringTable = nil
|
||||
|
||||
proc parseCookies(s: string): PStringTable =
|
||||
result = newStringTable(modeCaseInsensitive)
|
||||
var i = 0
|
||||
while true:
|
||||
while s[i] == ' ' or s[i] == '\t': inc(i)
|
||||
var keystart = i
|
||||
while s[i] != '=' and s[i] != '\0': inc(i)
|
||||
var keyend = i-1
|
||||
if s[i] == '\0': break
|
||||
inc(i) # skip '='
|
||||
var valstart = i
|
||||
while s[i] != ';' and s[i] != '\0': inc(i)
|
||||
result[copy(s, keystart, keyend)] = copy(s, valstart, i-1)
|
||||
if s[i] == '\0': break
|
||||
inc(i) # skip ';'
|
||||
|
||||
proc getCookie*(name: string): string =
|
||||
## Gets a cookie. If no cookie of `name` exists, "" is returned.
|
||||
if cookies == nil: cookies = parseCookies(getHttpCookie())
|
||||
result = cookies[name]
|
||||
|
||||
proc existsCookie*(name: string): bool =
|
||||
## Checks if a cookie of `name` exists.
|
||||
if cookies == nil: cookies = parseCookies(getHttpCookie())
|
||||
result = hasKey(cookies)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -906,7 +906,7 @@ proc removeDir*(dir: string) =
|
|||
for kind, path in walkDir(dir):
|
||||
case kind
|
||||
of pcFile, pcLinkToFile, pcLinkToDir: removeFile(path)
|
||||
of pcDir: removeDir(dir)
|
||||
of pcDir: removeDir(path)
|
||||
rawRemoveDir(dir)
|
||||
|
||||
proc rawCreateDir(dir: string) =
|
||||
|
|
@ -935,7 +935,7 @@ proc parseCmdLine*(c: string): seq[string] =
|
|||
result = @[]
|
||||
var i = 0
|
||||
var a = ""
|
||||
while c[i] != '\0':
|
||||
while true:
|
||||
setLen(a, 0)
|
||||
while c[i] >= '\1' and c[i] <= ' ': inc(i) # skip whitespace
|
||||
case c[i]
|
||||
|
|
@ -946,6 +946,7 @@ proc parseCmdLine*(c: string): seq[string] =
|
|||
add a, c[i]
|
||||
inc(i)
|
||||
if c[i] != '\0': inc(i)
|
||||
of '\0': break
|
||||
else:
|
||||
while c[i] > ' ':
|
||||
add(a, c[i])
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ iterator split*(s: string, sep: char): string =
|
|||
inc(last)
|
||||
|
||||
iterator splitLines*(s: string): string =
|
||||
## Splits the string `s` into its containing lines. Each newline
|
||||
## Splits the string `s` into its containing lines. Every newline
|
||||
## combination (CR, LF, CR-LF) is supported. The result strings contain
|
||||
## no trailing ``\n``.
|
||||
##
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue