authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-03-01 20:06:30+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-01 11:08:16-08:00
logbee7db77fe65802a41f2812caac4faa7dcb8acd3
tree84c28ada047c8a39687c31a6944f23b081b24628
parentbaab1b2f3135a10ed0adb56e653fc300d4add661

std: Replace lastIndexOf with lastIndexOfScalar

This may work around the miscompilation in LLVM 12.

1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/fs/path.zig+1-1
...@@ -1226,7 +1226,7 @@ fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []cons...@@ -1226,7 +1226,7 @@ fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []cons
1226/// pointer address range of `path`, even if it is length zero.1226/// pointer address range of `path`, even if it is length zero.
1227pub fn extension(path: []const u8) []const u8 {1227pub fn extension(path: []const u8) []const u8 {
1228 const filename = basename(path);1228 const filename = basename(path);
1229 const index = mem.lastIndexOf(u8, filename, ".") orelse return path[path.len..];1229 const index = mem.lastIndexOfScalar(u8, filename, '.') orelse return path[path.len..];
1230 if (index == 0) return path[path.len..];1230 if (index == 0) return path[path.len..];
1231 return filename[index..];1231 return filename[index..];
1232}1232}