Desktop entry module compiles

This commit is contained in:
Sasha Koshka 2024-10-12 23:43:07 -04:00
parent e8af5d01d7
commit 19e6aa5259

View File

@ -1,5 +1,6 @@
use bufio;
use encoding::utf8;
use errors;
use io;
use locale;
use memio;
@ -65,6 +66,13 @@ export fn file_parse(in: io::stream) !(file | error | io::error | utf8::invalid)
return fil;
};
fn file_append_group(fil: *file, name: str) void = {
append(fil.groups, group {
name = name,
...
});
};
fn file_append_line(fil: *file, lin: line) void = {
if (len(fil.groups) > 0) {
append(fil.groups[len(fil.groups) - 1].lines, lin);
@ -96,10 +104,10 @@ fn parse_entry(line: str) ((str, str, (locale::locale | void)) | error) = {
let local: (locale::locale | void) = void;
let (key, local_string) = strings::cut(key, "[");
if (local_string != "") {
local_string = locale(strings::rtrim(local, "]"));
local_string = strings::rtrim(local_string, ']');
if (!validate_entry_locale(local_string)) return invalid_entry;
local = match(local_string) {
local = match(locale::parse(local_string)) {
case let local: locale::locale => yield local;
case errors::invalid => return invalid_entry;
};