authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2019-07-31 21:28:25-05:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2019-07-31 21:28:25-05:00
log327abdba0b5de1f1eeef32e19b6a16ec4c7ec323
treece85a4a789043ef5d889d4034d4fc1392239fa2b
parente40513e97ff57960165b30a6b9fecfaad95bd1aa

More current style for error handling


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

std/build.zig+3-15
......@@ -805,11 +805,7 @@ pub const Builder = struct {
805805 return name;
806806 }
807807 const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });
808 if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
809 return real_path;
810 } else |_| {
811 continue;
812 }
808 return fs.realpathAlloc(self.allocator, full_path) catch continue;
813809 }
814810 }
815811 if (self.env_map.get("PATH")) |PATH| {
......@@ -820,11 +816,7 @@ pub const Builder = struct {
820816 var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
821817 while (it.next()) |path| {
822818 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
823 if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
824 return real_path;
825 } else |_| {
826 continue;
827 }
819 return fs.realpathAlloc(self.allocator, full_path) catch continue;
828820 }
829821 }
830822 }
......@@ -834,11 +826,7 @@ pub const Builder = struct {
834826 }
835827 for (paths) |path| {
836828 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
837 if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
838 return real_path;
839 } else |_| {
840 continue;
841 }
829 return fs.realpathAlloc(self.allocator, full_path) catch continue;
842830 }
843831 }
844832 return error.FileNotFound;