authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-24 00:58:12 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-11-24 00:58:12 -08:00
loge545025a089e4512a95c147ba4a2773553817c74
tree9a9cf538f780b7a784a730acb802b61abe40e41b
parent5a69da98a707e3e638af7204e6dbb80bef0b186c

util: drop trim_suffix


3 files changed, 3 insertions(+), 9 deletions(-)

src/cmd/zpm/add.zig+2-1
......@@ -1,6 +1,7 @@
11const std = @import("std");
22const gpa = std.heap.c_allocator;
33const zfetch = @import("zfetch");
4const extras = @import("extras");
45
56const zigmod = @import("../../lib.zig");
67const u = @import("./../../util/index.zig");
......@@ -62,7 +63,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void {
6263
6364 const file_w = file.writer();
6465 try file_w.writeAll("\n");
65 try file_w.print(" - src: git {s}\n", .{u.trim_suffix(found.git, ".git")});
66 try file_w.print(" - src: git {s}\n", .{extras.trimSuffix(found.git, ".git")});
6667 if (!(has_zigdotmod or has_zigmodyml)) {
6768 try file_w.print(" name: {s}\n", .{found.name});
6869 try file_w.print(" main: {s}\n", .{found.root_file[1..]});
src/util/dep.zig+1-1
......@@ -41,7 +41,7 @@ pub const Dep = struct {
4141 p = extras.trimPrefix(p, "http://");
4242 p = extras.trimPrefix(p, "https://");
4343 p = extras.trimPrefix(p, "git://");
44 p = u.trim_suffix(p, ".git");
44 p = extras.trimSuffix(p, ".git");
4545 p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p });
4646 return p;
4747 }
src/util/funcs.zig-7
......@@ -46,13 +46,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
4646 return list.toOwnedSlice();
4747}
4848
49pub fn trim_suffix(in: string, suffix: string) string {
50 if (std.mem.endsWith(u8, in, suffix)) {
51 return in[0 .. in.len - suffix.len];
52 }
53 return in;
54}
55
5649pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool {
5750 for (haystack) |item| {
5851 if (item.eql(needle)) {