Skip to content

Commit 63da4e8

Browse files
authored
lib: remove backported cutPrefix implementation (ghostty-org#13658)
We can use std.mem.cutPrefix directly now that we're on Zig 0.16.
2 parents e1fc390 + 1d6bc68 commit 63da4e8

4 files changed

Lines changed: 5 additions & 23 deletions

File tree

src/apprt/gtk/class/application.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const xev = global.xev;
2626
const Binding = @import("../../../input.zig").Binding;
2727
const CoreConfig = configpkg.Config;
2828
const CoreSurface = @import("../../../Surface.zig");
29-
const lib = @import("../../../lib/main.zig");
3029

3130
const ext = @import("../ext.zig");
3231
const key = @import("../key.zig");
@@ -1878,7 +1877,7 @@ pub const Application = extern struct {
18781877
continue;
18791878
}
18801879

1881-
if (lib.cutPrefix(u8, str, "--command=")) |v| {
1880+
if (std.mem.cutPrefix(u8, str, "--command=")) |v| {
18821881
var cmd: configpkg.Command = undefined;
18831882
cmd.parseCLI(alloc, v) catch |err| {
18841883
log.warn("unable to parse command: {t}", .{err});
@@ -1887,14 +1886,14 @@ pub const Application = extern struct {
18871886
command = cmd;
18881887
continue;
18891888
}
1890-
if (lib.cutPrefix(u8, str, "--working-directory=")) |v| {
1889+
if (std.mem.cutPrefix(u8, str, "--working-directory=")) |v| {
18911890
working_directory = alloc.dupeZ(u8, std.mem.trim(u8, v, &std.ascii.whitespace)) catch |err| wd: {
18921891
log.warn("unable to duplicate working directory: {t}", .{err});
18931892
break :wd null;
18941893
};
18951894
continue;
18961895
}
1897-
if (lib.cutPrefix(u8, str, "--title=")) |v| {
1896+
if (std.mem.cutPrefix(u8, str, "--title=")) |v| {
18981897
title = alloc.dupeZ(u8, std.mem.trim(u8, v, &std.ascii.whitespace)) catch |err| t: {
18991898
log.warn("unable to duplicate title: {t}", .{err});
19001899
break :t null;

src/cli/new_window.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const Action = @import("../cli.zig").ghostty.Action;
55
const apprt = @import("../apprt.zig");
66
const args = @import("args.zig");
77
const diagnostics = @import("diagnostics.zig");
8-
const lib = @import("../lib/main.zig");
98
const homedir = @import("../os/homedir.zig");
109
const global = @import("../global.zig");
1110

@@ -70,12 +69,12 @@ pub const Options = struct {
7069
Allocator.Error;
7170

7271
fn checkArg(self: *Options, alloc: Allocator, arg: []const u8) CheckArgError!?[:0]const u8 {
73-
if (lib.cutPrefix(u8, arg, "--class=")) |rest| {
72+
if (std.mem.cutPrefix(u8, arg, "--class=")) |rest| {
7473
self.class = try alloc.dupeZ(u8, std.mem.trim(u8, rest, &std.ascii.whitespace));
7574
return null;
7675
}
7776

78-
if (lib.cutPrefix(u8, arg, "--working-directory=")) |rest| {
77+
if (std.mem.cutPrefix(u8, arg, "--working-directory=")) |rest| {
7978
const stripped = std.mem.trim(u8, rest, &std.ascii.whitespace);
8079
if (std.mem.eql(u8, stripped, "home")) return try alloc.dupeZ(u8, arg);
8180
if (std.mem.eql(u8, stripped, "inherit")) return try alloc.dupeZ(u8, arg);

src/lib/main.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub const Struct = structpkg.Struct;
1313
pub const structSizedFieldFits = structpkg.sizedFieldFits;
1414
pub const Target = @import("target.zig").Target;
1515
pub const TaggedUnion = unionpkg.TaggedUnion;
16-
pub const cutPrefix = @import("string.zig").cutPrefix;
1716

1817
test {
1918
std.testing.refAllDecls(@This());

src/lib/string.zig

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)