| author | |
| committer | |
| log | d2bedba959d5237145318d9feb424f914bfcdf74 |
| tree | a4d976bb55f2741aa60437bd0ca443af3d5e42d5 |
| parent | 67caed05c15bee558beb29dd5f33d38cac874e89 |
5 files changed, 8 insertions(+), 16 deletions(-)
src/cmd/license.zig+2-1| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const gpa = std.heap.c_allocator; | 2 | const gpa = std.heap.c_allocator; |
| 3 | const style = @import("ansi").style; | 3 | const style = @import("ansi").style; |
| 4 | const licenses = @import("licenses"); | 4 | const licenses = @import("licenses"); |
| 5 | const extras = @import("extras"); | ||
| 5 | 6 | ||
| 6 | const zigmod = @import("../lib.zig"); | 7 | const zigmod = @import("../lib.zig"); |
| 7 | const u = @import("./../util/index.zig"); | 8 | const u = @import("./../util/index.zig"); |
| ... | @@ -77,7 +78,7 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -77,7 +78,7 @@ pub fn execute(args: [][]u8) !void { |
| 77 | first = false; | 78 | first = false; |
| 78 | try writer.writeAll(Bold); | 79 | try writer.writeAll(Bold); |
| 79 | try writer.print("{s}:\n", .{entry.key_ptr.*}); | 80 | try writer.print("{s}:\n", .{entry.key_ptr.*}); |
| 80 | if (u.list_contains(licenses.spdx, entry.key_ptr.*)) { | 81 | if (extras.containsString(licenses.spdx, entry.key_ptr.*)) { |
| 81 | try writer.writeAll(Faint); | 82 | try writer.writeAll(Faint); |
| 82 | try writer.print("= {s}{s}\n", .{ "https://spdx.org/licenses/", entry.key_ptr.* }); | 83 | try writer.print("= {s}{s}\n", .{ "https://spdx.org/licenses/", entry.key_ptr.* }); |
| 83 | } | 84 | } |
src/common.zig+2-2| ... | @@ -104,8 +104,8 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! | ... | @@ -104,8 +104,8 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 104 | const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v(options.alloc) }); | 104 | const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v(options.alloc) }); |
| 105 | 105 | ||
| 106 | const nocache = d.type.isLocal(); | 106 | const nocache = d.type.isLocal(); |
| 107 | if (!nocache and u.list_contains(options.already_fetched.items, p)) return p; | 107 | if (!nocache and extras.containsString(options.already_fetched.items, p)) return p; |
| 108 | if (!nocache and u.list_contains(options.already_fetched.items, pv)) return pv; | 108 | if (!nocache and extras.containsString(options.already_fetched.items, pv)) return pv; |
| 109 | 109 | ||
| 110 | if (options.log and d.type != .local) { | 110 | if (options.log and d.type != .local) { |
| 111 | std.debug.print("fetch: {s}: {s}\n", .{ @tagName(d.type), d.path }); | 111 | std.debug.print("fetch: {s}: {s}\n", .{ @tagName(d.type), d.path }); |
src/util/dep.zig+2-2| ... | @@ -56,10 +56,10 @@ pub const Dep = struct { | ... | @@ -56,10 +56,10 @@ pub const Dep = struct { |
| 56 | pub fn is_for_this(self: Dep) bool { | 56 | pub fn is_for_this(self: Dep) bool { |
| 57 | const os = @tagName(builtin.os.tag); | 57 | const os = @tagName(builtin.os.tag); |
| 58 | if (self.only_os.len > 0) { | 58 | if (self.only_os.len > 0) { |
| 59 | return u.list_contains(self.only_os, os); | 59 | return extras.containsString(self.only_os, os); |
| 60 | } | 60 | } |
| 61 | if (self.except_os.len > 0) { | 61 | if (self.except_os.len > 0) { |
| 62 | return !u.list_contains(self.except_os, os); | 62 | return !extras.containsString(self.except_os, os); |
| 63 | } | 63 | } |
| 64 | return true; | 64 | return true; |
| 65 | } | 65 | } |
src/util/funcs.zig-9| ... | @@ -75,15 +75,6 @@ pub fn trim_suffix(in: string, suffix: string) string { | ... | @@ -75,15 +75,6 @@ pub fn trim_suffix(in: string, suffix: string) string { |
| 75 | return in; | 75 | return in; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | pub fn list_contains(haystack: []const string, needle: string) bool { | ||
| 79 | for (haystack) |item| { | ||
| 80 | if (std.mem.eql(u8, item, needle)) { | ||
| 81 | return true; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | return false; | ||
| 85 | } | ||
| 86 | |||
| 87 | pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool { | 78 | pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool { |
| 88 | for (haystack) |item| { | 79 | for (haystack) |item| { |
| 89 | if (item.eql(needle)) { | 80 | if (item.eql(needle)) { |
src/util/module.zig+2-2| ... | @@ -98,10 +98,10 @@ pub const Module = struct { | ... | @@ -98,10 +98,10 @@ pub const Module = struct { |
| 98 | pub fn is_for_this(self: Module) bool { | 98 | pub fn is_for_this(self: Module) bool { |
| 99 | const os = @tagName(builtin.os.tag); | 99 | const os = @tagName(builtin.os.tag); |
| 100 | if (self.only_os.len > 0) { | 100 | if (self.only_os.len > 0) { |
| 101 | return u.list_contains(self.only_os, os); | 101 | return extras.containsString(self.only_os, os); |
| 102 | } | 102 | } |
| 103 | if (self.except_os.len > 0) { | 103 | if (self.except_os.len > 0) { |
| 104 | return !u.list_contains(self.except_os, os); | 104 | return !extras.containsString(self.except_os, os); |
| 105 | } | 105 | } |
| 106 | return true; | 106 | return true; |
| 107 | } | 107 | } |