mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-21 03:34:54 +00:00
Backport: Update zigini (fixes incorrect comment parsing)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
.hash = "122014e73fd712190e109950837b97f6143f02d7e2b6986e1db70b6f4aadb5ba6a0d",
|
||||
},
|
||||
.zigini = .{
|
||||
.url = "https://github.com/Kawaii-Ash/zigini/archive/ce1f322482099db058f5d9fdd05fbfa255d79723.tar.gz",
|
||||
.hash = "1220e7a99793a0430e0a7c0b938cb3c98321035bc297e21cd0e2413cf740b4923b9f",
|
||||
.url = "https://github.com/Kawaii-Ash/zigini/archive/bdb6fd15c6dcedb0c6c2a46381f2d298e2f05fff.tar.gz",
|
||||
.hash = "12203feb831e21bec081af6aae70dd19b127f1627aa55f3415bd1fa476c174a511cc",
|
||||
},
|
||||
},
|
||||
.paths = .{""},
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
// The migrator ensures compatibility with <=0.6.0 configuration files
|
||||
|
||||
const std = @import("std");
|
||||
const ini = @import("zigini");
|
||||
const Save = @import("Save.zig");
|
||||
|
||||
pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniField {
|
||||
var mapped_field = field;
|
||||
|
||||
if (std.mem.eql(u8, field.key, "blank_password")) {
|
||||
mapped_field.key = "clear_password";
|
||||
}
|
||||
|
||||
return mapped_field;
|
||||
}
|
||||
|
||||
pub fn tryMigrateSaveFile(user_buf: *[32]u8, path: []const u8) Save {
|
||||
var save = Save{};
|
||||
|
||||
|
||||
19
src/main.zig
19
src/main.zig
@@ -90,8 +90,7 @@ pub fn main() !void {
|
||||
if (save_path_alloc) allocator.free(save_path);
|
||||
}
|
||||
|
||||
// Compatibility with v0.6.0
|
||||
const mapped_config_fields = .{.{ "blank_password", "clear_password" }};
|
||||
const comment_characters = "#";
|
||||
|
||||
if (res.args.config) |s| {
|
||||
const trailing_slash = if (s[s.len - 1] != '/') "/" else "";
|
||||
@@ -99,31 +98,33 @@ pub fn main() !void {
|
||||
const config_path = try std.fmt.allocPrint(allocator, "{s}{s}config.ini", .{ s, trailing_slash });
|
||||
defer allocator.free(config_path);
|
||||
|
||||
config = config_ini.readFileToStructWithMap(config_path, mapped_config_fields) catch Config{};
|
||||
config = config_ini.readFileToStruct(config_path, comment_characters, migrator.configFieldHandler) catch Config{};
|
||||
|
||||
const lang_path = try std.fmt.allocPrint(allocator, "{s}{s}lang/{s}.ini", .{ s, trailing_slash, config.lang });
|
||||
defer allocator.free(lang_path);
|
||||
|
||||
lang = lang_ini.readFileToStruct(lang_path) catch Lang{};
|
||||
lang = lang_ini.readFileToStruct(lang_path, comment_characters, null) catch Lang{};
|
||||
|
||||
if (config.load) {
|
||||
save_path = try std.fmt.allocPrint(allocator, "{s}{s}save.ini", .{ s, trailing_slash });
|
||||
save_path_alloc = true;
|
||||
|
||||
var user_buf: [32]u8 = undefined;
|
||||
save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file);
|
||||
save = save_ini.readFileToStruct(save_path, comment_characters, null) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file);
|
||||
}
|
||||
} else {
|
||||
config = config_ini.readFileToStructWithMap(build_options.data_directory ++ "/config.ini", mapped_config_fields) catch Config{};
|
||||
const config_path = build_options.data_directory ++ "/config.ini";
|
||||
|
||||
config = config_ini.readFileToStruct(config_path, comment_characters, migrator.configFieldHandler) catch Config{};
|
||||
|
||||
const lang_path = try std.fmt.allocPrint(allocator, "{s}/lang/{s}.ini", .{ build_options.data_directory, config.lang });
|
||||
defer allocator.free(lang_path);
|
||||
|
||||
lang = lang_ini.readFileToStruct(lang_path) catch Lang{};
|
||||
lang = lang_ini.readFileToStruct(lang_path, comment_characters, null) catch Lang{};
|
||||
|
||||
if (config.load) {
|
||||
var user_buf: [32]u8 = undefined;
|
||||
save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file);
|
||||
save = save_ini.readFileToStruct(save_path, comment_characters, null) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +542,7 @@ pub fn main() !void {
|
||||
.user = login.text.items,
|
||||
.session_index = desktop.current,
|
||||
};
|
||||
ini.writeFromStruct(save_data, file.writer(), null) catch break :save_last_settings;
|
||||
ini.writeFromStruct(save_data, file.writer(), null, true, .{}) catch break :save_last_settings;
|
||||
}
|
||||
|
||||
var shared_err = try SharedError.init();
|
||||
|
||||
@@ -150,7 +150,7 @@ pub fn crawl(self: *Desktop, path: []const u8, display_server: DisplayServer) !v
|
||||
const entry_path = try std.fmt.allocPrint(self.allocator, "{s}/{s}", .{ path, item.name });
|
||||
defer self.allocator.free(entry_path);
|
||||
var entry_ini = Ini(Entry).init(self.allocator);
|
||||
_ = try entry_ini.readFileToStruct(entry_path);
|
||||
_ = try entry_ini.readFileToStruct(entry_path, "#", null);
|
||||
errdefer entry_ini.deinit();
|
||||
|
||||
var xdg_session_desktop: []const u8 = undefined;
|
||||
|
||||
Reference in New Issue
Block a user