From c77c8862906f1f241f22eebe799cd3e62ae94a19 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 4 Oct 2024 23:17:45 -0400 Subject: [PATCH] Remove prefixes and postfixes from declaration names --- locale/+linux.ha | 18 +++++++++--------- locale/-linux.ha | 14 +++++++------- locale/locale.ha | 16 ++++++++-------- locale/locale_test.ha | 40 ++++++++++++++++++++-------------------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/locale/+linux.ha b/locale/+linux.ha index 0a87069..2649d95 100644 --- a/locale/+linux.ha +++ b/locale/+linux.ha @@ -8,38 +8,38 @@ def locale_conf_path = "/etc/locale.conf"; // Returns the locale to use for character classification and case conversion. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_ctype() locale = get_locale("LC_CTYPE"); // Returns the locale to use for collation order. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_collate() locale = get_locale("LC_COLLATE"); // Returns the locale to use for monetary formatting. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_monetary() locale = get_locale("LC_MONETARY"); // Returns the locale to use for numeric, non-monetary formatting. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_numeric() locale = get_locale("LC_NUMERIC"); // Returns the locale to use for date and time formats. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_time() locale = get_locale("LC_TIME"); // Returns the locale to use for formats of informative and diagnostic messages // and interactive responses. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_messages() locale = get_locale("LC_MESSAGES"); // Returns the locale to use for linguistic translations. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_lang() locale = get_locale("LC_LANG"); // TODO @@ -58,7 +58,7 @@ fn get_locale(var: str) locale = fn get_env_locale(var: str) (locale | errors::invalid) = match (os::getenv(var)) { - case let env: str => return parse_locale(env); + case let env: str => return parse(env); case => return errors::invalid; }; @@ -70,7 +70,7 @@ fn get_locale_conf_entry(var: str) (locale | errors::invalid) = { get_locale_conf(); for (let entry .. locale_conf) { let (key, value) = strings::cut(entry, "="); - if (key == var) return parse_locale(value); + if (key == var) return parse(value); }; return errors::invalid; }; diff --git a/locale/-linux.ha b/locale/-linux.ha index b9eec62..afd3df5 100644 --- a/locale/-linux.ha +++ b/locale/-linux.ha @@ -2,38 +2,38 @@ use errors; // Returns the locale to use for character classification and case conversion. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_ctype() locale = c; // Returns the locale to use for collation order. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_collate() locale = c; // Returns the locale to use for monetary formatting. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_monetary() locale = c; // Returns the locale to use for numeric, non-monetary formatting. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_numeric() locale = c; // Returns the locale to use for date and time formats. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_time() locale = c; // Returns the locale to use for formats of informative and diagnostic messages // and interactive responses. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_messages() locale = c; // Returns the locale to use for linguistic translations. // The memory is statically allocated and must not be free'd. It may be -// overwritten later, so use [[locale_dup]] to extend its lifetime. +// overwritten later, so use [[dup]] to extend its lifetime. export fn get_lang() locale = c; // TODO diff --git a/locale/locale.ha b/locale/locale.ha index 5ae02e2..f514321 100644 --- a/locale/locale.ha +++ b/locale/locale.ha @@ -22,9 +22,9 @@ export def c = locale { // // Where _COUNTRY, .ENCODING, and @MODIFIER may be omitted. The function // returns a [[locale]], or [[errors::invalid]] if the input cannot be parsed. -// All memory is borrowed from the input, so [[locale_finish]] should not be -// used to free it. -export fn parse_locale(in: str) (locale | errors::invalid) = { +// All memory is borrowed from the input, so [[finish]] should not be used to +// free it. +export fn parse(in: str) (locale | errors::invalid) = { let (in, modifier) = strings::rcut(in, "@"); if (strings::compare(in, "") == 0) return void: errors::invalid; let (in, encoding) = strings::rcut(in, "."); @@ -40,7 +40,7 @@ export fn parse_locale(in: str) (locale | errors::invalid) = { }; // Formats a [[locale]]. The caller must free the return value. -export fn format_locale(local: locale) str = { +export fn format(local: locale) str = { let output = strings::dup(local.lang); if (strings::compare(local.country, "") != 0) { let new_output = strings::join("_", output, local.country); @@ -61,14 +61,14 @@ export fn format_locale(local: locale) str = { }; // Checks if two [[locale]]s are equal. -export fn locale_equal(a: locale, b: locale) bool = +export fn equal(a: locale, b: locale) bool = a.lang == b.lang && a.country == b.country && a.encoding == b.encoding && a.modifier == b.modifier; -// Duplicates a [[locale]] structure. Use [[locale_finish]] to get rid of it. -export fn locale_dup(local: locale) locale = locale { +// Duplicates a [[locale]] structure. Use [[finish]] to get rid of it. +export fn dup(local: locale) locale = locale { lang = strings::dup(local.lang), country = strings::dup(local.country), encoding = strings::dup(local.encoding), @@ -76,7 +76,7 @@ export fn locale_dup(local: locale) locale = locale { }; // Frees memory associated with a [[locale]] structure. -export fn locale_finish(local: locale) void = { +export fn finish(local: locale) void = { free(local.lang); free(local.country); free(local.encoding); diff --git a/locale/locale_test.ha b/locale/locale_test.ha index d8afd9d..d954d78 100644 --- a/locale/locale_test.ha +++ b/locale/locale_test.ha @@ -2,8 +2,8 @@ use fmt; use errors; use strings; -@test fn parse_locale_full() void = { - let local = match(parse_locale("lang_COUNTRY.ENCODING@MODIFIER")) { +@test fn parse_full() void = { + let local = match(parse("lang_COUNTRY.ENCODING@MODIFIER")) { case let local: locale => yield local; case => abort("error"); }; @@ -17,8 +17,8 @@ use strings; assert(strings::compare(local.modifier, "MODIFIER") == 0); }; -@test fn parse_locale_sparse_a() void = { - let local = match(parse_locale("lang.ENCODING@MODIFIER")) { +@test fn parse_sparse_a() void = { + let local = match(parse("lang.ENCODING@MODIFIER")) { case let local: locale => yield local; case => abort("error"); }; @@ -32,8 +32,8 @@ use strings; assert(strings::compare(local.modifier, "MODIFIER") == 0); }; -@test fn parse_locale_sparse_b() void = { - let local = match(parse_locale("lang.ENCODING")) { +@test fn parse_sparse_b() void = { + let local = match(parse("lang.ENCODING")) { case let local: locale => yield local; case => abort("error"); }; @@ -47,8 +47,8 @@ use strings; assert(strings::compare(local.modifier, "") == 0); }; -@test fn parse_locale_sparse_c() void = { - let local = match(parse_locale("lang")) { +@test fn parse_sparse_c() void = { + let local = match(parse("lang")) { case let local: locale => yield local; case => abort("error"); }; @@ -62,15 +62,15 @@ use strings; assert(strings::compare(local.modifier, "") == 0); }; -@test fn parse_locale_error() void = { - let local = match(parse_locale("_COUNTRY.ENCODING@MODIFIER")) { +@test fn parse_error() void = { + let local = match(parse("_COUNTRY.ENCODING@MODIFIER")) { case errors::invalid => void; case => abort("error"); }; }; -@test fn format_locale_a() void = { - let string = format_locale(locale { +@test fn format_a() void = { + let string = format(locale { lang = "lang", country = "COUNTRY", encoding = "ENCODING", @@ -81,8 +81,8 @@ use strings; assert(strings::compare(string, "lang_COUNTRY.ENCODING@MODIFIER") == 0); }; -@test fn format_locale_b() void = { - let string = format_locale(locale { +@test fn format_b() void = { + let string = format(locale { lang = "lang", country = "COUNTRY", modifier = "MODIFIER", @@ -93,8 +93,8 @@ use strings; assert(strings::compare(string, "lang_COUNTRY@MODIFIER") == 0); }; -@test fn format_locale_c() void = { - let string = format_locale(locale { +@test fn format_c() void = { + let string = format(locale { lang = "lang", ... }); @@ -103,8 +103,8 @@ use strings; assert(strings::compare(string, "lang") == 0); }; -@test fn locale_equal() void = { - assert(locale_equal(locale { +@test fn equal() void = { + assert(equal(locale { lang = "lang", country = "COUNTRY", encoding = "ENCODING", @@ -116,7 +116,7 @@ use strings; encoding = "ENCODING", modifier = "MODIFIER", })); - assert(!locale_equal(locale { + assert(!equal(locale { lang = "lang", country = "COUNTRY", encoding = "ENCODING", @@ -128,7 +128,7 @@ use strings; encoding = "ENCODING", modifier = "MODIFIER", })); - assert(!locale_equal(locale { + assert(!equal(locale { lang = "lang", encoding = "ENCODING", modifier = "MODIFIER",