diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-10-01 14:15:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 14:15:35 +0200 |
commit | e867c8e5c3cf5c08c703e76434fc7db962f755f7 (patch) | |
tree | 077eea3f3e0986363d8296b1b74cefcceb7310e5 /lib | |
parent | aa8249d177cbac4a3c08348ea6dbe12d6526928d (diff) | |
parent | 5298c509a7b0168f0edce9b28442feca914d15f7 (diff) | |
download | Nim-e867c8e5c3cf5c08c703e76434fc7db962f755f7.tar.gz |
Merge branch 'devel' into fix_issues_9126
Diffstat (limited to 'lib')
-rw-r--r-- | lib/impure/db_odbc.nim | 15 | ||||
-rw-r--r-- | lib/packages/docutils/rstgen.nim | 10 | ||||
-rw-r--r-- | lib/pure/concurrency/cpuload.nim | 2 | ||||
-rw-r--r-- | lib/pure/json.nim | 16 | ||||
-rw-r--r-- | lib/pure/uri.nim | 1 |
5 files changed, 30 insertions, 14 deletions
diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index d6343acc7..224bcbb50 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -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) diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 51bb9c757..232da5c93 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -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: diff --git a/lib/pure/concurrency/cpuload.nim b/lib/pure/concurrency/cpuload.nim index 1ec739485..78a95681d 100644 --- a/lib/pure/concurrency/cpuload.nim +++ b/lib/pure/concurrency/cpuload.nim @@ -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() = diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 9279fea77..81d5702c9 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -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") diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim index dd8040928..d296017dd 100644 --- a/lib/pure/uri.nim +++ b/lib/pure/uri.nim @@ -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: |