Merge branch 'devel' into fix_issues_9126

This commit is contained in:
Andreas Rumpf 2018-10-01 14:15:35 +02:00 • committed by GitHub
commit e867c8e5c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 219 additions and 114 deletions

View file

@ -183,7 +183,7 @@ proc sqlGetDBMS(db: var DbConn): string {.
db.sqlCheck(SQLGetInfo(db.hDb, SQL_DBMS_NAME, cast[SqlPointer](buf.addr),
4095.TSqlSmallInt, sz.addr))
except: discard
return $buf.cstring
return $(addr buf)
proc dbQuote*(s: string): string {.noSideEffect.} =
## DB quotes the string.
@ -201,10 +201,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string {.
var a = 0
for c in items(string(formatstr)):
if c == '?':
if args[a] == nil:
add(result, "NULL")
else:
add(result, dbQuote(args[a]))
add(result, dbQuote(args[a]))
inc(a)
else:
add(result, c)
@ -303,7 +300,7 @@ iterator fastRows*(db: var DbConn, query: SqlQuery,
buf[0] = '\0'
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
rowRes[colId-1] = $buf.cstring
rowRes[colId-1] = $(addr buf)
cCnt = tempcCnt
yield rowRes
res = SQLFetch(db.stmt)
@ -338,7 +335,7 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
buf[0] = '\0'
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
rowRes[colId-1] = $buf.cstring
rowRes[colId-1] = $(addr buf)
cCnt = tempcCnt
yield (row: rowRes, len: cCnt.int)
res = SQLFetch(db.stmt)
@ -380,7 +377,7 @@ proc getRow*(db: var DbConn, query: SqlQuery,
buf[0] = '\0'
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
rowRes[colId-1] = $buf.cstring
rowRes[colId-1] = $(addr buf)
cCnt = tempcCnt
res = SQLFetch(db.stmt)
result = rowRes
@ -415,7 +412,7 @@ proc getAllRows*(db: var DbConn, query: SqlQuery,
buf[0] = '\0'
db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR,
cast[cstring](buf.addr), 4095.TSqlSmallInt, sz.addr))
rowRes[colId-1] = $buf.cstring
rowRes[colId-1] = $(addr buf)
cCnt = tempcCnt
rows.add(rowRes)
res = SQLFetch(db.stmt)

View file

@ -424,11 +424,15 @@ proc sortIndex(a: var openArray[IndexEntry]) =
if h == 1: break
proc escapeLink(s: string): string =
## This proc is mostly copied from uri/encodeUrl except that
## these chars are also left unencoded: '#', '/'.
result = newStringOfCap(s.len + s.len shr 2)
for c in items(s):
case c
of 'a'..'z', '_', 'A'..'Z', '0'..'9', '.', '#', ',', '/':
result.add c
of 'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~': # same as that in uri/encodeUrl
add(result, c)
of '#', '/': # example.com/foo/#bar (don't escape the '/' and '#' in such links)
add(result, c)
else:
add(result, "%")
add(result, toHex(ord(c), 2))
@ -444,7 +448,7 @@ proc generateSymbolIndex(symbols: seq[IndexEntry]): string =
var j = i
while j < symbols.len and keyword == symbols[j].keyword:
let
url = symbols[j].link #.escapeLink
url = symbols[j].link.escapeLink
text = if symbols[j].linkTitle.len > 0: symbols[j].linkTitle else: url
desc = if symbols[j].linkDesc.len > 0: symbols[j].linkDesc else: ""
if desc.len > 0:

View file

@ -81,7 +81,7 @@ proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
result = doNothing
inc s.calls
when not defined(testing) and isMainModule:
when not defined(testing) and isMainModule and not defined(nimdoc):
import random
proc busyLoop() =

View file

@ -1147,7 +1147,7 @@ proc processType(typeName: NimNode, obj: NimNode,
`getEnumCall`
)
of nnkSym:
let name = ($typeName).normalize
let name = normalize($typeName.getTypeImpl())
case name
of "string":
result = quote do:
@ -1639,3 +1639,17 @@ when isMainModule:
# bug #6438
doAssert($ %*[] == "[]")
doAssert($ %*{} == "{}")
# bug #9111
block:
type
Bar = string
Foo = object
a: int
b: Bar
let
js = """{"a": 123, "b": "abc"}""".parseJson
foo = js.to Foo
doAssert(foo.b == "abc")

View file

@ -60,6 +60,7 @@ proc encodeUrl*(s: string, usePlus=true): string =
let fromSpace = if usePlus: "+" else: "%20"
for c in s:
case c
# https://tools.ietf.org/html/rfc3986#section-2.3
of 'a'..'z', 'A'..'Z', '0'..'9', '-', '.', '_', '~': add(result, c)
of ' ': add(result, fromSpace)
else: