From 57396065ce1a3990a91100e528cfcb99bdac9b4c Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 1 Nov 2017 19:53:09 +0100 Subject: [PATCH 1/4] Fix for latest Nim --- src/uuids.nim | 5 +++-- uuids.nimble | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/uuids.nim b/src/uuids.nim index 4a1f034..3127c31 100644 --- a/src/uuids.nim +++ b/src/uuids.nim @@ -10,10 +10,11 @@ type template toHex(s: string, start: Natural, x: BiggestInt, len: Positive) = - const HexChars = "0123456789abcdef" + const HexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', 'a', 'b', 'c', 'd', 'e', 'f'] var n = x for j in countdown(len - 1, 0): - s[start + j] = HexChars[n and 0xF] + s[start + j] = HexChars[int(n and 0xF)] n = n shr 4 # handle negative overflow if n == 0 and x < 0: n = -1 diff --git a/uuids.nimble b/uuids.nimble index 7a5c79a..a670f52 100644 --- a/uuids.nimble +++ b/uuids.nimble @@ -1,6 +1,6 @@ [Package] name: "uuids" -version: "0.1.7" +version: "0.1.8" author: "Xored Software, Inc." description: "UUID library" license: "MIT" From 2ff415fb2b020f01149f3292bdb0c7e7e0e068d0 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 22 Nov 2017 16:53:53 +0700 Subject: [PATCH 2/4] Update isaac dependency --- uuids.nimble | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uuids.nimble b/uuids.nimble index a670f52..3fcc1fd 100644 --- a/uuids.nimble +++ b/uuids.nimble @@ -1,10 +1,10 @@ [Package] name: "uuids" -version: "0.1.8" +version: "0.1.9" author: "Xored Software, Inc." description: "UUID library" license: "MIT" srcDir: "src" [Deps] -requires: "isaac >= 0.1.2" +requires: "isaac >= 0.1.3" From c5039c1cc6a8a93fc2f3c03a206372eb4412e63b Mon Sep 17 00:00:00 2001 From: Giovanni Date: Wed, 5 Sep 2018 15:22:45 +0900 Subject: [PATCH 3/4] fixed nimble check and compatibility with new nim compiler (strings can't be nil) --- .gitignore | 2 -- src/uuids.nim => uuids.nim | 4 ++-- uuids.nimble | 3 +-- {src => uuids}/urandom.nim | 0 4 files changed, 3 insertions(+), 6 deletions(-) rename src/uuids.nim => uuids.nim (99%) rename {src => uuids}/urandom.nim (100%) diff --git a/.gitignore b/.gitignore index 4532471..528610a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -**/uuids - .vscode/.browse.* nimsuggest.log diff --git a/src/uuids.nim b/uuids.nim similarity index 99% rename from src/uuids.nim rename to uuids.nim index 3127c31..b44ede2 100644 --- a/src/uuids.nim +++ b/uuids.nim @@ -1,6 +1,6 @@ import strutils, hashes import isaac -import urandom +import uuids/urandom type UUID* = object @@ -20,7 +20,7 @@ template toHex(s: string, start: Natural, if n == 0 and x < 0: n = -1 proc uuidsParseHexInt(s: string, maxLen: int): int64 = - if s.isNil or s.len == 0: + if s.len == 0: raise newException(ValueError, "UUID part is empty") if s.len > maxLen or s.len > sizeof(result) * 2: raise newException(ValueError, "UUID part is longer than expected") diff --git a/uuids.nimble b/uuids.nimble index 3fcc1fd..98eaf59 100644 --- a/uuids.nimble +++ b/uuids.nimble @@ -1,10 +1,9 @@ [Package] name: "uuids" -version: "0.1.9" +version: "0.1.10" author: "Xored Software, Inc." description: "UUID library" license: "MIT" -srcDir: "src" [Deps] requires: "isaac >= 0.1.3" diff --git a/src/urandom.nim b/uuids/urandom.nim similarity index 100% rename from src/urandom.nim rename to uuids/urandom.nim From 8cb8720b567c6bcb261bd1c0f7491bdb5209ad06 Mon Sep 17 00:00:00 2001 From: ee7 <45465154+ee7@users.noreply.github.com> Date: Fri, 15 Jan 2021 07:30:01 +0100 Subject: [PATCH 4/4] Fix error with styleCheck Before this commit, running `nim c --styleCheck:error` on a file that imports the `uuids` package would produce an error on Windows. `WINBOOL` is defined here: https://github.com/nim-lang/Nim/blob/52cf7280019c/lib/windows/winlean.nim#L33 Fixes: #5 --- uuids.nimble | 2 +- uuids/urandom.nim | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/uuids.nimble b/uuids.nimble index 98eaf59..ccc6e86 100644 --- a/uuids.nimble +++ b/uuids.nimble @@ -1,6 +1,6 @@ [Package] name: "uuids" -version: "0.1.10" +version: "0.1.11" author: "Xored Software, Inc." description: "UUID library" license: "MIT" diff --git a/uuids/urandom.nim b/uuids/urandom.nim index 3666214..6078de4 100644 --- a/uuids/urandom.nim +++ b/uuids/urandom.nim @@ -16,16 +16,16 @@ when defined(windows): proc CryptAcquireContext( phProv: ptr HCRYPTPROV, pszContainer: WideCString, pszProvider: WideCString, dwProvType: DWORD, dwFlags: DWORD - ): WinBool {.importc: "CryptAcquireContextW".} + ): WINBOOL {.importc: "CryptAcquireContextW".} else: proc CryptAcquireContext( phProv: ptr HCRYPTPROV, pszContainer: cstring, pszProvider: cstring, dwProvType: DWORD, dwFlags: DWORD - ): WinBool {.importc: "CryptAcquireContextA".} + ): WINBOOL {.importc: "CryptAcquireContextA".} proc CryptGenRandom( hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: pointer - ): WinBool {.importc: "CryptGenRandom".} + ): WINBOOL {.importc: "CryptGenRandom".} {.pop.}