This commit is contained in:
Bung 2022-12-16 15:01:15 +08:00 • committed by GitHub
commit a9bd78d579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 140 additions and 140 deletions

View file

@ -93,7 +93,7 @@ func find*(s: cstring, sub: char, start: Natural = 0, last = 0): int =
if L > 0:
let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](L))
if not found.isNil:
return cast[ByteAddress](found) -% cast[ByteAddress](s)
return cast[int](found) -% cast[int](s)
return -1
func find*(s, sub: cstring, start: Natural = 0, last = 0): int =
@ -108,6 +108,6 @@ func find*(s, sub: cstring, start: Natural = 0, last = 0): int =
if last == 0 and s.len > start:
let found = c_strstr(cast[cstring](s[start].unsafeAddr), sub)
if not found.isNil:
result = cast[ByteAddress](found) -% cast[ByteAddress](s)
result = cast[int](found) -% cast[int](s)
else:
result = -1