52 lines
1.3 KiB
Hare
52 lines
1.3 KiB
Hare
use locale;
|
|
use strings;
|
|
|
|
// A line in the file, which can be a comment (or a blank line), an entry, or
|
|
// a localized entry.
|
|
export type line = (blank | comment | entry | localized_entry);
|
|
|
|
// A blank line.
|
|
// Specification: §3.1
|
|
export type blank = void;
|
|
|
|
// A comment.
|
|
// Specification: §3.1
|
|
export type comment = str;
|
|
|
|
// A group header.
|
|
// Specification: §3.2
|
|
export type group_header = str;
|
|
|
|
// A key/value pair.
|
|
// Specification: §3.3
|
|
export type entry = (str, str);
|
|
|
|
// A localized key/value pair.
|
|
// Specification: §5
|
|
export type localized_entry = (str, str, locale::locale);
|
|
|
|
// Duplicates an [[entry]]. Use [[entry_finish]] to get rid of it.
|
|
export fn entry_dup(entr: entry) entry = (
|
|
strings::dup(entr.0),
|
|
strings::dup(entr.1));
|
|
|
|
// Frees memory associated with an [[entry]].
|
|
export fn entry_finish(entr: entry) void = {
|
|
free(entr.0);
|
|
free(entr.1);
|
|
};
|
|
|
|
// Duplicates a [[localized_entry]]. Use [[localized_entry_finish]] to get rid
|
|
// of it.
|
|
export fn localized_entry_dup(entr: localized_entry) localized_entry = (
|
|
strings::dup(entr.0),
|
|
strings::dup(entr.1),
|
|
locale::dup(entr.2));
|
|
|
|
// Frees memory associated with an [[localized_entry]].
|
|
export fn localized_entry_finish(entr: localized_entry) void = {
|
|
free(entr.0);
|
|
free(entr.1);
|
|
locale::finish(entr.2);
|
|
};
|