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

@ -1914,7 +1914,7 @@ func find*(s: string, sub: char, start: Natural = 0, last = -1): int {.rtl,
if length > 0:
let found = c_memchr(s[start].unsafeAddr, sub, cast[csize_t](length))
if not found.isNil:
return cast[ByteAddress](found) -% cast[ByteAddress](s.cstring)
return cast[int](found) -% cast[int](s.cstring)
else:
findImpl()
@ -1970,7 +1970,7 @@ func find*(s, sub: string, start: Natural = 0, last = -1): int {.rtl,
if last < 0 and start < s.len and subLen != 0:
let found = memmem(s[start].unsafeAddr, csize_t(s.len - start), sub.cstring, csize_t(subLen))
result = if not found.isNil:
cast[ByteAddress](found) -% cast[ByteAddress](s.cstring)
cast[int](found) -% cast[int](s.cstring)
else:
-1
else: