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 @@...@@ -1,6 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const gpa = std.heap.c_allocator;2const gpa = std.heap.c_allocator;
3const zfetch = @import("zfetch");3const zfetch = @import("zfetch");
4const extras = @import("extras");
45
5const zigmod = @import("../../lib.zig");6const zigmod = @import("../../lib.zig");
6const u = @import("./../../util/index.zig");7const u = @import("./../../util/index.zig");
...@@ -62,7 +63,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void {...@@ -62,7 +63,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void {
6263
63 const file_w = file.writer();64 const file_w = file.writer();
64 try file_w.writeAll("\n");65 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")});
66 if (!(has_zigdotmod or has_zigmodyml)) {67 if (!(has_zigdotmod or has_zigmodyml)) {
67 try file_w.print(" name: {s}\n", .{found.name});68 try file_w.print(" name: {s}\n", .{found.name});
68 try file_w.print(" main: {s}\n", .{found.root_file[1..]});69 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 {...@@ -41,7 +41,7 @@ pub const Dep = struct {
41 p = extras.trimPrefix(p, "http://");41 p = extras.trimPrefix(p, "http://");
42 p = extras.trimPrefix(p, "https://");42 p = extras.trimPrefix(p, "https://");
43 p = extras.trimPrefix(p, "git://");43 p = extras.trimPrefix(p, "git://");
44 p = u.trim_suffix(p, ".git");44 p = extras.trimSuffix(p, ".git");
45 p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p });45 p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p });
46 return p;46 return p;
47 }47 }
src/util/funcs.zig-7
...@@ -46,13 +46,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {...@@ -46,13 +46,6 @@ pub fn split(alloc: std.mem.Allocator, in: string, delim: string) ![]string {
46 return list.toOwnedSlice();46 return list.toOwnedSlice();
47}47}
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
56pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool {49pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool {
57 for (haystack) |item| {50 for (haystack) |item| {
58 if (item.eql(needle)) {51 if (item.eql(needle)) {