diff --git a/format/desktop_entry/parse.ha b/format/desktop_entry/parse.ha index d734bc0..2c11852 100644 --- a/format/desktop_entry/parse.ha +++ b/format/desktop_entry/parse.ha @@ -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; };