diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/posix/posix.nim | 6 | ||||
-rw-r--r-- | lib/pure/coro.nim | 2 | ||||
-rw-r--r-- | lib/pure/coro.nimcfg | 1 | ||||
-rw-r--r-- | lib/pure/math.nim | 2 | ||||
-rw-r--r-- | lib/pure/nativesockets.nim | 1 | ||||
-rw-r--r-- | lib/pure/ospaths.nim | 4 | ||||
-rw-r--r-- | lib/pure/subexes.nim | 19 |
7 files changed, 19 insertions, 16 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 8486fa04f..5f1dfcfcd 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -1810,7 +1810,7 @@ proc ntohs*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".} proc inet_addr*(a1: cstring): InAddrT {.importc, header: "<arpa/inet.h>".} proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "<arpa/inet.h>".} proc inet_ntop*(a1: cint, a2: pointer, a3: cstring, a4: int32): cstring {. - importc, header: "<arpa/inet.h>".} + importc:"(char *)$1", header: "<arpa/inet.h>".} proc inet_pton*(a1: cint, a2: cstring, a3: pointer): cint {. importc, header: "<arpa/inet.h>".} @@ -2381,7 +2381,7 @@ proc sched_setscheduler*(a1: Pid, a2: cint, a3: var Sched_param): cint {. proc sched_yield*(): cint {.importc, header: "<sched.h>".} proc strerror*(errnum: cint): cstring {.importc, header: "<string.h>".} -proc hstrerror*(herrnum: cint): cstring {.importc, header: "<netdb.h>".} +proc hstrerror*(herrnum: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>".} proc FD_CLR*(a1: cint, a2: var TFdSet) {.importc, header: "<sys/select.h>".} proc FD_ISSET*(a1: cint | SocketHandle, a2: var TFdSet): cint {. @@ -2565,7 +2565,7 @@ proc endprotoent*() {.importc, header: "<netdb.h>".} proc endservent*() {.importc, header: "<netdb.h>".} proc freeaddrinfo*(a1: ptr AddrInfo) {.importc, header: "<netdb.h>".} -proc gai_strerror*(a1: cint): cstring {.importc, header: "<netdb.h>".} +proc gai_strerror*(a1: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>".} proc getaddrinfo*(a1, a2: cstring, a3: ptr AddrInfo, a4: var ptr AddrInfo): cint {.importc, header: "<netdb.h>".} diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim index 8fa529474..c5724f26f 100644 --- a/lib/pure/coro.nim +++ b/lib/pure/coro.nim @@ -119,7 +119,7 @@ proc wait*(c: proc(), interval=0.01) = while alive(c): suspend interval -when isMainModule: +when defined(nimCoroutines) and isMainModule: var stackCheckValue = 1100220033 proc c2() diff --git a/lib/pure/coro.nimcfg b/lib/pure/coro.nimcfg new file mode 100644 index 000000000..b011bc585 --- /dev/null +++ b/lib/pure/coro.nimcfg @@ -0,0 +1 @@ +-d:nimCoroutines diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 06a018d9f..391a880ae 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -475,7 +475,7 @@ when isMainModule and not defined(JS): return sqrt(num) # check gamma function - assert(tgamma(5.0) == 24.0) # 4! + assert($tgamma(5.0) == $24.0) # 4! assert(lgamma(1.0) == 0.0) # ln(1.0) == 0.0 assert(erf(6.0) > erf(5.0)) assert(erfc(6.0) < erfc(5.0)) diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index b5661c4d3..c9e067a3e 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -349,7 +349,6 @@ proc getAddrString*(sockAddr: ptr SockAddr): string = elif sockAddr.sa_family == nativeAfInet6: when not useWinVersion: # TODO: Windows - var v6addr = cast[ptr Sockaddr_in6](sockAddr).sin6_addr result = newString(posix.INET6_ADDRSTRLEN) let addr6 = addr cast[ptr Sockaddr_in6](sockAddr).sin6_addr discard posix.inet_ntop(posix.AF_INET6, addr6, result.cstring, diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim index dcc710193..667ca82d7 100644 --- a/lib/pure/ospaths.nim +++ b/lib/pure/ospaths.nim @@ -10,6 +10,10 @@ # Included by the ``os`` module but a module in its own right for NimScript # support. +when isMainModule: + {.pragma: rtl.} + import strutils + when defined(nimscript) or (defined(nimdoc) and not declared(os)): {.pragma: rtl.} {.push hint[ConvFromXtoItselfNotNeeded]:off.} diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index 2d1adc0eb..5824ace81 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -351,6 +351,7 @@ proc format*(formatstr: Subex, a: varargs[string, `$`]): string {.noSideEffect, {.pop.} when isMainModule: + from strutils import replace proc `%`(formatstr: string, a: openarray[string]): string = result = newStringOfCap(formatstr.len + a.len shl 4) @@ -382,18 +383,18 @@ when isMainModule: doAssert "${$1}" % "1" == "1" doAssert "${$$-1} $$1" % "1" == "1 $1" - doAssert "$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"] == + doAssert(("$#($', '10c'\n '{#..})" % ["doAssert", "longishA", "longish"]).replace(" \n", "\n") == """doAssert( longishA, - longish)""" + longish)""") - assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", - "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] == + doAssert(("type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", + "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"]).replace(" \n", "\n") == strutils.unindent """ type MyEnum* = enum fieldA, fieldB, FiledClkad, fieldD, - fieldE, longishFieldName""" + fieldE, longishFieldName""") doAssert subex"$1($', '{2..})" % ["f", "a", "b", "c"] == "f(a, b, c)" @@ -401,12 +402,10 @@ when isMainModule: doAssert subex"$['''|'|''''|']']#" % "0" == "'|" - assert subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ - "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"] == + doAssert((subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ + "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"]).replace(" \n", "\n") == strutils.unindent """ type Enum = enum fieldNameA, fieldNameB, fieldNameC, - fieldNameD""" - - + fieldNameD""") |