From 9602c574e96844aa5e96bc148f340619d9d8730c Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 12 Mar 2021 15:42:33 -0800 Subject: [PATCH] util/modfile: allow src attribute to accept version in 3rd space --- src/util/modfile.zig | 11 +++++++++-- zig.mod | 20 +++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/util/modfile.zig b/src/util/modfile.zig index 90dd17bc5ac872b92940b19bfb6dc9c8a498cd6a..0ae8582f6a3a92f59a28cc06cc1855ee223d2ad8 100644 --- a/src/util/modfile.zig +++ b/src/util/modfile.zig @@ -44,14 +44,21 @@ pub const ModFile = struct { for (dep_seq.sequence) |item| { var dtype: []const u8 = undefined; var path: []const u8 = undefined; + var version: []const u8 = undefined; if (item.mapping.get("src")) |val| { - var src_iter = std.mem.split(val.string, " "); + var src_iter = std.mem.tokenize(val.string, " "); dtype = src_iter.next().?; path = src_iter.next().?; + if (src_iter.next()) |dver| { + version = dver; + } } else { dtype = item.mapping.get("type").?.string; path = item.mapping.get("path").?.string; } + if (item.mapping.get("version")) |verv| { + version = verv.string; + } const dep_type = std.meta.stringToEnum(u.DepType, dtype).?; try dep_list.append(u.Dep{ @@ -60,7 +67,7 @@ pub const ModFile = struct { .id = item.mapping.get_string("id"), .name = item.mapping.get_string("name"), .main = item.mapping.get_string("main"), - .version = item.mapping.get_string("version"), + .version = version, .c_include_dirs = try item.mapping.get_string_array(alloc, "c_include_dirs"), .c_source_flags = try item.mapping.get_string_array(alloc, "c_source_flags"), .c_source_files = try item.mapping.get_string_array(alloc, "c_source_files"), diff --git a/zig.mod b/zig.mod index 020da1dddca6f51b475b2a71247994d10239fbac..ca6f03e9eec046c838b238f506dba62b2795099a 100644 --- a/zig.mod +++ b/zig.mod @@ -3,8 +3,7 @@ name: zigmod main: src/main.zig license: MIT dependencies: - - src: git https://github.com/yaml/libyaml - version: tag-0.2.5 + - src: git https://github.com/yaml/libyaml tag-0.2.5 id: 8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc license: MIT c_include_dirs: @@ -25,21 +24,16 @@ dependencies: - src/scanner.c - src/writer.c - - src: git https://github.com/nektro/zig-ansi - version: commit-25039ca + - src: git https://github.com/nektro/zig-ansi commit-25039ca # Entries above this line are needed to bootstrap and kept as git submodules # -------- # Entries below this line are only fetched with zigmod itself - - src: git https://github.com/ziglibs/known-folders - version: commit-f0f4188 + - src: git https://github.com/ziglibs/known-folders commit-f0f4188 - - src: git https://github.com/Vexu/zuri - version: commit-41bcd78 + - src: git https://github.com/Vexu/zuri commit-41bcd78 - - src: git https://github.com/alexnask/iguanaTLS - version: commit-2c21764 - - - src: git https://github.com/nektro/zig-licenses - version: commit-73bc493 + - src: git https://github.com/alexnask/iguanaTLS commit-2c21764 + + - src: git https://github.com/nektro/zig-licenses commit-73bc493 -- 2.54.0