config: RepeatableString is null-terminated now

This makes it easier for these values to interface with C APIs
This commit is contained in:
Mitchell Hashimoto
2024-01-03 09:24:15 -08:00
parent 36013dcaa6
commit 98237b112f
3 changed files with 9 additions and 8 deletions

View File

@ -2203,11 +2203,11 @@ pub const RepeatableString = struct {
const Self = @This();
// Allocator for the list is the arena for the parent config.
list: std.ArrayListUnmanaged([]const u8) = .{},
list: std.ArrayListUnmanaged([:0]const u8) = .{},
pub fn parseCLI(self: *Self, alloc: Allocator, input: ?[]const u8) !void {
const value = input orelse return error.ValueRequired;
const copy = try alloc.dupe(u8, value);
const copy = try alloc.dupeZ(u8, value);
try self.list.append(alloc, copy);
}
@ -2284,7 +2284,8 @@ pub const RepeatablePath = struct {
// If it isn't absolute, we need to make it absolute relative
// to the base.
const abs = dir.realpathAlloc(alloc, path) catch |err| {
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const abs = std.os.realpath(path, &buf) catch |err| {
try errors.add(alloc, .{
.message = try std.fmt.allocPrintZ(
alloc,
@ -2300,7 +2301,7 @@ pub const RepeatablePath = struct {
"expanding config-file path relative={s} abs={s}",
.{ path, abs },
);
self.value.list.items[i] = abs;
self.value.list.items[i] = try alloc.dupeZ(u8, abs);
}
}
};

View File

@ -142,7 +142,7 @@ pub const DerivedConfig = struct {
arena: ArenaAllocator,
font_thicken: bool,
font_features: std.ArrayListUnmanaged([]const u8),
font_features: std.ArrayListUnmanaged([:0]const u8),
font_styles: font.Group.StyleStatus,
cursor_color: ?terminal.color.RGB,
cursor_opacity: f64,
@ -154,7 +154,7 @@ pub const DerivedConfig = struct {
selection_foreground: ?terminal.color.RGB,
invert_selection_fg_bg: bool,
min_contrast: f32,
custom_shaders: std.ArrayListUnmanaged([]const u8),
custom_shaders: std.ArrayListUnmanaged([:0]const u8),
custom_shader_animation: bool,
links: link.Set,

View File

@ -239,7 +239,7 @@ pub const DerivedConfig = struct {
arena: ArenaAllocator,
font_thicken: bool,
font_features: std.ArrayListUnmanaged([]const u8),
font_features: std.ArrayListUnmanaged([:0]const u8),
font_styles: font.Group.StyleStatus,
cursor_color: ?terminal.color.RGB,
cursor_text: ?terminal.color.RGB,
@ -251,7 +251,7 @@ pub const DerivedConfig = struct {
selection_foreground: ?terminal.color.RGB,
invert_selection_fg_bg: bool,
min_contrast: f32,
custom_shaders: std.ArrayListUnmanaged([]const u8),
custom_shaders: std.ArrayListUnmanaged([:0]const u8),
custom_shader_animation: bool,
links: link.Set,