mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Fix multiple deprecated names for zig lib/std
This commit is contained in:
@ -394,7 +394,7 @@ pub fn expandPath(alloc: Allocator, cmd: []const u8) !?[]u8 {
|
|||||||
};
|
};
|
||||||
defer if (builtin.os.tag == .windows) alloc.free(PATH);
|
defer if (builtin.os.tag == .windows) alloc.free(PATH);
|
||||||
|
|
||||||
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
var it = std.mem.tokenizeScalar(u8, PATH, std.fs.path.delimiter);
|
var it = std.mem.tokenizeScalar(u8, PATH, std.fs.path.delimiter);
|
||||||
var seen_eacces = false;
|
var seen_eacces = false;
|
||||||
while (it.next()) |search_path| {
|
while (it.next()) |search_path| {
|
||||||
|
@ -3591,7 +3591,7 @@ fn writeScreenFile(
|
|||||||
try buf_writer.flush();
|
try buf_writer.flush();
|
||||||
|
|
||||||
// Get the final path
|
// Get the final path
|
||||||
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try tmp_dir.dir.realpath(@tagName(loc), &path_buf);
|
const path = try tmp_dir.dir.realpath(@tagName(loc), &path_buf);
|
||||||
|
|
||||||
switch (write_action) {
|
switch (write_action) {
|
||||||
|
@ -1864,7 +1864,7 @@ pub fn loadCliArgs(self: *Config, alloc_gpa: Allocator) !void {
|
|||||||
|
|
||||||
// Config files loaded from the CLI args are relative to pwd
|
// Config files loaded from the CLI args are relative to pwd
|
||||||
if (self.@"config-file".value.list.items.len > 0) {
|
if (self.@"config-file".value.list.items.len > 0) {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
try self.expandPaths(try std.fs.cwd().realpath(".", &buf));
|
try self.expandPaths(try std.fs.cwd().realpath(".", &buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2097,7 +2097,7 @@ pub fn finalize(self: *Config) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wd_home) {
|
if (wd_home) {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
if (try internal_os.home(&buf)) |home| {
|
if (try internal_os.home(&buf)) |home| {
|
||||||
self.@"working-directory" = try alloc.dupe(u8, home);
|
self.@"working-directory" = try alloc.dupe(u8, home);
|
||||||
}
|
}
|
||||||
@ -2899,7 +2899,7 @@ pub const RepeatablePath = struct {
|
|||||||
|
|
||||||
// If it isn't absolute, we need to make it absolute relative
|
// If it isn't absolute, we need to make it absolute relative
|
||||||
// to the base.
|
// to the base.
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const abs = dir.realpath(path, &buf) catch |err| {
|
const abs = dir.realpath(path, &buf) catch |err| {
|
||||||
try errors.add(alloc, .{
|
try errors.add(alloc, .{
|
||||||
.message = try std.fmt.allocPrintZ(
|
.message = try std.fmt.allocPrintZ(
|
||||||
|
@ -375,7 +375,7 @@ pub const Action = union(enum) {
|
|||||||
// ordering
|
// ordering
|
||||||
comptime assert(info.is_tuple);
|
comptime assert(info.is_tuple);
|
||||||
|
|
||||||
var it = std.mem.split(u8, param, ",");
|
var it = std.mem.splitAny(u8, param, ",");
|
||||||
var value: field.type = undefined;
|
var value: field.type = undefined;
|
||||||
inline for (info.fields) |field_| {
|
inline for (info.fields) |field_| {
|
||||||
const next = it.next() orelse return Error.InvalidFormat;
|
const next = it.next() orelse return Error.InvalidFormat;
|
||||||
|
@ -8,7 +8,7 @@ const log = std.log.scoped(.@"linux-cgroup");
|
|||||||
|
|
||||||
/// Returns the path to the cgroup for the given pid.
|
/// Returns the path to the cgroup for the given pid.
|
||||||
pub fn current(alloc: Allocator, pid: std.os.linux.pid_t) !?[]const u8 {
|
pub fn current(alloc: Allocator, pid: std.os.linux.pid_t) !?[]const u8 {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
|
||||||
// Read our cgroup by opening /proc/<pid>/cgroup and reading the first
|
// Read our cgroup by opening /proc/<pid>/cgroup and reading the first
|
||||||
// line. The first line will look something like this:
|
// line. The first line will look something like this:
|
||||||
@ -39,7 +39,7 @@ pub fn create(
|
|||||||
child: []const u8,
|
child: []const u8,
|
||||||
move: ?std.os.linux.pid_t,
|
move: ?std.os.linux.pid_t,
|
||||||
) !void {
|
) !void {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try std.fmt.bufPrint(&buf, "/sys/fs/cgroup{s}/{s}", .{ cgroup, child });
|
const path = try std.fmt.bufPrint(&buf, "/sys/fs/cgroup{s}/{s}", .{ cgroup, child });
|
||||||
try std.fs.cwd().makePath(path);
|
try std.fs.cwd().makePath(path);
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ pub fn moveInto(
|
|||||||
cgroup: []const u8,
|
cgroup: []const u8,
|
||||||
pid: std.os.linux.pid_t,
|
pid: std.os.linux.pid_t,
|
||||||
) !void {
|
) !void {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try std.fmt.bufPrint(&buf, "/sys/fs/cgroup{s}/cgroup.procs", .{cgroup});
|
const path = try std.fmt.bufPrint(&buf, "/sys/fs/cgroup{s}/cgroup.procs", .{cgroup});
|
||||||
const file = try std.fs.cwd().openFile(path, .{ .mode = .write_only });
|
const file = try std.fs.cwd().openFile(path, .{ .mode = .write_only });
|
||||||
defer file.close();
|
defer file.close();
|
||||||
@ -71,7 +71,7 @@ pub fn moveInto(
|
|||||||
/// Use clone3 to have the kernel create a new process with the correct cgroup
|
/// Use clone3 to have the kernel create a new process with the correct cgroup
|
||||||
/// rather than moving the process to the correct cgroup later.
|
/// rather than moving the process to the correct cgroup later.
|
||||||
pub fn cloneInto(cgroup: []const u8) !posix.pid_t {
|
pub fn cloneInto(cgroup: []const u8) !posix.pid_t {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try std.fmt.bufPrintZ(&buf, "/sys/fs/cgroup{s}", .{cgroup});
|
const path = try std.fmt.bufPrintZ(&buf, "/sys/fs/cgroup{s}", .{cgroup});
|
||||||
|
|
||||||
// Get a file descriptor that refers to the cgroup directory in the cgroup
|
// Get a file descriptor that refers to the cgroup directory in the cgroup
|
||||||
@ -133,7 +133,7 @@ pub fn cloneInto(cgroup: []const u8) !posix.pid_t {
|
|||||||
/// than allocating a bunch of copies for an array.
|
/// than allocating a bunch of copies for an array.
|
||||||
pub fn controllers(alloc: Allocator, cgroup: []const u8) ![]const u8 {
|
pub fn controllers(alloc: Allocator, cgroup: []const u8) ![]const u8 {
|
||||||
assert(cgroup[0] == '/');
|
assert(cgroup[0] == '/');
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
|
||||||
// Read the available controllers. These will be space separated.
|
// Read the available controllers. These will be space separated.
|
||||||
const path = try std.fmt.bufPrint(
|
const path = try std.fmt.bufPrint(
|
||||||
@ -165,7 +165,7 @@ pub fn configureControllers(
|
|||||||
v: []const u8,
|
v: []const u8,
|
||||||
) !void {
|
) !void {
|
||||||
assert(cgroup[0] == '/');
|
assert(cgroup[0] == '/');
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
|
||||||
// Read the available controllers. These will be space separated.
|
// Read the available controllers. These will be space separated.
|
||||||
const path = try std.fmt.bufPrint(
|
const path = try std.fmt.bufPrint(
|
||||||
@ -195,7 +195,7 @@ pub fn configureMemoryLimit(cgroup: []const u8, limit: MemoryLimit) !void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Open our file
|
// Open our file
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try std.fmt.bufPrint(
|
const path = try std.fmt.bufPrint(
|
||||||
&buf,
|
&buf,
|
||||||
"/sys/fs/cgroup{s}/{s}",
|
"/sys/fs/cgroup{s}/{s}",
|
||||||
|
@ -24,12 +24,12 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 {
|
|||||||
const sentinel = "terminfo/ghostty.termcap";
|
const sentinel = "terminfo/ghostty.termcap";
|
||||||
|
|
||||||
// Get the path to our running binary
|
// Get the path to our running binary
|
||||||
var exe_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var exe_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
var exe: []const u8 = std.fs.selfExePath(&exe_buf) catch return null;
|
var exe: []const u8 = std.fs.selfExePath(&exe_buf) catch return null;
|
||||||
|
|
||||||
// We have an exe path! Climb the tree looking for the terminfo
|
// We have an exe path! Climb the tree looking for the terminfo
|
||||||
// bundle as we expect it.
|
// bundle as we expect it.
|
||||||
var dir_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
while (std.fs.path.dirname(exe)) |dir| {
|
while (std.fs.path.dirname(exe)) |dir| {
|
||||||
exe = dir;
|
exe = dir;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 {
|
|||||||
/// seems roughly right.
|
/// seems roughly right.
|
||||||
///
|
///
|
||||||
/// "buf" must be large enough to fit base + sub + suffix. This is generally
|
/// "buf" must be large enough to fit base + sub + suffix. This is generally
|
||||||
/// MAX_PATH_BYTES so its not a big deal.
|
/// max_path_bytes so its not a big deal.
|
||||||
pub fn maybeDir(
|
pub fn maybeDir(
|
||||||
buf: []u8,
|
buf: []u8,
|
||||||
base: []const u8,
|
base: []const u8,
|
||||||
|
@ -74,7 +74,7 @@ pub const LoadingImage = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var abs_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var abs_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = posix.realpath(cmd.data, &abs_buf) catch |err| {
|
const path = posix.realpath(cmd.data, &abs_buf) catch |err| {
|
||||||
log.warn("failed to get absolute path: {}", .{err});
|
log.warn("failed to get absolute path: {}", .{err});
|
||||||
return error.InvalidData;
|
return error.InvalidData;
|
||||||
@ -197,7 +197,7 @@ pub const LoadingImage = struct {
|
|||||||
|
|
||||||
// The temporary dir is sometimes a symlink. On macOS for
|
// The temporary dir is sometimes a symlink. On macOS for
|
||||||
// example /tmp is /private/var/...
|
// example /tmp is /private/var/...
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
if (posix.realpath(dir, &buf)) |real_dir| {
|
if (posix.realpath(dir, &buf)) |real_dir| {
|
||||||
if (std.mem.startsWith(u8, path, real_dir)) return true;
|
if (std.mem.startsWith(u8, path, real_dir)) return true;
|
||||||
} else |_| {}
|
} else |_| {}
|
||||||
@ -627,7 +627,7 @@ test "image load: rgb, not compressed, temporary file" {
|
|||||||
.data = data,
|
.data = data,
|
||||||
});
|
});
|
||||||
|
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try tmp_dir.dir.realpath("image.data", &buf);
|
const path = try tmp_dir.dir.realpath("image.data", &buf);
|
||||||
|
|
||||||
var cmd: command.Command = .{
|
var cmd: command.Command = .{
|
||||||
@ -664,7 +664,7 @@ test "image load: rgb, not compressed, regular file" {
|
|||||||
.data = data,
|
.data = data,
|
||||||
});
|
});
|
||||||
|
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try tmp_dir.dir.realpath("image.data", &buf);
|
const path = try tmp_dir.dir.realpath("image.data", &buf);
|
||||||
|
|
||||||
var cmd: command.Command = .{
|
var cmd: command.Command = .{
|
||||||
@ -699,7 +699,7 @@ test "image load: png, not compressed, regular file" {
|
|||||||
.data = data,
|
.data = data,
|
||||||
});
|
});
|
||||||
|
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const path = try tmp_dir.dir.realpath("image.data", &buf);
|
const path = try tmp_dir.dir.realpath("image.data", &buf);
|
||||||
|
|
||||||
var cmd: command.Command = .{
|
var cmd: command.Command = .{
|
||||||
|
@ -589,7 +589,7 @@ const Subprocess = struct {
|
|||||||
|
|
||||||
// Assume that the resources directory is adjacent to the terminfo
|
// Assume that the resources directory is adjacent to the terminfo
|
||||||
// database
|
// database
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const dir = try std.fmt.bufPrint(&buf, "{s}/terminfo", .{
|
const dir = try std.fmt.bufPrint(&buf, "{s}/terminfo", .{
|
||||||
std.fs.path.dirname(base) orelse unreachable,
|
std.fs.path.dirname(base) orelse unreachable,
|
||||||
});
|
});
|
||||||
@ -607,7 +607,7 @@ const Subprocess = struct {
|
|||||||
|
|
||||||
// Add our binary to the path if we can find it.
|
// Add our binary to the path if we can find it.
|
||||||
ghostty_path: {
|
ghostty_path: {
|
||||||
var exe_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var exe_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const exe_bin_path = std.fs.selfExePath(&exe_buf) catch |err| {
|
const exe_bin_path = std.fs.selfExePath(&exe_buf) catch |err| {
|
||||||
log.warn("failed to get ghostty exe path err={}", .{err});
|
log.warn("failed to get ghostty exe path err={}", .{err});
|
||||||
break :ghostty_path;
|
break :ghostty_path;
|
||||||
@ -642,7 +642,7 @@ const Subprocess = struct {
|
|||||||
// Add the man pages from our application bundle to MANPATH.
|
// Add the man pages from our application bundle to MANPATH.
|
||||||
if (comptime builtin.target.isDarwin()) {
|
if (comptime builtin.target.isDarwin()) {
|
||||||
if (cfg.resources_dir) |resources_dir| man: {
|
if (cfg.resources_dir) |resources_dir| man: {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const dir = std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir}) catch |err| {
|
const dir = std.fmt.bufPrint(&buf, "{s}/../man", .{resources_dir}) catch |err| {
|
||||||
log.warn("error building manpath, man pages may not be available err={}", .{err});
|
log.warn("error building manpath, man pages may not be available err={}", .{err});
|
||||||
break :man;
|
break :man;
|
||||||
|
@ -204,7 +204,7 @@ fn setupBash(
|
|||||||
if (!posix and env.get("HISTFILE") == null) {
|
if (!posix and env.get("HISTFILE") == null) {
|
||||||
var home_buf: [1024]u8 = undefined;
|
var home_buf: [1024]u8 = undefined;
|
||||||
if (try homedir.home(&home_buf)) |home| {
|
if (try homedir.home(&home_buf)) |home| {
|
||||||
var histfile_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var histfile_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const histfile = try std.fmt.bufPrint(
|
const histfile = try std.fmt.bufPrint(
|
||||||
&histfile_buf,
|
&histfile_buf,
|
||||||
"{s}/.bash_history",
|
"{s}/.bash_history",
|
||||||
@ -223,7 +223,7 @@ fn setupBash(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set our new ENV to point to our integration script.
|
// Set our new ENV to point to our integration script.
|
||||||
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const integ_dir = try std.fmt.bufPrint(
|
const integ_dir = try std.fmt.bufPrint(
|
||||||
&path_buf,
|
&path_buf,
|
||||||
"{s}/shell-integration/bash/ghostty.bash",
|
"{s}/shell-integration/bash/ghostty.bash",
|
||||||
@ -433,7 +433,7 @@ fn setupXdgDataDirs(
|
|||||||
resource_dir: []const u8,
|
resource_dir: []const u8,
|
||||||
env: *EnvMap,
|
env: *EnvMap,
|
||||||
) !void {
|
) !void {
|
||||||
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
|
|
||||||
// Get our path to the shell integration directory.
|
// Get our path to the shell integration directory.
|
||||||
const integ_dir = try std.fmt.bufPrint(
|
const integ_dir = try std.fmt.bufPrint(
|
||||||
@ -484,7 +484,7 @@ fn setupZsh(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set our new ZDOTDIR
|
// Set our new ZDOTDIR
|
||||||
var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
|
||||||
const integ_dir = try std.fmt.bufPrint(
|
const integ_dir = try std.fmt.bufPrint(
|
||||||
&path_buf,
|
&path_buf,
|
||||||
"{s}/shell-integration/zsh",
|
"{s}/shell-integration/zsh",
|
||||||
|
Reference in New Issue
Block a user