From e545025a089e4512a95c147ba4a2773553817c74 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 24 Nov 2023 00:58:12 -0800 Subject: [PATCH] util: drop trim_suffix --- src/cmd/zpm/add.zig | 3 ++- src/util/dep.zig | 2 +- src/util/funcs.zig | 7 ------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/cmd/zpm/add.zig b/src/cmd/zpm/add.zig index 1dd5ed9eb14868c4f71cc15b30717ddab4aa9575..b787517fddbebe80ec3388df68fd074a8f5debda 100644 --- a/src/cmd/zpm/add.zig +++ b/src/cmd/zpm/add.zig @@ -1,6 +1,7 @@ const std = @import("std"); const gpa = std.heap.c_allocator; const zfetch = @import("zfetch"); +const extras = @import("extras"); const zigmod = @import("../../lib.zig"); const u = @import("./../../util/index.zig"); @@ -62,7 +63,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { const file_w = file.writer(); try file_w.writeAll("\n"); - try file_w.print(" - src: git {s}\n", .{u.trim_suffix(found.git, ".git")}); + try file_w.print(" - src: git {s}\n", .{extras.trimSuffix(found.git, ".git")}); if (!(has_zigdotmod or has_zigmodyml)) { try file_w.print(" name: {s}\n", .{found.name}); try file_w.print(" main: {s}\n", .{found.root_file[1..]}); diff --git a/src/util/dep.zig b/src/util/dep.zig index e8bd2c5f16d8d33ae0abb3069102a45b84a08ce9..b16b2ba14945fd3b97cfa087cbb0c585cb3dbb33 100644 --- a/src/util/dep.zig +++ b/src/util/dep.zig @@ -41,7 +41,7 @@ pub const Dep = struct { p = extras.trimPrefix(p, "http://"); p = extras.trimPrefix(p, "https://"); p = extras.trimPrefix(p, "git://"); - p = u.trim_suffix(p, ".git"); + p = extras.trimSuffix(p, ".git"); p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p }); return p; } diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 97b73547cfc6fdedd58a769dbc834e08188bffdb..a920acc39b3b55096d73a47e2a30a0bc3da088a1 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -46,13 +46,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string { return list.toOwnedSlice(); } -pub fn trim_suffix(in: string, suffix: string) string { - if (std.mem.endsWith(u8, in, suffix)) { - return in[0 .. in.len - suffix.len]; - } - return in; -} - pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool { for (haystack) |item| { if (item.eql(needle)) { -- 2.54.0