aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/bools.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-23 19:28:08 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-23 19:28:08 -0400
commitfcda36561d668f43bac91ea31cd55cbbd605d330 (patch)
treeeb74c0b17df584af0fd8154422ad924e04c96cc2 /src/stdlib/bools.c
parent414b0c7472c87c5a013029aefef49e2dbc41e700 (diff)
Autoformat everything with clang-format
Diffstat (limited to 'src/stdlib/bools.c')
-rw-r--r--src/stdlib/bools.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/stdlib/bools.c b/src/stdlib/bools.c
index 76de49e0..0231e21b 100644
--- a/src/stdlib/bools.c
+++ b/src/stdlib/bools.c
@@ -11,18 +11,14 @@
#include "text.h"
#include "util.h"
-PUREFUNC public Text_t Bool$as_text(const void *b, bool colorize, const TypeInfo_t *info)
-{
+PUREFUNC public Text_t Bool$as_text(const void *b, bool colorize, const TypeInfo_t *info) {
(void)info;
if (!b) return Text("Bool");
- if (colorize)
- return *(Bool_t*)b ? Text("\x1b[35myes\x1b[m") : Text("\x1b[35mno\x1b[m");
- else
- return *(Bool_t*)b ? Text("yes") : Text("no");
+ if (colorize) return *(Bool_t *)b ? Text("\x1b[35myes\x1b[m") : Text("\x1b[35mno\x1b[m");
+ else return *(Bool_t *)b ? Text("yes") : Text("no");
}
-static bool try_parse(Text_t text, Text_t target, bool target_value, Text_t *remainder, bool *result)
-{
+static bool try_parse(Text_t text, Text_t target, bool target_value, Text_t *remainder, bool *result) {
static const Text_t lang = Text("C");
if (text.length < target.length) return false;
Text_t prefix = Text$to(text, Int$from_int64(target.length));
@@ -36,35 +32,33 @@ static bool try_parse(Text_t text, Text_t target, bool target_value, Text_t *rem
}
}
-PUREFUNC public OptionalBool_t Bool$parse(Text_t text, Text_t *remainder)
-{
+PUREFUNC public OptionalBool_t Bool$parse(Text_t text, Text_t *remainder) {
bool result;
if (try_parse(text, Text("yes"), true, remainder, &result)
|| try_parse(text, Text("true"), true, remainder, &result)
- || try_parse(text, Text("on"), true, remainder, &result)
- || try_parse(text, Text("1"), true, remainder, &result)
+ || try_parse(text, Text("on"), true, remainder, &result) || try_parse(text, Text("1"), true, remainder, &result)
|| try_parse(text, Text("no"), false, remainder, &result)
|| try_parse(text, Text("false"), false, remainder, &result)
|| try_parse(text, Text("off"), false, remainder, &result)
|| try_parse(text, Text("0"), false, remainder, &result))
return result;
- else
- return NONE_BOOL;
+ else return NONE_BOOL;
}
-static bool Bool$is_none(const void *b, const TypeInfo_t *info)
-{
+static bool Bool$is_none(const void *b, const TypeInfo_t *info) {
(void)info;
- return *(OptionalBool_t*)b == NONE_BOOL;
+ return *(OptionalBool_t *)b == NONE_BOOL;
}
-public const TypeInfo_t Bool$info = {
- .size=sizeof(bool),
- .align=__alignof__(bool),
- .metamethods={
- .as_text=Bool$as_text,
- .is_none=Bool$is_none,
- },
+public
+const TypeInfo_t Bool$info = {
+ .size = sizeof(bool),
+ .align = __alignof__(bool),
+ .metamethods =
+ {
+ .as_text = Bool$as_text,
+ .is_none = Bool$is_none,
+ },
};
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0