| author | |
| committer | |
| log | 6aa244fffd454b871bebf38194c5a55ed52a8abb |
| tree | 722603e15d0b3cf460332fa3330a69a9575cf7e0 |
| parent | ae17b466f8c7971edd28125a68a4f9ffdc291dd9 |
4 files changed, 15 insertions(+), 15 deletions(-)
src/common.zig+5-5| ... | @@ -127,10 +127,10 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! | ... | @@ -127,10 +127,10 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 127 | }, | 127 | }, |
| 128 | .git => { | 128 | .git => { |
| 129 | if (d.version.len > 0) { | 129 | if (d.version.len > 0) { |
| 130 | const vers = u.parse_split(zigmod.Dep.Type.Version.Git, "-").do(d.version) catch |e| switch (e) { | 130 | const vers = u.parse_split(zigmod.Dep.Type.Version.Git, '-').do(d.version) catch |e| switch (e) { |
| 131 | error.IterEmpty => unreachable, | 131 | error.IterEmpty => unreachable, |
| 132 | error.NoMemberFound => { | 132 | error.NoMemberFound => { |
| 133 | const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; | 133 | const vtype = d.version[0..std.mem.indexOfScalar(u8, d.version, '-').?]; |
| 134 | u.fail("fetch: git: version type '{s}' is invalid.", .{vtype}); | 134 | u.fail("fetch: git: version type '{s}' is invalid.", .{vtype}); |
| 135 | }, | 135 | }, |
| 136 | }; | 136 | }; |
| ... | @@ -179,7 +179,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! | ... | @@ -179,7 +179,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 179 | if (try extras.doesFolderExist(null, pv)) { | 179 | if (try extras.doesFolderExist(null, pv)) { |
| 180 | return pv; | 180 | return pv; |
| 181 | } | 181 | } |
| 182 | const file_name = u.last(try u.split(options.alloc, d.path, "/")).?; | 182 | const file_name = u.last(try u.split(options.alloc, d.path, '/')).?; |
| 183 | if (d.version.len > 0) { | 183 | if (d.version.len > 0) { |
| 184 | if (try extras.doesFolderExist(null, pv)) { | 184 | if (try extras.doesFolderExist(null, pv)) { |
| 185 | return pv; | 185 | return pv; |
| ... | @@ -338,7 +338,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str | ... | @@ -338,7 +338,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 338 | } | 338 | } |
| 339 | switch (v) { | 339 | switch (v) { |
| 340 | 1 => { | 340 | 1 => { |
| 341 | var iter = std.mem.split(u8, line, " "); | 341 | var iter = std.mem.splitScalar(u8, line, ' '); |
| 342 | try list.append([4]string{ | 342 | try list.append([4]string{ |
| 343 | iter.next().?, | 343 | iter.next().?, |
| 344 | iter.next().?, | 344 | iter.next().?, |
| ... | @@ -347,7 +347,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str | ... | @@ -347,7 +347,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 347 | }); | 347 | }); |
| 348 | }, | 348 | }, |
| 349 | 2 => { | 349 | 2 => { |
| 350 | var iter = std.mem.split(u8, line, " "); | 350 | var iter = std.mem.splitScalar(u8, line, ' '); |
| 351 | const asdep = zigmod.Dep{ | 351 | const asdep = zigmod.Dep{ |
| 352 | .type = std.meta.stringToEnum(zigmod.Dep.Type, iter.next().?).?, | 352 | .type = std.meta.stringToEnum(zigmod.Dep.Type, iter.next().?).?, |
| 353 | .path = iter.next().?, | 353 | .path = iter.next().?, |
src/util/dep.zig+1-1| ... | @@ -71,7 +71,7 @@ pub const Dep = struct { | ... | @@ -71,7 +71,7 @@ pub const Dep = struct { |
| 71 | } | 71 | } |
| 72 | return switch (self.type) { | 72 | return switch (self.type) { |
| 73 | .git => blk: { | 73 | .git => blk: { |
| 74 | const vers = try u.parse_split(zigmod.Dep.Type.Version.Git, "-").do(self.version); | 74 | const vers = try u.parse_split(zigmod.Dep.Type.Version.Git, '-').do(self.version); |
| 75 | if (vers.id.frozen()) break :blk self.version; | 75 | if (vers.id.frozen()) break :blk self.version; |
| 76 | break :blk try self.type.exact_version(alloc, dpath); | 76 | break :blk try self.type.exact_version(alloc, dpath); |
| 77 | }, | 77 | }, |
src/util/funcs.zig+6-6| ... | @@ -36,11 +36,11 @@ pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T { | ... | @@ -36,11 +36,11 @@ pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T { |
| 36 | return array[n]; | 36 | return array[n]; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string { | 39 | pub fn split(alloc: std.mem.Allocator, in: string, delim: u8) ![]string { |
| 40 | var list = std.ArrayList(string).init(alloc); | 40 | var list = std.ArrayList(string).init(alloc); |
| 41 | errdefer list.deinit(); | 41 | errdefer list.deinit(); |
| 42 | 42 | ||
| 43 | var iter = std.mem.split(u8, in, delim); | 43 | var iter = std.mem.splitScalar(u8, in, delim); |
| 44 | while (iter.next()) |str| { | 44 | while (iter.next()) |str| { |
| 45 | try list.append(str); | 45 | try list.append(str); |
| 46 | } | 46 | } |
| ... | @@ -99,7 +99,7 @@ pub fn random_string(comptime len: usize) [len]u8 { | ... | @@ -99,7 +99,7 @@ pub fn random_string(comptime len: usize) [len]u8 { |
| 99 | return buf; | 99 | return buf; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | pub fn parse_split(comptime T: type, comptime delim: string) type { | 102 | pub fn parse_split(comptime T: type, comptime delim: u8) type { |
| 103 | return struct { | 103 | return struct { |
| 104 | const Self = @This(); | 104 | const Self = @This(); |
| 105 | 105 | ||
| ... | @@ -107,7 +107,7 @@ pub fn parse_split(comptime T: type, comptime delim: string) type { | ... | @@ -107,7 +107,7 @@ pub fn parse_split(comptime T: type, comptime delim: string) type { |
| 107 | string: string, | 107 | string: string, |
| 108 | 108 | ||
| 109 | pub fn do(input: string) !Self { | 109 | pub fn do(input: string) !Self { |
| 110 | var iter = std.mem.split(u8, input, delim); | 110 | var iter = std.mem.splitScalar(u8, input, delim); |
| 111 | const start = iter.next() orelse return error.IterEmpty; | 111 | const start = iter.next() orelse return error.IterEmpty; |
| 112 | const id = std.meta.stringToEnum(T, start) orelse return error.NoMemberFound; | 112 | const id = std.meta.stringToEnum(T, start) orelse return error.NoMemberFound; |
| 113 | return Self{ | 113 | return Self{ |
| ... | @@ -125,7 +125,7 @@ pub const HashFn = enum { | ... | @@ -125,7 +125,7 @@ pub const HashFn = enum { |
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | pub fn validate_hash(alloc: std.mem.Allocator, input: string, file_path: string) !bool { | 127 | pub fn validate_hash(alloc: std.mem.Allocator, input: string, file_path: string) !bool { |
| 128 | const hash = parse_split(HashFn, "-").do(input) catch return false; | 128 | const hash = parse_split(HashFn, '-').do(input) catch return false; |
| 129 | const file = try std.fs.cwd().openFile(file_path, .{}); | 129 | const file = try std.fs.cwd().openFile(file_path, .{}); |
| 130 | defer file.close(); | 130 | defer file.close(); |
| 131 | const data = try file.reader().readAllAlloc(alloc, gb); | 131 | const data = try file.reader().readAllAlloc(alloc, gb); |
| ... | @@ -169,7 +169,7 @@ pub fn detect_pkgname(alloc: std.mem.Allocator, override: string, dir: string) ! | ... | @@ -169,7 +169,7 @@ pub fn detect_pkgname(alloc: std.mem.Allocator, override: string, dir: string) ! |
| 169 | return error.NoBuildZig; | 169 | return error.NoBuildZig; |
| 170 | } | 170 | } |
| 171 | const dpath = try std.fs.realpathAlloc(alloc, try std.fs.path.join(alloc, &.{ dir, "build.zig" })); | 171 | const dpath = try std.fs.realpathAlloc(alloc, try std.fs.path.join(alloc, &.{ dir, "build.zig" })); |
| 172 | const splitP = try split(alloc, dpath, std.fs.path.sep_str); | 172 | const splitP = try split(alloc, dpath, std.fs.path.sep); |
| 173 | var name = splitP[splitP.len - 2]; | 173 | var name = splitP[splitP.len - 2]; |
| 174 | name = extras.trimPrefix(name, "zig-"); | 174 | name = extras.trimPrefix(name, "zig-"); |
| 175 | assert(name.len > 0, "package name must not be an empty string", .{}); | 175 | assert(name.len > 0, "package name must not be an empty string", .{}); |
src/util/modfile.zig+3-3| ... | @@ -93,7 +93,7 @@ pub const ModFile = struct { | ... | @@ -93,7 +93,7 @@ pub const ModFile = struct { |
| 93 | var main = item.mapping.get_string("main") orelse ""; | 93 | var main = item.mapping.get_string("main") orelse ""; |
| 94 | 94 | ||
| 95 | if (item.mapping.get("src")) |val| { | 95 | if (item.mapping.get("src")) |val| { |
| 96 | var src_iter = std.mem.tokenize(u8, val.string, " "); | 96 | var src_iter = std.mem.tokenizeScalar(u8, val.string, ' '); |
| 97 | dtype = src_iter.next().?; | 97 | dtype = src_iter.next().?; |
| 98 | path = src_iter.next().?; | 98 | path = src_iter.next().?; |
| 99 | if (src_iter.next()) |dver| { | 99 | if (src_iter.next()) |dver| { |
| ... | @@ -130,8 +130,8 @@ pub const ModFile = struct { | ... | @@ -130,8 +130,8 @@ pub const ModFile = struct { |
| 130 | .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"), | 130 | .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"), |
| 131 | .c_source_flags = try item.mapping.get_string_array(alloc, "c_source_flags"), | 131 | .c_source_flags = try item.mapping.get_string_array(alloc, "c_source_flags"), |
| 132 | .c_source_files = try item.mapping.get_string_array(alloc, "c_source_files"), | 132 | .c_source_files = try item.mapping.get_string_array(alloc, "c_source_files"), |
| 133 | .only_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("only_os") orelse "", ","), ""), | 133 | .only_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("only_os") orelse "", ','), ""), |
| 134 | .except_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("except_os") orelse "", ","), ""), | 134 | .except_os = try u.list_remove(alloc, try u.split(alloc, item.mapping.get_string("except_os") orelse "", ','), ""), |
| 135 | .yaml = item.mapping, | 135 | .yaml = item.mapping, |
| 136 | .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build), | 136 | .deps = try dep_list_by_name(alloc, item.mapping, &.{"dependencies"}, for_build), |
| 137 | .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""), | 137 | .keep = std.mem.eql(u8, "true", item.mapping.get_string("keep") orelse ""), |