bugfix: new GCC version requires -ldl to come after object files
This commit is contained in:
parent
64e74cf484
commit
d819350145
5 changed files with 51 additions and 43 deletions
|
|
@ -106,19 +106,29 @@ proc skipWhitespace*(s: string, start = 0): int {.inline.} =
|
|||
while s[start+result] in Whitespace: inc(result)
|
||||
|
||||
proc skip*(s, token: string, start = 0): int {.inline.} =
|
||||
## skips the `token` starting at ``s[start]``. Returns the length of `token`
|
||||
## or 0 if there was no `token` at ``s[start]``.
|
||||
while result < token.len and s[result+start] == token[result]: inc(result)
|
||||
if result != token.len: result = 0
|
||||
|
||||
proc skipIgnoreCase*(s, token: string, start = 0): int =
|
||||
## same as `skip` but case is ignored for token matching.
|
||||
while result < token.len and
|
||||
toLower(s[result+start]) == toLower(token[result]): inc(result)
|
||||
if result != token.len: result = 0
|
||||
|
||||
proc skipUntil*(s: string, until: set[char], start = 0): int {.inline.} =
|
||||
## Skips all characters until one char from the set `token` is found.
|
||||
## Skips all characters until one char from the set `until` is found
|
||||
## or the end is reached.
|
||||
## Returns number of characters skipped.
|
||||
while s[result+start] notin until and s[result+start] != '\0': inc(result)
|
||||
|
||||
proc skipUntil*(s: string, until: char, start = 0): int {.inline.} =
|
||||
## Skips all characters until the char `until` is found
|
||||
## or the end is reached.
|
||||
## Returns number of characters skipped.
|
||||
while s[result+start] != until and s[result+start] != '\0': inc(result)
|
||||
|
||||
proc skipWhile*(s: string, toSkip: set[char], start = 0): int {.inline.} =
|
||||
## Skips all characters while one char from the set `token` is found.
|
||||
## Returns number of characters skipped.
|
||||
|
|
@ -130,7 +140,17 @@ proc parseUntil*(s: string, token: var string, until: set[char],
|
|||
## the number of the parsed characters or 0 in case of an error. A token
|
||||
## consists of the characters notin `until`.
|
||||
var i = start
|
||||
while s[i] notin until: inc(i)
|
||||
while i < s.len and s[i] notin until: inc(i)
|
||||
result = i-start
|
||||
token = substr(s, start, i-1)
|
||||
|
||||
proc parseUntil*(s: string, token: var string, until: char,
|
||||
start = 0): int {.inline.} =
|
||||
## parses a token and stores it in ``token``. Returns
|
||||
## the number of the parsed characters or 0 in case of an error. A token
|
||||
## consists of any character that is not the `until` character.
|
||||
var i = start
|
||||
while i < s.len and s[i] != until: inc(i)
|
||||
result = i-start
|
||||
token = substr(s, start, i-1)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
# This module implements the RFC 4122 specification for generating universally unique identifiers
|
||||
# http://en.wikipedia.org/wiki/Universally_unique_identifier
|
||||
|
||||
# This module is a work-in-progress
|
||||
# If you want to help with the implementation, take a loot at:
|
||||
# http://dsource.org/projects/tango/docs/current/tango.util.uuid.Uuid.html
|
||||
|
||||
type TUuid* = array[0..15, char]
|
||||
|
||||
when defined(windows):
|
||||
# This is actually available only on Windows 2000+
|
||||
type PUuid* {.importc: "UUID __RPC_FAR *", header: "<Rpc.h>".} = ptr TUuid
|
||||
proc uuid1Sys*(uuid: PUuid) {.importc: "UuidCreateSequential", header: "<Rpc.h>".}
|
||||
|
||||
else:
|
||||
type PUuid {.importc: "uuid_t", header: "<uuid/uuid.h>".} = ptr TUuid
|
||||
proc uuid1Sys*(uuid: PUuid) {.importc: "uuid_generate_time", header: "<uuid/uuid.h>".}
|
||||
|
||||
# v1 UUIDs include the MAC address of the machine generating the ID and a timestamp
|
||||
# This scheme has the strongest guaranty of uniqueness, but discloses when the ID was generated
|
||||
proc uuidMacTime* : TUuid = uuid1Sys(addr(result))
|
||||
|
||||
# v4 UUID are created entirely using a random number generator.
|
||||
# Some bits have fixed value in order to indicate the UUID type
|
||||
proc uuidRandom*[RandomGenerator](rand: RandomGenerator) : TUuid = nil
|
||||
|
||||
# v3 and v5 UUIDs are derived from given namespace and name using a secure hashing algorithm.
|
||||
# v3 uses MD5, v5 uses SHA1.
|
||||
proc uuidByName*[Hash](namespace: TUuid, name: string, hasher: Hash, v: int) : TUuid = nil
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue