fix: replace nim's std/nre with nim-regex library

This commit is contained in:
Lorenzo Delgado 2022-11-02 15:55:09 +01:00 committed by GitHub
parent 83ae6987b8
commit 0e1dae5956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 7 deletions

10
.gitmodules vendored
View File

@ -153,3 +153,13 @@
url = https://github.com/vacp2p/zerokit.git url = https://github.com/vacp2p/zerokit.git
ignore = dirty ignore = dirty
branch = master branch = master
[submodule "vendor/nim-regex"]
path = vendor/nim-regex
url = https://github.com/nitely/nim-regex.git
ignore = untracked
branch = master
[submodule "vendor/nim-unicodedb"]
path = vendor/nim-unicodedb
url = https://github.com/nitely/nim-unicodedb.git
ignore = untracked
branch = master

View File

@ -1,8 +1,9 @@
import import
std/[strutils, nre], std/strutils,
stew/results, stew/results,
chronicles, chronicles,
chronos, chronos,
regex,
confutils, confutils,
confutils/defs, confutils/defs,
confutils/std/net, confutils/std/net,
@ -473,8 +474,7 @@ proc defaultListenAddress*(): ValidIpAddress =
proc defaultPrivateKey*(): PrivateKey = proc defaultPrivateKey*(): PrivateKey =
crypto.PrivateKey.random(Secp256k1, crypto.newRng()[]).value crypto.PrivateKey.random(Secp256k1, crypto.newRng()[]).value
proc readValue*(r: var TomlReader, val: var crypto.PrivateKey) proc readValue*(r: var TomlReader, val: var crypto.PrivateKey) {.raises: [SerializationError].} =
{.raises: [Defect, IOError, SerializationError].} =
val = try: parseCmdArg(crypto.PrivateKey, r.readValue(string)) val = try: parseCmdArg(crypto.PrivateKey, r.readValue(string))
except CatchableError as err: except CatchableError as err:
raise newException(SerializationError, err.msg) raise newException(SerializationError, err.msg)
@ -487,7 +487,7 @@ let DbUrlRegex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
proc validateDbUrl*(val: string): ConfResult[string] = proc validateDbUrl*(val: string): ConfResult[string] =
let val = val.strip() let val = val.strip()
if val == "" or val.match(DbUrlRegex).isSome(): if val == "" or val.match(DbUrlRegex):
return ok(val) return ok(val)
else: else:
return err("invalid 'db url' option format: " & val) return err("invalid 'db url' option format: " & val)
@ -498,7 +498,7 @@ let StoreMessageRetentionPolicyRegex = re"^\w+:\w$"
proc validateStoreMessageRetentionPolicy*(val: string): ConfResult[string] = proc validateStoreMessageRetentionPolicy*(val: string): ConfResult[string] =
let val = val.strip() let val = val.strip()
if val == "" or val.match(StoreMessageRetentionPolicyRegex).isSome(): if val == "" or val.match(StoreMessageRetentionPolicyRegex):
return ok(val) return ok(val)
else: else:
return err("invalid 'store message retention policy' option format: " & val) return err("invalid 'store message retention policy' option format: " & val)

1
vendor/nim-regex vendored Submodule

@ -0,0 +1 @@
Subproject commit ab98735539ddd8a1eaaa795fd2ca65293c1640b3

1
vendor/nim-unicodedb vendored Submodule

@ -0,0 +1 @@
Subproject commit c3c9ae079ab2eed33ffe5ca27ec4013beed7647f

View File

@ -8,7 +8,7 @@ license = "MIT or Apache License 2.0"
#bin = @["build/waku"] #bin = @["build/waku"]
### Dependencies ### Dependencies
requires "nim >= 1.2.0", requires "nim >= 1.6.0",
"chronicles", "chronicles",
"confutils", "confutils",
"chronos", "chronos",
@ -21,7 +21,8 @@ requires "nim >= 1.2.0",
"metrics", "metrics",
"libp2p", # Only for Waku v2 "libp2p", # Only for Waku v2
"web3", "web3",
"presto" "presto",
"regex"
### Helper functions ### Helper functions
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =