Fix deprecation warnings in re
This commit is contained in:
parent
7d06fc2165
commit
fd8c6d0a32
1 changed files with 7 additions and 7 deletions
|
|
@ -41,11 +41,11 @@ type
|
||||||
reExtended = 3, ## ignore whitespace and ``#`` comments
|
reExtended = 3, ## ignore whitespace and ``#`` comments
|
||||||
reStudy = 4 ## study the expression (may be omitted if the
|
reStudy = 4 ## study the expression (may be omitted if the
|
||||||
## expression will be used only once)
|
## expression will be used only once)
|
||||||
|
|
||||||
RegexDesc = object
|
RegexDesc = object
|
||||||
h: PPcre
|
h: ptr Pcre
|
||||||
e: ptr TExtra
|
e: ptr ExtraData
|
||||||
|
|
||||||
Regex* = ref RegexDesc ## a compiled regular expression
|
Regex* = ref RegexDesc ## a compiled regular expression
|
||||||
|
|
||||||
RegexError* = object of ValueError
|
RegexError* = object of ValueError
|
||||||
|
|
@ -60,7 +60,7 @@ proc raiseInvalidRegex(msg: string) {.noinline, noreturn.} =
|
||||||
e.msg = msg
|
e.msg = msg
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
proc rawCompile(pattern: string, flags: cint): PPcre =
|
proc rawCompile(pattern: string, flags: cint): ptr Pcre =
|
||||||
var
|
var
|
||||||
msg: cstring
|
msg: cstring
|
||||||
offset: cint
|
offset: cint
|
||||||
|
|
@ -84,7 +84,7 @@ proc re*(s: string, flags = {reExtended, reStudy}): Regex =
|
||||||
result.h = rawCompile(s, cast[cint](flags - {reStudy}))
|
result.h = rawCompile(s, cast[cint](flags - {reStudy}))
|
||||||
if reStudy in flags:
|
if reStudy in flags:
|
||||||
var msg: cstring
|
var msg: cstring
|
||||||
result.e = pcre.study(result.h, 0, msg)
|
result.e = pcre.study(result.h, 0, addr msg)
|
||||||
if not isNil(msg): raiseInvalidRegex($msg)
|
if not isNil(msg): raiseInvalidRegex($msg)
|
||||||
|
|
||||||
proc matchOrFind(s: string, pattern: Regex, matches: var openArray[string],
|
proc matchOrFind(s: string, pattern: Regex, matches: var openArray[string],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue