Merge ../Nim into devel

This commit is contained in:
Charles Blake 2015-02-16 14:55:08 -05:00
commit 55840d9505
112 changed files with 313 additions and 311 deletions

View file

@ -21,7 +21,7 @@ type
## is performed. Deprecated, do not use anymore!
AquireEffect* {.deprecated.} = object of LockEffect ## \
## effect that denotes that some lock is
## aquired. Deprecated, do not use anymore!
## acquired. Deprecated, do not use anymore!
ReleaseEffect* {.deprecated.} = object of LockEffect ## \
## effect that denotes that some lock is
## released. Deprecated, do not use anymore!

View file

@ -76,7 +76,7 @@ type
TNimrodTypeKind* = enum
ntyNone, ntyBool, ntyChar, ntyEmpty,
ntyArrayConstr, ntyNil, ntyExpr, ntyStmt,
ntyTypeDesc, ntyGenericInvokation, ntyGenericBody, ntyGenericInst,
ntyTypeDesc, ntyGenericInvocation, ntyGenericBody, ntyGenericInst,
ntyGenericParam, ntyDistinct, ntyEnum, ntyOrdinal,
ntyArray, ntyObject, ntyTuple, ntySet,
ntyRange, ntyPtr, ntyRef, ntyVar,

View file

@ -1145,7 +1145,7 @@ proc formatNamedVars*(frmt: string, varnames: openArray[string],
proc defaultConfig*(): StringTableRef =
## Returns a default configuration for embedded HTML generation.
##
## The returned ``StringTableRef`` contains the paramters used by the HTML
## The returned ``StringTableRef`` contains the parameters 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.

View file

@ -606,7 +606,7 @@ when defined(windows) or defined(nimdoc):
retFuture.fail(newException(OSError, osErrorMsg(err)))
elif ret == 0 and bytesReceived == 0 and dataBuf.buf[0] == '\0':
# We have to ensure that the buffer is empty because WSARecv will tell
# us immediatelly when it was disconnected, even when there is still
# us immediately when it was disconnected, even when there is still
# data in the buffer.
# We want to give the user as much data as we can. So we only return
# the empty string (which signals a disconnection) when there is

View file

@ -18,7 +18,7 @@ import strutils
##
## Quick start example:
##
## # Create a matrix wich first rotates, then scales and at last translates
## # Create a matrix which first rotates, then scales and at last translates
##
## var m:TMatrix2d=rotate(DEG90) & scale(2.0) & move(100.0,200.0)
##
@ -256,7 +256,7 @@ proc `$`* (t:TMatrix2d):string {.noInit.} =
proc isUniform*(t:TMatrix2d,tol=1.0e-6):bool=
## Checks if the transform is uniform, that is
## perpendicular axes of equal lenght, which means (for example)
## perpendicular axes of equal length, which means (for example)
## it cannot transform a circle into an ellipse.
## `tol` is used as tolerance for both equal length comparison
## and perp. comparison.
@ -305,7 +305,7 @@ proc equals*(m1:TMatrix2d,m2:TMatrix2d,tol=1.0e-6):bool=
abs(m1.ty-m2.ty)<=tol
proc `=~`*(m1,m2:TMatrix2d):bool=
## Checks if `m1`and `m2` is aproximately equal, using a
## Checks if `m1`and `m2` is approximately equal, using a
## tolerance of 1e-6.
equals(m1,m2)

View file

@ -23,7 +23,7 @@ import times
##
## Quick start example:
##
## # Create a matrix wich first rotates, then scales and at last translates
## # Create a matrix which first rotates, then scales and at last translates
##
## var m:TMatrix3d=rotate(PI,vector3d(1,1,2.5)) & scale(2.0) & move(100.0,200.0,300.0)
##
@ -320,7 +320,7 @@ proc rotateZ*(angle:float):TMatrix3d {.noInit.}=
proc isUniform*(m:TMatrix3d,tol=1.0e-6):bool=
## Checks if the transform is uniform, that is
## perpendicular axes of equal lenght, which means (for example)
## perpendicular axes of equal length, which means (for example)
## it cannot transform a sphere into an ellipsoid.
## `tol` is used as tolerance for both equal length comparison
## and perpendicular comparison.
@ -483,7 +483,7 @@ proc equals*(m1:TMatrix3d,m2:TMatrix3d,tol=1.0e-6):bool=
abs(m1.tw-m2.tw)<=tol
proc `=~`*(m1,m2:TMatrix3d):bool=
## Checks if `m1` and `m2` is aproximately equal, using a
## Checks if `m1` and `m2` is approximately equal, using a
## tolerance of 1e-6.
equals(m1,m2)
@ -788,7 +788,7 @@ proc angleTo*(v1,v2:TVector3d):float=
proc arbitraryAxis*(norm:TVector3d):TMatrix3d {.noInit.}=
## Computes the rotation matrix that would transform
## world z vector into `norm`. The inverse of this matrix
## is useful to tranform a planar 3d object to 2d space.
## is useful to transform a planar 3d object to 2d space.
## This is the same algorithm used to interpret DXF and DWG files.
const lim=1.0/64.0
var ax,ay,az:TVector3d

View file

@ -404,7 +404,7 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int,
#echo("tomb old slot then set in new table")
nextTable = copySlotAndCheck(table,idx)
return setVal(nextTable, key, val, expVal, match)
# Finaly ready to add new val to table
# Finally ready to add new val to table
while true:
if match and oldVal != expVal:
#echo("set failed, no match oldVal= " & $oldVal & " expVal= " & $expVal)

View file

@ -174,7 +174,7 @@ proc excl*[T](c: var CritBitTree[T], key: string) =
iterator leaves[T](n: Node[T]): Node[T] =
if n != nil:
# XXX actually we could compute the necessary stack size in advance:
# it's rougly log2(c.count).
# it's roughly log2(c.count).
var stack = @[n]
while stack.len > 0:
var it = stack.pop

View file

@ -320,7 +320,7 @@ template foldl*(sequence, operation: expr): expr =
##
## The ``operation`` parameter should be an expression which uses the
## variables ``a`` and ``b`` for each step of the fold. Since this is a left
## fold, for non associative binary operations like substraction think that
## fold, for non associative binary operations like subtraction think that
## the sequence of numbers 1, 2 and 3 will be parenthesized as (((1) - 2) -
## 3). Example:
##
@ -328,12 +328,12 @@ template foldl*(sequence, operation: expr): expr =
## let
## numbers = @[5, 9, 11]
## addition = foldl(numbers, a + b)
## substraction = foldl(numbers, a - b)
## subtraction = foldl(numbers, a - b)
## multiplication = foldl(numbers, a * b)
## words = @["nim", "is", "cool"]
## concatenation = foldl(words, a & b)
## assert addition == 25, "Addition is (((5)+9)+11)"
## assert substraction == -15, "Substraction is (((5)-9)-11)"
## assert subtraction == -15, "Subtraction is (((5)-9)-11)"
## assert multiplication == 495, "Multiplication is (((5)*9)*11)"
## assert concatenation == "nimiscool"
assert sequence.len > 0, "Can't fold empty sequences"
@ -356,7 +356,7 @@ template foldr*(sequence, operation: expr): expr =
##
## The ``operation`` parameter should be an expression which uses the
## variables ``a`` and ``b`` for each step of the fold. Since this is a right
## fold, for non associative binary operations like substraction think that
## fold, for non associative binary operations like subtraction think that
## the sequence of numbers 1, 2 and 3 will be parenthesized as (1 - (2 -
## (3))). Example:
##
@ -364,12 +364,12 @@ template foldr*(sequence, operation: expr): expr =
## let
## numbers = @[5, 9, 11]
## addition = foldr(numbers, a + b)
## substraction = foldr(numbers, a - b)
## subtraction = foldr(numbers, a - b)
## multiplication = foldr(numbers, a * b)
## words = @["nim", "is", "cool"]
## concatenation = foldr(words, a & b)
## assert addition == 25, "Addition is (5+(9+(11)))"
## assert substraction == 7, "Substraction is (5-(9-(11)))"
## assert subtraction == 7, "Subtraction is (5-(9-(11)))"
## assert multiplication == 495, "Multiplication is (5*(9*(11)))"
## assert concatenation == "nimiscool"
assert sequence.len > 0, "Can't fold empty sequences"
@ -507,12 +507,12 @@ when isMainModule:
let
numbers = @[5, 9, 11]
addition = foldl(numbers, a + b)
substraction = foldl(numbers, a - b)
subtraction = foldl(numbers, a - b)
multiplication = foldl(numbers, a * b)
words = @["nim", "is", "cool"]
concatenation = foldl(words, a & b)
assert addition == 25, "Addition is (((5)+9)+11)"
assert substraction == -15, "Substraction is (((5)-9)-11)"
assert subtraction == -15, "Subtraction is (((5)-9)-11)"
assert multiplication == 495, "Multiplication is (((5)*9)*11)"
assert concatenation == "nimiscool"
@ -520,12 +520,12 @@ when isMainModule:
let
numbers = @[5, 9, 11]
addition = foldr(numbers, a + b)
substraction = foldr(numbers, a - b)
subtraction = foldr(numbers, a - b)
multiplication = foldr(numbers, a * b)
words = @["nim", "is", "cool"]
concatenation = foldr(words, a & b)
assert addition == 25, "Addition is (5+(9+(11)))"
assert substraction == 7, "Substraction is (5-(9-(11)))"
assert subtraction == 7, "Subtraction is (5-(9-(11)))"
assert multiplication == 495, "Multiplication is (5*(9*(11)))"
assert concatenation == "nimiscool"

View file

@ -11,7 +11,7 @@
## (also often named `dictionary`:idx: in other programming languages) that is
## a mapping from keys to values. ``Table`` is the usual hash table,
## ``OrderedTable`` is like ``Table`` but remembers insertion order
## and ``CountTable`` is a mapping from a key to its number of occurances.
## and ``CountTable`` is a mapping from a key to its number of occurrences.
## For consistency with every other data type in Nim these have **value**
## semantics, this means that ``=`` performs a copy of the hash table.
## For **reference** semantics use the ``Ref`` variant: ``TableRef``,

View file

@ -46,7 +46,7 @@ proc `+`*(a, b: Color): Color =
colorOp(satPlus)
proc `-`*(a, b: Color): Color =
## substracts two colors: This uses saturated artithmetic, so that each color
## subtracts two colors: This uses saturated artithmetic, so that each color
## component cannot overflow (255 is used as a maximum).
colorOp(satMinus)
@ -392,7 +392,7 @@ proc parseColor*(name: string): Color =
result = Color(parseHexInt(name))
else:
var idx = binaryStrSearch(colorNames, name)
if idx < 0: raise newException(ValueError, "unkown color: " & name)
if idx < 0: raise newException(ValueError, "unknown color: " & name)
result = colorNames[idx][1]
proc isColor*(name: string): bool =

View file

@ -301,7 +301,7 @@ proc getCurrentEncoding*(): string =
proc open*(destEncoding = "UTF-8", srcEncoding = "CP1252"): EncodingConverter =
## opens a converter that can convert from `srcEncoding` to `destEncoding`.
## Raises `EIO` if it cannot fullfill the request.
## Raises `EIO` if it cannot fulfill the request.
when not defined(windows):
result = iconvOpen(destEncoding, srcEncoding)
if result == nil:

View file

@ -9,7 +9,7 @@
## :Author: Alex Mitchell
##
## This module implements an event system that is not dependant on external
## This module implements an event system that is not dependent on external
## graphical toolkits. It was originally called ``NimEE`` because
## it was inspired by Python's PyEE module. There are two ways you can use
## events: one is a python-inspired way; the other is more of a C-style way.

View file

@ -552,7 +552,7 @@ proc parse(x: var XmlParser, errors: var seq[string]): XmlNode =
proc parseHtml*(s: Stream, filename: string,
errors: var seq[string]): XmlNode =
## parses the XML from stream `s` and returns a ``PXmlNode``. Every
## occured parsing error is added to the `errors` sequence.
## occurred parsing error is added to the `errors` sequence.
var x: XmlParser
open(x, s, filename, {reportComments, reportWhitespace})
next(x)
@ -581,7 +581,7 @@ proc parseHtml*(s: Stream): XmlNode =
proc loadHtml*(path: string, errors: var seq[string]): XmlNode =
## Loads and parses HTML from file specified by ``path``, and returns
## a ``PXmlNode``. Every occured parsing error is added to
## a ``PXmlNode``. Every occurred parsing error is added to
## the `errors` sequence.
var s = newFileStream(path, fmRead)
if s == nil: raise newException(IOError, "Unable to read file: " & path)

View file

@ -385,7 +385,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
userAgent = defUserAgent, proxy: Proxy = nil): Response =
## | Requests ``url`` with the custom method string specified by the
## | ``httpMethod`` parameter.
## | Extra headers can be specified and must be seperated by ``\c\L``
## | Extra headers can be specified and must be separated by ``\c\L``
## | An optional timeout can be specified in miliseconds, if reading from the
## server takes longer than specified an ETimeout exception will be raised.
var r = if proxy == nil: parseUri(url) else: proxy.url
@ -436,7 +436,7 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
body = "", sslContext = defaultSSLContext, timeout = -1,
userAgent = defUserAgent, proxy: Proxy = nil): Response =
## | Requests ``url`` with the specified ``httpMethod``.
## | Extra headers can be specified and must be seperated by ``\c\L``
## | Extra headers can be specified and must be separated by ``\c\L``
## | An optional timeout can be specified in miliseconds, if reading from the
## server takes longer than specified an ETimeout exception will be raised.
result = request(url, $httpMethod, extraHeaders, body, sslContext, timeout,

View file

@ -55,7 +55,7 @@ import
type
JsonEventKind* = enum ## enumeration of all events that may occur when parsing
jsonError, ## an error ocurred during parsing
jsonError, ## an error occurred during parsing
jsonEof, ## end of file reached
jsonString, ## a string literal
jsonInt, ## an integer literal

View file

@ -8,7 +8,7 @@
#
## This module implements a simple logger. It has been designed to be as simple
## as possible to avoid bloat, if this library does not fullfill your needs,
## as possible to avoid bloat, if this library does not fulfill your needs,
## write your own.
##
## Format strings support the following variables which must be prefixed with

View file

@ -258,7 +258,7 @@ proc socketError*(socket: Socket, err: int = -1, async = false,
of SSL_ERROR_WANT_X509_LOOKUP:
raiseSSLError("Function for x509 lookup has been called.")
of SSL_ERROR_SYSCALL:
var errStr = "IO error has occured "
var errStr = "IO error has occurred "
let sslErr = ErrPeekLastError()
if sslErr == 0 and err == 0:
errStr.add "because an EOF was observed that violates the protocol"
@ -887,7 +887,7 @@ proc connectAsync(socket: Socket, name: string, port = Port(0),
af: Domain = AF_INET) {.tags: [ReadIOEffect].} =
## A variant of ``connect`` for non-blocking sockets.
##
## This procedure will immediatelly return, it will not block until a connection
## This procedure will immediately return, it will not block until a connection
## is made. It is up to the caller to make sure the connection has been established
## by checking (using ``select``) whether the socket is writeable.
##

View file

@ -185,7 +185,7 @@ const
proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} =
## Retrieves the operating system's error flag, ``errno``.
## On Windows ``GetLastError`` is checked before ``errno``.
## Returns "" if no error occured.
## Returns "" if no error occurred.
##
## **Deprecated since version 0.9.4**: use the other ``osErrorMsg`` proc.
@ -1099,7 +1099,7 @@ when defined(windows):
var
env = getEnvironmentStringsW()
e = env
if e == nil: return # an error occured
if e == nil: return # an error occurred
while true:
var eend = strEnd(e)
add(environment, $e)
@ -1110,7 +1110,7 @@ when defined(windows):
var
env = getEnvironmentStringsA()
e = env
if e == nil: return # an error occured
if e == nil: return # an error occurred
while true:
var eend = strEnd(e)
add(environment, $e)
@ -1182,7 +1182,7 @@ proc putEnv*(key, val: string) {.tags: [WriteEnvEffect].} =
## If an error occurs, `EInvalidEnvVar` is raised.
# Note: by storing the string in the environment sequence,
# we gurantee that we don't free the memory before the program
# we guarantee that we don't free the memory before the program
# ends (this is needed for POSIX compliance). It is also needed so that
# the process itself may access its modified environment variables!
var indx = findEnvVar(key)
@ -1454,7 +1454,7 @@ proc createHardlink*(src, dest: string) =
proc parseCmdLine*(c: string): seq[string] {.
noSideEffect, rtl, extern: "nos$1".} =
## Splits a command line into several components;
## This proc is only occassionally useful, better use the `parseopt` module.
## This proc is only occasionally useful, better use the `parseopt` module.
##
## On Windows, it uses the following parsing rules
## (see http://msdn.microsoft.com/en-us/library/17w5ykft.aspx ):

View file

@ -146,7 +146,7 @@ proc startProcess*(command: string,
## of `args` to `command` carefully escaping/quoting any special characters,
## since it will be passed *as is* to the system shell. Each system/shell may
## feature different escaping rules, so try to avoid this kind of shell
## invokation if possible as it leads to non portable software.
## invocation if possible as it leads to non portable software.
##
## Return value: The newly created process object. Nil is never returned,
## but ``EOS`` is raised in case of an error.

View file

@ -35,7 +35,7 @@ type
cfgSectionStart, ## a ``[section]`` has been parsed
cfgKeyValuePair, ## a ``key=value`` pair has been detected
cfgOption, ## a ``--key=value`` command line option
cfgError ## an error ocurred during parsing
cfgError ## an error occurred during parsing
CfgEvent* = object of RootObj ## describes a parsing event
case kind*: CfgEventKind ## the kind of the event

View file

@ -60,7 +60,7 @@ proc initOptParser*(cmdline: string): OptParser {.rtl, deprecated.} =
## Initalizes option parses with cmdline. Splits cmdline in on spaces
## and calls initOptParser(openarray[string])
## Do not use.
if cmdline == "": # backward compatibilty
if cmdline == "": # backward compatibility
return initOptParser(seq[string](nil))
else:
return initOptParser(cmdline.split)

View file

@ -181,7 +181,7 @@ proc parseWhile*(s: string, token: var string, validChars: set[char],
token = substr(s, start, i-1)
proc captureBetween*(s: string, first: char, second = '\0', start = 0): string =
## Finds the first occurence of ``first``, then returns everything from there
## Finds the first occurrence of ``first``, then returns everything from there
## up to ``second``(if ``second`` is '\0', then ``first`` is used).
var i = skipUntil(s, first, start)+1+start
result = ""
@ -240,7 +240,7 @@ proc parseBiggestFloat*(s: string, number: var BiggestFloat, start = 0): int {.
proc parseFloat*(s: string, number: var float, start = 0): int {.
rtl, extern: "npuParseFloat", noSideEffect.} =
## parses a float starting at `start` and stores the value into `number`.
## Result is the number of processed chars or 0 if there occured a parsing
## Result is the number of processed chars or 0 if there occurred a parsing
## error.
var bf: BiggestFloat
result = parseBiggestFloat(s, bf, start)

View file

@ -57,7 +57,7 @@ import
type
XmlEventKind* = enum ## enumation of all events that may occur when parsing
xmlError, ## an error ocurred during parsing
xmlError, ## an error occurred during parsing
xmlEof, ## end of file reached
xmlCharData, ## character data
xmlWhitespace, ## whitespace has been parsed

View file

@ -43,7 +43,7 @@ proc isConc(r: Rope): bool {.inline.} = return isNil(r.data)
# Note that the left and right pointers are not needed for leafs.
# Leaves have relatively high memory overhead (~30 bytes on a 32
# bit machine) and we produce many of them. This is why we cache and
# share leafs accross different rope trees.
# share leafs across different rope trees.
# To cache them they are inserted in another tree, a splay tree for best
# performance. But for the caching tree we use the leaf's left and right
# pointers.

View file

@ -35,7 +35,7 @@ type
when defined(nimdoc):
type
Selector* = ref object
## An object which holds file descripters to be checked for read/write
## An object which holds file descriptors to be checked for read/write
## status.
fds: Table[SocketHandle, SelectorKey]

View file

@ -851,7 +851,7 @@ proc connectAsync*(socket: Socket, name: string, port = Port(0),
af: Domain = AF_INET) {.tags: [ReadIOEffect].} =
## A variant of ``connect`` for non-blocking sockets.
##
## This procedure will immediatelly return, it will not block until a connection
## This procedure will immediately return, it will not block until a connection
## is made. It is up to the caller to make sure the connection has been established
## by checking (using ``select``) whether the socket is writeable.
##
@ -1467,7 +1467,7 @@ proc recvAsync*(socket: Socket, s: var TaintedString): bool {.
of SSL_ERROR_ZERO_RETURN:
raiseSslError("TLS/SSL connection failed to initiate, socket closed prematurely.")
of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
raiseSslError("Unexpected error occured.") # This should just not happen.
raiseSslError("Unexpected error occurred.") # This should just not happen.
of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_READ:
return false
of SSL_ERROR_WANT_X509_LOOKUP:
@ -1610,7 +1610,7 @@ proc sendAsync*(socket: Socket, data: string): int {.tags: [WriteIOEffect].} =
of SSL_ERROR_ZERO_RETURN:
raiseSslError("TLS/SSL connection failed to initiate, socket closed prematurely.")
of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT:
raiseSslError("Unexpected error occured.") # This should just not happen.
raiseSslError("Unexpected error occurred.") # This should just not happen.
of SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_READ:
return 0
of SSL_ERROR_WANT_X509_LOOKUP:

View file

@ -122,41 +122,41 @@ proc read[T](s: Stream, result: var T) =
raise newEIO("cannot read from stream")
proc readChar*(s: Stream): char =
## reads a char from the stream `s`. Raises `EIO` if an error occured.
## reads a char from the stream `s`. Raises `EIO` if an error occurred.
## Returns '\0' as an EOF marker.
if readData(s, addr(result), sizeof(result)) != 1: result = '\0'
proc readBool*(s: Stream): bool =
## reads a bool from the stream `s`. Raises `EIO` if an error occured.
## reads a bool from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readInt8*(s: Stream): int8 =
## reads an int8 from the stream `s`. Raises `EIO` if an error occured.
## reads an int8 from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readInt16*(s: Stream): int16 =
## reads an int16 from the stream `s`. Raises `EIO` if an error occured.
## reads an int16 from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readInt32*(s: Stream): int32 =
## reads an int32 from the stream `s`. Raises `EIO` if an error occured.
## reads an int32 from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readInt64*(s: Stream): int64 =
## reads an int64 from the stream `s`. Raises `EIO` if an error occured.
## reads an int64 from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readFloat32*(s: Stream): float32 =
## reads a float32 from the stream `s`. Raises `EIO` if an error occured.
## reads a float32 from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readFloat64*(s: Stream): float64 =
## reads a float64 from the stream `s`. Raises `EIO` if an error occured.
## reads a float64 from the stream `s`. Raises `EIO` if an error occurred.
read(s, result)
proc readStr*(s: Stream, length: int): TaintedString =
## reads a string of length `length` from the stream `s`. Raises `EIO` if
## an error occured.
## an error occurred.
result = newString(length).TaintedString
var L = readData(s, addr(string(result)[0]), length)
if L != length: setLen(result.string, L)
@ -183,7 +183,7 @@ proc readLine*(s: Stream, line: var TaintedString): bool =
proc readLine*(s: Stream): TaintedString =
## Reads a line from a stream `s`. Note: This is not very efficient. Raises
## `EIO` if an error occured.
## `EIO` if an error occurred.
result = TaintedString""
while true:
var c = readChar(s)

View file

@ -815,8 +815,8 @@ proc rfind*(s: string, sub: char, start: int = -1): int {.noSideEffect,
proc count*(s: string, sub: string, overlapping: bool = false): int {.noSideEffect,
rtl, extern: "nsuCountString".} =
## Count the occurences of a substring `sub` in the string `s`.
## Overlapping occurences of `sub` only count when `overlapping`
## Count the occurrences of a substring `sub` in the string `s`.
## Overlapping occurrences of `sub` only count when `overlapping`
## is set to true.
var i = 0
while true:
@ -831,14 +831,14 @@ proc count*(s: string, sub: string, overlapping: bool = false): int {.noSideEffe
proc count*(s: string, sub: char): int {.noSideEffect,
rtl, extern: "nsuCountChar".} =
## Count the occurences of the character `sub` in the string `s`.
## Count the occurrences of the character `sub` in the string `s`.
for c in s:
if c == sub:
inc result
proc count*(s: string, subs: set[char]): int {.noSideEffect,
rtl, extern: "nsuCountCharSet".} =
## Count the occurences of the group of character `subs` in the string `s`.
## Count the occurrences of the group of character `subs` in the string `s`.
for c in s:
if c in subs:
inc result
@ -898,7 +898,7 @@ proc replaceWord*(s, sub: string, by = ""): string {.noSideEffect,
rtl, extern: "nsuReplaceWord".} =
## Replaces `sub` in `s` by the string `by`.
##
## Each occurance of `sub` has to be surrounded by word boundaries
## Each occurrence of `sub` has to be surrounded by word boundaries
## (comparable to ``\\w`` in regular expressions), otherwise it is not
## replaced.
const wordChars = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\128'..'\255'}

View file

@ -642,7 +642,7 @@ proc isEmpty(s: string): bool =
return true
proc normalize*(n: PNode) =
## Merges all seperated TextNodes together, and removes any empty TextNodes
## Merges all separated TextNodes together, and removes any empty TextNodes
var curTextNode: PNode = nil
var i: int = 0

View file

@ -103,7 +103,7 @@ proc parse(x: var XmlParser, errors: var seq[string]): XmlNode =
proc parseXml*(s: Stream, filename: string,
errors: var seq[string]): XmlNode =
## parses the XML from stream `s` and returns a ``PXmlNode``. Every
## occured parsing error is added to the `errors` sequence.
## occurred parsing error is added to the `errors` sequence.
var x: XmlParser
open(x, s, filename, {reportComments})
while true:
@ -129,7 +129,7 @@ proc parseXml*(s: Stream): XmlNode =
proc loadXml*(path: string, errors: var seq[string]): XmlNode =
## Loads and parses XML from file specified by ``path``, and returns
## a ``PXmlNode``. Every occured parsing error is added to the `errors`
## a ``PXmlNode``. Every occurred parsing error is added to the `errors`
## sequence.
var s = newFileStream(path, fmRead)
if s == nil: raise newException(IOError, "Unable to read file: " & path)

View file

@ -73,7 +73,7 @@ type
expr* {.magic: Expr.} ## meta type to denote an expression (for templates)
stmt* {.magic: Stmt.} ## meta type to denote a statement (for templates)
typedesc* {.magic: TypeDesc.} ## meta type to denote a type description
void* {.magic: "VoidType".} ## meta type to denote the absense of any type
void* {.magic: "VoidType".} ## meta type to denote the absence of any type
auto* = expr
any* = distinct auto
@ -357,7 +357,7 @@ type
##
## See the full `exception hierarchy`_.
IOError* = object of SystemError ## \
## Raised if an IO error occured.
## Raised if an IO error occurred.
##
## See the full `exception hierarchy`_.
OSError* = object of SystemError ## \
@ -370,11 +370,11 @@ type
##
## See the full `exception hierarchy`_.
ResourceExhaustedError* = object of SystemError ## \
## Raised if a resource request could not be fullfilled.
## Raised if a resource request could not be fulfilled.
##
## See the full `exception hierarchy`_.
ArithmeticError* = object of Exception ## \
## Raised if any kind of arithmetic error occured.
## Raised if any kind of arithmetic error occurred.
##
## See the full `exception hierarchy`_.
DivByZeroError* = object of ArithmeticError ## \
@ -578,7 +578,7 @@ proc len*(x: cstring): int {.magic: "LengthStr", noSideEffect.}
proc len*[I, T](x: array[I, T]): int {.magic: "LengthArray", noSideEffect.}
proc len*[T](x: seq[T]): int {.magic: "LengthSeq", noSideEffect.}
## returns the length of an array, an openarray, a sequence or a string.
## This is rougly the same as ``high(T)-low(T)+1``, but its resulting type is
## This is roughly the same as ``high(T)-low(T)+1``, but its resulting type is
## always an int.
# set routines:
@ -865,7 +865,7 @@ proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
## passes its arguments in reverse order.
proc contains*[T](s: Slice[T], value: T): bool {.noSideEffect, inline.} =
## Checks if `value` is withing the range of `s`; returns true iff
## Checks if `value` is within the range of `s`; returns true iff
## `value >= s.a and value <= s.b`
##
## .. code-block:: Nim

View file

@ -15,7 +15,7 @@ proc raiseOverflow {.compilerproc, noinline, noreturn.} =
sysFatal(OverflowError, "over- or underflow")
proc raiseDivByZero {.compilerproc, noinline, noreturn.} =
sysFatal(DivByZeroError, "divison by zero")
sysFatal(DivByZeroError, "division by zero")
proc addInt64(a, b: int64): int64 {.compilerProc, inline.} =
result = a +% b

View file

@ -13,7 +13,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc, benign.}
type
TLibHandle = pointer # private type
TProcAddr = pointer # libary loading and loading of procs:
TProcAddr = pointer # library loading and loading of procs:
proc nimLoadLibrary(path: string): TLibHandle {.compilerproc.}
proc nimUnloadLibrary(lib: TLibHandle) {.compilerproc.}

View file

@ -8,7 +8,7 @@
#
# This file implements the ability to call native procs from libraries.
# It is not possible to do this in a platform independant way, unfortunately.
# It is not possible to do this in a platform independent way, unfortunately.
# However, the interface has been designed to take platform differences into
# account and been ported to all major platforms.

View file

@ -884,7 +884,7 @@ elif stackIncreases:
var
jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int
# a little hack to get the size of a TJmpBuf in the generated C code
# in a platform independant way
# in a platform independent way
template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} =
var registers: C_JmpBuf

View file

@ -128,7 +128,7 @@ type
# cycle roots table that uses a cheap linear scan
# to find only possitively dead objects.
# One strategy is to perform it only for new objects
# allocated between the invocations of CollectZCT.
# allocated between the invocations of collectZCT.
# This index indicates the start of the range of
# such new objects within the table.
when withRealTime:
@ -140,7 +140,7 @@ var
gch* {.rtlThreadVar.}: TGcHeap
when not defined(useNimRtl):
InstantiateForRegion(gch.region)
instantiateForRegion(gch.region)
template acquire(gch: TGcHeap) =
when hasThreadSupport and hasSharedHeap:
@ -233,11 +233,11 @@ template addCycleRoot(cycleRoots: var TCellSeq, c: PCell) =
proc cellToUsr(cell: PCell): pointer {.inline.} =
# convert object (=pointer to refcount) to pointer to userdata
result = cast[pointer](cast[TAddress](cell)+%TAddress(sizeof(TCell)))
result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(TCell)))
proc usrToCell*(usr: pointer): PCell {.inline.} =
# convert pointer to userdata to object (=pointer to refcount)
result = cast[PCell](cast[TAddress](usr)-%TAddress(sizeof(TCell)))
result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(TCell)))
proc canbeCycleRoot(c: PCell): bool {.inline.} =
result = ntfAcyclic notin c.typ.flags
@ -255,10 +255,10 @@ when BitsPerPage mod (sizeof(int)*8) != 0:
# forward declarations:
proc collectCT(gch: var TGcHeap)
proc IsOnStack*(p: pointer): bool {.noinline.}
proc isOnStack*(p: pointer): bool {.noinline.}
proc forAllChildren(cell: PCell, op: TWalkOp)
proc doOperation(p: pointer, op: TWalkOp)
proc forAllChildrenAux(dest: Pointer, mt: PNimType, op: TWalkOp)
proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp)
# we need the prototype here for debugging purposes
proc prepareDealloc(cell: PCell) =
@ -432,7 +432,7 @@ proc nimGCunrefNoCycle(p: pointer) {.compilerProc, inline.} =
sysAssert(allocInv(gch.region), "end nimGCunrefNoCycle 2")
sysAssert(allocInv(gch.region), "end nimGCunrefNoCycle 5")
template doAsgnRef(dest: ppointer, src: pointer,
template doAsgnRef(dest: PPointer, src: pointer,
heapType = LocalHeap, cycleFlag = MaybeCyclic): stmt =
sysAssert(not isOnStack(dest), "asgnRef")
# BUGFIX: first incRef then decRef!
@ -440,20 +440,20 @@ template doAsgnRef(dest: ppointer, src: pointer,
if dest[] != nil: doDecRef(usrToCell(dest[]), heapType, cycleFlag)
dest[] = src
proc asgnRef(dest: ppointer, src: pointer) {.compilerProc, inline.} =
proc asgnRef(dest: PPointer, src: pointer) {.compilerProc, inline.} =
# the code generator calls this proc!
doAsgnRef(dest, src, LocalHeap, MaybeCyclic)
proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerProc, inline.} =
proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerProc, inline.} =
# the code generator calls this proc if it is known at compile time that no
# cycle is possible.
doAsgnRef(dest, src, LocalHeap, Acyclic)
proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerProc.} =
proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerProc.} =
# unsureAsgnRef updates the reference counters only if dest is not on the
# stack. It is used by the code generator if it cannot decide wether a
# reference is in the stack or not (this can happen for var parameters).
if not IsOnStack(dest):
if not isOnStack(dest):
if src != nil: doIncRef(usrToCell(src))
# XXX we must detect a shared heap here
# better idea may be to just eliminate the need for unsureAsgnRef
@ -470,16 +470,16 @@ proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerProc.} =
when hasThreadSupport and hasSharedHeap:
# shared heap version of the above procs
proc asgnRefSh(dest: ppointer, src: pointer) {.compilerProc, inline.} =
proc asgnRefSh(dest: PPointer, src: pointer) {.compilerProc, inline.} =
doAsgnRef(dest, src, SharedHeap, MaybeCyclic)
proc asgnRefNoCycleSh(dest: ppointer, src: pointer) {.compilerProc, inline.} =
proc asgnRefNoCycleSh(dest: PPointer, src: pointer) {.compilerProc, inline.} =
doAsgnRef(dest, src, SharedHeap, Acyclic)
proc initGC() =
when not defined(useNimRtl):
when traceGC:
for i in low(TCellState)..high(TCellState): Init(states[i])
for i in low(TCellState)..high(TCellState): init(states[i])
gch.cycleThreshold = InitialCycleThreshold
gch.stat.stackScans = 0
gch.stat.cycleCollections = 0
@ -491,11 +491,11 @@ proc initGC() =
init(gch.zct)
init(gch.tempStack)
init(gch.freeStack)
Init(gch.cycleRoots)
Init(gch.decStack)
init(gch.cycleRoots)
init(gch.decStack)
proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) =
var d = cast[TAddress](dest)
var d = cast[ByteAddress](dest)
case n.kind
of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op)
of nkList:
@ -503,7 +503,7 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) =
# inlined for speed
if n.sons[i].kind == nkSlot:
if n.sons[i].typ.kind in {tyRef, tyString, tySequence}:
doOperation(cast[ppointer](d +% n.sons[i].offset)[], op)
doOperation(cast[PPointer](d +% n.sons[i].offset)[], op)
else:
forAllChildrenAux(cast[pointer](d +% n.sons[i].offset),
n.sons[i].typ, op)
@ -514,19 +514,19 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) =
if m != nil: forAllSlotsAux(dest, m, op)
of nkNone: sysAssert(false, "forAllSlotsAux")
proc forAllChildrenAux(dest: Pointer, mt: PNimType, op: TWalkOp) =
var d = cast[TAddress](dest)
proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) =
var d = cast[ByteAddress](dest)
if dest == nil: return # nothing to do
if ntfNoRefs notin mt.flags:
case mt.Kind
case mt.kind
of tyRef, tyString, tySequence: # leaf:
doOperation(cast[ppointer](d)[], op)
doOperation(cast[PPointer](d)[], op)
of tyObject, tyTuple:
forAllSlotsAux(dest, mt.node, op)
of tyArray, tyArrayConstr, tyOpenArray:
for i in 0..(mt.size div mt.base.size)-1:
forAllChildrenAux(cast[pointer](d +% i *% mt.base.size), mt.base, op)
else: nil
else: discard
proc forAllChildren(cell: PCell, op: TWalkOp) =
sysAssert(cell != nil, "forAllChildren: 1")
@ -536,18 +536,18 @@ proc forAllChildren(cell: PCell, op: TWalkOp) =
if marker != nil:
marker(cellToUsr(cell), op.int)
else:
case cell.typ.Kind
case cell.typ.kind
of tyRef: # common case
forAllChildrenAux(cellToUsr(cell), cell.typ.base, op)
of tySequence:
var d = cast[TAddress](cellToUsr(cell))
var d = cast[ByteAddress](cellToUsr(cell))
var s = cast[PGenericSeq](d)
if s != nil:
let baseAddr = d +% GenericSeqSize
for i in 0..s.len-1:
forAllChildrenAux(cast[pointer](baseAddr +% i *% cell.typ.base.size),
cell.typ.base, op)
else: nil
else: discard
proc addNewObjToZCT(res: PCell, gch: var TGcHeap) {.inline.} =
# we check the last 8 entries (cache line) for a slot that could be reused.
@ -605,7 +605,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap, rc1: bool): pointer =
var res = cast[PCell](rawAlloc(gch.region, size + sizeof(TCell)))
sysAssert(allocInv(gch.region), "rawNewObj after rawAlloc")
sysAssert((cast[TAddress](res) and (MemAlign-1)) == 0, "newObj: 2")
sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2")
res.typ = typ
@ -708,10 +708,10 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer =
# call user-defined move code
# call user-defined default constructor
copyMem(res, ol, oldsize + sizeof(TCell))
zeroMem(cast[pointer](cast[TAddress](res)+% oldsize +% sizeof(TCell)),
zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(TCell)),
newsize-oldsize)
sysAssert((cast[TAddress](res) and (MemAlign-1)) == 0, "growObj: 3")
sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "growObj: 3")
sysAssert(res.refcount shr rcShift <=% 1, "growObj: 4")
when false:
@ -786,10 +786,10 @@ type
FromChildren,
FromRoot
proc CollectZCT(gch: var TGcHeap): bool
proc collectZCT(gch: var TGcHeap): bool
template pseudoRecursion(typ: TRecursionType, body: stmt): stmt =
#
discard
proc trimCycleRoots(gch: var TGcHeap, startIdx = gch.cycleRootsTrimIdx) =
var i = startIdx
@ -967,17 +967,17 @@ proc collectCycles(gch: var TGcHeap) =
maybedeads,
collected
Deinit(gch.cycleRoots)
Init(gch.cycleRoots)
deinit(gch.cycleRoots)
init(gch.cycleRoots)
Deinit(gch.freeStack)
Init(gch.freeStack)
deinit(gch.freeStack)
init(gch.freeStack)
when MarkingSkipsAcyclicObjects:
# Collect the acyclic objects that became unreachable due to collected
# cyclic objects.
discard CollectZCT(gch)
# CollectZCT may add new cycle candidates and we may decide to loop here
discard collectZCT(gch)
# collectZCT may add new cycle candidates and we may decide to loop here
# if gch.cycleRoots.len > 0: repeat
var gcDebugging* = false
@ -988,7 +988,7 @@ proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} =
# the addresses are not as cells on the stack, so turn them to cells:
sysAssert(allocInv(gch.region), "gcMark begin")
var cell = usrToCell(p)
var c = cast[TAddress](cell)
var c = cast[ByteAddress](cell)
if c >% PageSize:
# fast check: does it look like a cell?
var objStart = cast[PCell](interiorAllocatedPtr(gch.region, cell))
@ -997,6 +997,7 @@ proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} =
if objStart.color != rcReallyDead:
if gcDebugging:
# writeCell("marking ", objStart)
discard
else:
inc objStart.refcount, rcIncrement
gch.decStack.add objStart
@ -1009,6 +1010,7 @@ proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} =
# coincidence due to the conservative stack marking.
when debugGC:
# writeCell("marking dead object", objStart)
discard
when false:
if isAllocatedPtr(gch.region, cell):
sysAssert false, "allocated pointer but not interior?"
@ -1024,12 +1026,12 @@ proc markThreadStacks(gch: var TGcHeap) =
while it != nil:
# mark registers:
for i in 0 .. high(it.registers): gcMark(gch, it.registers[i])
var sp = cast[TAddress](it.stackBottom)
var max = cast[TAddress](it.stackTop)
var sp = cast[ByteAddress](it.stackBottom)
var max = cast[ByteAddress](it.stackTop)
# XXX stack direction?
# XXX unroll this loop:
while sp <=% max:
gcMark(gch, cast[ppointer](sp)[])
gcMark(gch, cast[PPointer](sp)[])
sp = sp +% sizeof(pointer)
it = it.next
@ -1051,8 +1053,8 @@ when not defined(useNimRtl):
# the first init must be the one that defines the stack bottom:
if gch.stackBottom == nil: gch.stackBottom = theStackBottom
else:
var a = cast[TAddress](theStackBottom) # and not PageMask - PageSize*2
var b = cast[TAddress](gch.stackBottom)
var a = cast[ByteAddress](theStackBottom) # and not PageMask - PageSize*2
var b = cast[ByteAddress](gch.stackBottom)
#c_fprintf(c_stdout, "old: %p new: %p;\n",gch.stackBottom,theStackBottom)
when stackIncreases:
gch.stackBottom = cast[pointer](min(a, b))
@ -1067,15 +1069,15 @@ proc stackSize(): int {.noinline.} =
var
jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int
# a little hack to get the size of a TJmpBuf in the generated C code
# in a platform independant way
# in a platform independent way
when defined(sparc): # For SPARC architecture.
proc isOnStack(p: pointer): bool =
var stackTop {.volatile.}: pointer
stackTop = addr(stackTop)
var b = cast[TAddress](gch.stackBottom)
var a = cast[TAddress](stackTop)
var x = cast[TAddress](p)
var b = cast[ByteAddress](gch.stackBottom)
var a = cast[ByteAddress](stackTop)
var x = cast[ByteAddress](p)
result = a <=% x and x <=% b
proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
@ -1092,7 +1094,7 @@ when defined(sparc): # For SPARC architecture.
# Addresses decrease as the stack grows.
while sp <= max:
gcMark(gch, sp[])
sp = cast[ppointer](cast[TAddress](sp) +% sizeof(pointer))
sp = cast[PPointer](cast[ByteAddress](sp) +% sizeof(pointer))
elif defined(ELATE):
{.error: "stack marking code is to be written for this architecture".}
@ -1104,20 +1106,20 @@ elif stackIncreases:
proc isOnStack(p: pointer): bool =
var stackTop {.volatile.}: pointer
stackTop = addr(stackTop)
var a = cast[TAddress](gch.stackBottom)
var b = cast[TAddress](stackTop)
var x = cast[TAddress](p)
var a = cast[ByteAddress](gch.stackBottom)
var b = cast[ByteAddress](stackTop)
var x = cast[ByteAddress](p)
result = a <=% x and x <=% b
proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
var registers: C_JmpBuf
if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
var max = cast[TAddress](gch.stackBottom)
var sp = cast[TAddress](addr(registers)) +% jmpbufSize -% sizeof(pointer)
var max = cast[ByteAddress](gch.stackBottom)
var sp = cast[ByteAddress](addr(registers)) +% jmpbufSize -% sizeof(pointer)
# sp will traverse the JMP_BUF as well (jmp_buf size is added,
# otherwise sp would be below the registers structure).
while sp >=% max:
gcMark(gch, cast[ppointer](sp)[])
gcMark(gch, cast[PPointer](sp)[])
sp = sp -% sizeof(pointer)
else:
@ -1127,9 +1129,9 @@ else:
proc isOnStack(p: pointer): bool =
var stackTop {.volatile.}: pointer
stackTop = addr(stackTop)
var b = cast[TAddress](gch.stackBottom)
var a = cast[TAddress](stackTop)
var x = cast[TAddress](p)
var b = cast[ByteAddress](gch.stackBottom)
var a = cast[ByteAddress](stackTop)
var x = cast[ByteAddress](p)
result = a <=% x and x <=% b
proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
@ -1141,18 +1143,18 @@ else:
if c_setjmp(registers) == 0'i32: # To fill the C stack with registers.
when MinimumStackMarking:
# mark the registers
var jmpbufPtr = cast[TAddress](addr(registers))
var jmpbufPtr = cast[ByteAddress](addr(registers))
var jmpbufEnd = jmpbufPtr +% jmpbufSize
while jmpbufPtr <=% jmpbufEnd:
gcMark(gch, cast[ppointer](jmpbufPtr)[])
gcMark(gch, cast[PPointer](jmpbufPtr)[])
jmpbufPtr = jmpbufPtr +% sizeof(pointer)
var sp = cast[TAddress](gch.stackTop)
var sp = cast[ByteAddress](gch.stackTop)
else:
var sp = cast[TAddress](addr(registers))
var sp = cast[ByteAddress](addr(registers))
# mark the user stack
var max = cast[TAddress](gch.stackBottom)
var max = cast[ByteAddress](gch.stackBottom)
# loop unrolled:
while sp <% max - 8*sizeof(pointer):
gcMark(gch, cast[PStackSlice](sp)[0])
@ -1166,7 +1168,7 @@ else:
sp = sp +% sizeof(pointer)*8
# last few entries:
while sp <=% max:
gcMark(gch, cast[ppointer](sp)[])
gcMark(gch, cast[PPointer](sp)[])
sp = sp +% sizeof(pointer)
# ----------------------------------------------------------------------------
@ -1202,7 +1204,7 @@ proc releaseCell(gch: var TGcHeap, cell: PCell) =
# recursion).
# We can ignore it now as the ZCT cleaner will reach it soon.
proc CollectZCT(gch: var TGcHeap): bool =
proc collectZCT(gch: var TGcHeap): bool =
const workPackage = 100
var L = addr(gch.zct.len)
@ -1213,8 +1215,8 @@ proc CollectZCT(gch: var TGcHeap): bool =
while L[] > 0:
var c = gch.zct.d[0]
sysAssert c.isBitUp(rcZct), "CollectZCT: rcZct missing!"
sysAssert(isAllocatedPtr(gch.region, c), "CollectZCT: isAllocatedPtr")
sysAssert c.isBitUp(rcZct), "collectZCT: rcZct missing!"
sysAssert(isAllocatedPtr(gch.region, c), "collectZCT: isAllocatedPtr")
# remove from ZCT:
c.clearBit(rcZct)
@ -1263,7 +1265,7 @@ proc unmarkStackAndRegisters(gch: var TGcHeap) =
# XXX no need for an atomic dec here:
if c.refcount--(LocalHeap):
# the object survived only because of a stack reference
# it still doesn't have heap refernces
# it still doesn't have heap references
addZCT(gch.zct, c)
if canbeCycleRoot(c):
@ -1295,7 +1297,7 @@ proc collectCTBody(gch: var TGcHeap) =
sysAssert gch.zct.len == 0, "zct is not null after collect cycles"
inc(gch.stat.cycleCollections)
gch.cycleThreshold = max(InitialCycleThreshold, getOccupiedMem() *
cycleIncrease)
CycleIncrease)
gch.stat.maxThreshold = max(gch.stat.maxThreshold, gch.cycleThreshold)
unmarkStackAndRegisters(gch)
sysAssert(allocInv(gch.region), "collectCT: end")
@ -1346,10 +1348,10 @@ when not defined(useNimRtl):
proc GC_setStrategy(strategy: GC_Strategy) =
case strategy
of gcThroughput: nil
of gcResponsiveness: nil
of gcOptimizeSpace: nil
of gcOptimizeTime: nil
of gcThroughput: discard
of gcResponsiveness: discard
of gcOptimizeSpace: discard
of gcOptimizeTime: discard
proc GC_enableMarkAndSweep() =
gch.cycleThreshold = InitialCycleThreshold

View file

@ -476,7 +476,7 @@ elif stackIncreases:
var
jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int
# a little hack to get the size of a TJmpBuf in the generated C code
# in a platform independant way
# in a platform independent way
proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} =
var registers: C_JmpBuf

View file

@ -26,7 +26,7 @@ type
tyExpr,
tyStmt,
tyTypeDesc,
tyGenericInvokation, # ``T[a, b]`` for types to invoke
tyGenericInvocation, # ``T[a, b]`` for types to invoke
tyGenericBody, # ``T[a, b, body]`` last parameter is the body
tyGenericInst, # ``T[a, b, realInstance]`` instantiated generic type
tyGenericParam, # ``a`` in the example

View file

@ -128,7 +128,7 @@ proc raiseOverflow {.exportc: "raiseOverflow", noreturn.} =
raise newException(OverflowError, "over- or underflow")
proc raiseDivByZero {.exportc: "raiseDivByZero", noreturn.} =
raise newException(DivByZeroError, "divison by zero")
raise newException(DivByZeroError, "division by zero")
proc raiseRangeError() {.compilerproc, noreturn.} =
raise newException(RangeError, "value out of range")

View file

@ -132,7 +132,7 @@ proc rawFileSize(file: File): int =
discard fseek(file, clong(oldPos), 0)
proc readAllFile(file: File, len: int): string =
# We aquire the filesize beforehand and hope it doesn't change.
# We acquire the filesize beforehand and hope it doesn't change.
# Speeds things up.
result = newString(int(len))
if readBuffer(file, addr(result[0]), int(len)) != len:

