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 {...@@ -805,11 +805,7 @@ pub const Builder = struct {
805 return name;805 return name;
806 }806 }
807 const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });807 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| {808 return fs.realpathAlloc(self.allocator, full_path) catch continue;
809 return real_path;
810 } else |_| {
811 continue;
812 }
813 }809 }
814 }810 }
815 if (self.env_map.get("PATH")) |PATH| {811 if (self.env_map.get("PATH")) |PATH| {
...@@ -820,11 +816,7 @@ pub const Builder = struct {...@@ -820,11 +816,7 @@ pub const Builder = struct {
820 var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});816 var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
821 while (it.next()) |path| {817 while (it.next()) |path| {
822 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });818 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| {819 return fs.realpathAlloc(self.allocator, full_path) catch continue;
824 return real_path;
825 } else |_| {
826 continue;
827 }
828 }820 }
829 }821 }
830 }822 }
...@@ -834,11 +826,7 @@ pub const Builder = struct {...@@ -834,11 +826,7 @@ pub const Builder = struct {
834 }826 }
835 for (paths) |path| {827 for (paths) |path| {
836 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });828 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| {829 return fs.realpathAlloc(self.allocator, full_path) catch continue;
838 return real_path;
839 } else |_| {
840 continue;
841 }
842 }830 }
843 }831 }
844 return error.FileNotFound;832 return error.FileNotFound;