View file

@ -208,7 +208,7 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
when compileOption("gc", "v2"):
for i in newLen..result.len-1:
let len0 = gch.tempStack.len
forAllChildrenAux(cast[pointer](cast[TAddress](result) +%
forAllChildrenAux(cast[pointer](cast[ByteAddress](result) +%
GenericSeqSize +% (i*%elemSize)),
extGetCellType(result).base, waPush)
let len1 = gch.tempStack.len
@ -222,9 +222,9 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {.
extGetCellType(result).base, waZctDecRef)
# XXX: zeroing out the memory can still result in crashes if a wiped-out
# cell is aliased by another pointer (ie proc paramter or a let variable).
# cell is aliased by another pointer (ie proc parameter or a let variable).
# This is a tought problem, because even if we don't zeroMem here, in the
# presense of user defined destructors, the user will expect the cell to be
# presence of user defined destructors, the user will expect the cell to be
# "destroyed" thus creating the same problem. We can destoy the cell in the
# finalizer of the sequence, but this makes destruction non-deterministic.
zeroMem(cast[pointer](cast[ByteAddress](result) +% GenericSeqSize +%

View file

@ -90,7 +90,7 @@ noclean:
// If the return value pointer is NULL, assume no return value.
/*
Intel asm is weird. We have to explicitely specify 'DWORD PTR' in the nexr instruction,
Intel asm is weird. We have to explicitly specify 'DWORD PTR' in the nexr instruction,
otherwise only one BYTE will be compared (instead of a DWORD)!
*/
cmp DWORD PTR [ebp + 24], 0

View file

@ -63,9 +63,9 @@ type
const
SCRAMBLE_LENGTH* = 20 # Length of random string sent by server on handshake;
# this is also length of obfuscated password,
# recieved from client
# received from client
SCRAMBLE_LENGTH_323* = 8 # length of password stored in the db:
# new passwords are preceeded with '*'
# new passwords are preceded with '*'
SCRAMBLED_PASSWORD_CHAR_LENGTH* = SCRAMBLE_LENGTH * 2 + 1
SCRAMBLED_PASSWORD_CHAR_LENGTH_323* = SCRAMBLE_LENGTH_323 * 2
NOT_NULL_FLAG* = 1 # Field can't be NULL
@ -146,7 +146,7 @@ const
MAX_MEDIUMINT_WIDTH* = 8 # Max width for a INT24 w.o. sign
MAX_INT_WIDTH* = 10 # Max width for a LONG w.o. sign
MAX_BIGINT_WIDTH* = 20 # Max width for a LONGLONG
MAX_CHAR_WIDTH* = 255 # Max length for a CHAR colum
MAX_CHAR_WIDTH* = 255 # Max length for a CHAR column
MAX_BLOB_WIDTH* = 8192 # Default width for blob
type
@ -558,7 +558,7 @@ type
Tstatus* = enum
STATUS_READY, STATUS_GET_RESULT, STATUS_USE_RESULT
Tprotocol_type* = enum # There are three types of queries - the ones that have to go to
# the master, the ones that go to a slave, and the adminstrative
# the master, the ones that go to a slave, and the administrative
# type which must happen on the pivot connectioin
PROTOCOL_DEFAULT, PROTOCOL_TCP, PROTOCOL_SOCKET, PROTOCOL_PIPE,
PROTOCOL_MEMORY
@ -790,7 +790,7 @@ proc server_init*(argc: cint, argv: cstringArray, groups: cstringArray): cint{.
proc server_end*(){.cdecl, dynlib: lib, importc: "mysql_server_end".}
# mysql_server_init/end need to be called when using libmysqld or
# libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
# you don't need to call it explicitely; but you need to call
# you don't need to call it explicitly; but you need to call
# mysql_server_end() to free memory). The names are a bit misleading
# (mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
# names which suit well whether you're using libmysqld or libmysqlclient. We

View file

@ -231,7 +231,7 @@ proc history_truncate_file*(a2: cstring, a3: cint): cint{.cdecl,
# -1) If there was an error in expansion.
# 2) If the returned line should just be printed.
#
# If an error ocurred in expansion, then OUTPUT contains a descriptive
# If an error occurred in expansion, then OUTPUT contains a descriptive
# error message.
proc history_expand*(a2: cstring, a3: cstringArray): cint{.cdecl,

View file

@ -217,7 +217,7 @@ extern int history_truncate_file PARAMS((const char *, int));
-1) If there was an error in expansion.
2) If the returned line should just be printed.
If an error ocurred in expansion, then OUTPUT contains a descriptive
If an error occurred in expansion, then OUTPUT contains a descriptive
error message. */
extern int history_expand PARAMS((char *, char **));

View file

@ -89,7 +89,7 @@
# As most games will need it.
#
# April 02 2001 - DL : Added SDL_getenv.h definitions and tested version
# 1.2.0 compatability.
# 1.2.0 compatibility.
#
# March 13 2001 - MT : Added Linux compatibility.
#
@ -118,7 +118,7 @@
#
# November 30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton.
#
# December 11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in
# December 11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate usage in
# Components
#
# January 05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias
@ -209,7 +209,7 @@
# forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
#
# Revision 1.14 2004/12/23 23:42:18 savage
# Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
# Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatibility.
#
# Revision 1.13 2004/09/30 22:31:59 savage
# Updated with slightly different header comments
@ -221,7 +221,7 @@
# Updated so that Library name defines are correctly defined for MacOS X.
#
# Revision 1.10 2004/07/20 23:57:33 savage
# Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures.
# Thanks to Paul Toth for spotting an error in the SDL Audio Conversion structures.
# In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
#
# Revision 1.9 2004/07/03 22:07:22 savage
@ -243,7 +243,7 @@
# SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
#
# Revision 1.3 2004/02/18 22:35:51 savage
# Brought sdl.pas up to 1.2.7 compatability
# Brought sdl.pas up to 1.2.7 compatibility
# Thus...
# Added SDL_GL_STEREO,
# SDL_GL_MULTISAMPLEBUFFERS,

View file

@ -136,7 +136,7 @@
# Windows unit not used in this file, so it was removed to keep the code tidy.
#
# Revision 1.3 2004/03/31 10:05:08 savage
# Better defines for Endianess under FreePascal and Borland compilers.
# Better defines for Endianness under FreePascal and Borland compilers.
#
# Revision 1.2 2004/03/30 20:23:28 savage
# Tidied up use of UNIX compiler directive.