aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-28 17:30:04 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-28 17:30:04 -0500
commitfedc4b0ead8f7874120c6e86aaa971a790faea1f (patch)
tree2973f9691b72c97a9cc80fd75c4db8e2e2c59e63
parent469030e9686e81c520c2ecbeab703a07361f51a4 (diff)
parentcfce376f585e0cd0231e95843617f75bd65b6c07 (diff)
Merge branch 'dev' into static-dependencies
-rw-r--r--.clang-format2
-rw-r--r--src/ast.c8
-rw-r--r--src/compile/blocks.c4
-rw-r--r--src/compile/promotions.c4
-rw-r--r--src/compile/text.h8
-rw-r--r--src/environment.c4
-rw-r--r--src/parse/expressions.c4
-rw-r--r--src/parse/utils.c8
-rw-r--r--src/print.h16
-rw-r--r--src/stdlib/bigint.c4
-rw-r--r--src/stdlib/bigint.h24
-rw-r--r--src/stdlib/bools.h24
-rw-r--r--src/stdlib/bytes.c8
-rw-r--r--src/stdlib/bytes.h8
-rw-r--r--src/stdlib/intX.c.h8
-rw-r--r--src/stdlib/intX.h28
-rw-r--r--src/stdlib/lists.c12
-rw-r--r--src/stdlib/numX.c.h20
-rw-r--r--src/stdlib/numX.h24
-rw-r--r--src/stdlib/paths.c16
-rw-r--r--src/stdlib/tables.c29
-rw-r--r--src/stdlib/tables.h2
-rw-r--r--src/stdlib/text.c12
-rw-r--r--src/stdlib/text.h4
-rw-r--r--src/types.c8
25 files changed, 214 insertions, 75 deletions
diff --git a/.clang-format b/.clang-format
index 82e3ce3b..1fabd157 100644
--- a/.clang-format
+++ b/.clang-format
@@ -71,7 +71,7 @@ AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
-AllowShortFunctionsOnASingleLine: All
+AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
diff --git a/src/ast.c b/src/ast.c
index e87ca005..69c55327 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -85,7 +85,9 @@ static Text_t tags_to_sexp(tag_ast_t *tags);
static Text_t optional_sexp(const char *tag, ast_t *ast);
static Text_t optional_type_sexp(const char *tag, type_ast_t *ast);
-static Text_t quoted_text(const char *text) { return Text$quoted(Text$from_str(text), false, Text("\"")); }
+static Text_t quoted_text(const char *text) {
+ return Text$quoted(Text$from_str(text), false, Text("\""));
+}
Text_t ast_list_to_sexp(ast_list_t *asts) {
Text_t c = EMPTY_TEXT;
@@ -281,7 +283,9 @@ Text_t ast_to_sexp(ast_t *ast) {
}
}
-const char *ast_to_sexp_str(ast_t *ast) { return Text$as_c_string(ast_to_sexp(ast)); }
+const char *ast_to_sexp_str(ast_t *ast) {
+ return Text$as_c_string(ast_to_sexp(ast));
+}
OptionalText_t ast_source(ast_t *ast) {
if (ast == NULL || ast->start == NULL || ast->end == NULL) return NONE_TEXT;
diff --git a/src/compile/blocks.c b/src/compile/blocks.c
index 470597a8..87be350a 100644
--- a/src/compile/blocks.c
+++ b/src/compile/blocks.c
@@ -9,7 +9,9 @@
#include "compilation.h"
public
-Text_t compile_block(env_t *env, ast_t *ast) { return Texts("{\n", compile_inline_block(env, ast), "}\n"); }
+Text_t compile_block(env_t *env, ast_t *ast) {
+ return Texts("{\n", compile_inline_block(env, ast), "}\n");
+}
Text_t compile_block_expression(env_t *env, ast_t *ast) {
ast_list_t *stmts = Match(ast, Block)->statements;
diff --git a/src/compile/promotions.c b/src/compile/promotions.c
index 482e5ed0..7a169821 100644
--- a/src/compile/promotions.c
+++ b/src/compile/promotions.c
@@ -8,7 +8,9 @@
#include "../types.h"
#include "compilation.h"
-static Text_t quoted_str(const char *str) { return Text$quoted(Text$from_str(str), false, Text("\"")); }
+static Text_t quoted_str(const char *str) {
+ return Text$quoted(Text$from_str(str), false, Text("\""));
+}
public
bool promote(env_t *env, ast_t *ast, Text_t *code, type_t *actual, type_t *needed) {
diff --git a/src/compile/text.h b/src/compile/text.h
index 510c3ed1..6aefeeb8 100644
--- a/src/compile/text.h
+++ b/src/compile/text.h
@@ -14,5 +14,9 @@ Text_t compile_text(env_t *env, ast_t *ast, Text_t color);
Text_t compile_text_literal(Text_t literal);
Text_t expr_as_text(Text_t expr, type_t *t, Text_t color);
-MACROLIKE Text_t quoted_str(const char *str) { return Text$quoted(Text$from_str(str), false, Text("\"")); }
-MACROLIKE Text_t quoted_text(Text_t text) { return Text$quoted(text, false, Text("\"")); }
+MACROLIKE Text_t quoted_str(const char *str) {
+ return Text$quoted(Text$from_str(str), false, Text("\""));
+}
+MACROLIKE Text_t quoted_text(Text_t text) {
+ return Text$quoted(text, false, Text("\""));
+}
diff --git a/src/environment.c b/src/environment.c
index a53823aa..24d586d2 100644
--- a/src/environment.c
+++ b/src/environment.c
@@ -710,7 +710,9 @@ env_t *namespace_env(env_t *env, const char *namespace_name) {
return ns_env;
}
-PUREFUNC binding_t *get_binding(env_t *env, const char *name) { return Table$str_get(*env->locals, name); }
+PUREFUNC binding_t *get_binding(env_t *env, const char *name) {
+ return Table$str_get(*env->locals, name);
+}
binding_t *get_namespace_binding(env_t *env, ast_t *self, const char *name) {
type_t *self_type = get_type(env, self);
diff --git a/src/parse/expressions.c b/src/parse/expressions.c
index 9cc0aa07..c6a4f940 100644
--- a/src/parse/expressions.c
+++ b/src/parse/expressions.c
@@ -195,7 +195,9 @@ ast_t *parse_term(parse_ctx_t *ctx, const char *pos) {
return term;
}
-ast_t *parse_expr(parse_ctx_t *ctx, const char *pos) { return parse_infix_expr(ctx, pos, 0); }
+ast_t *parse_expr(parse_ctx_t *ctx, const char *pos) {
+ return parse_infix_expr(ctx, pos, 0);
+}
ast_t *parse_extended_expr(parse_ctx_t *ctx, const char *pos) {
ast_t *expr = NULL;
diff --git a/src/parse/utils.c b/src/parse/utils.c
index 26a33e70..bdf59aff 100644
--- a/src/parse/utils.c
+++ b/src/parse/utils.c
@@ -41,7 +41,9 @@ size_t some_not(const char **pos, const char *forbid) {
return len;
}
-size_t spaces(const char **pos) { return some_of(pos, " \t"); }
+size_t spaces(const char **pos) {
+ return some_of(pos, " \t");
+}
void whitespace(parse_ctx_t *ctx, const char **pos) {
while (some_of(pos, " \t\r\n") || comment(ctx, pos))
@@ -93,7 +95,9 @@ const char *get_id(const char **inout) {
return word;
}
-PUREFUNC const char *eol(const char *str) { return str + strcspn(str, "\r\n"); }
+PUREFUNC const char *eol(const char *str) {
+ return str + strcspn(str, "\r\n");
+}
bool comment(parse_ctx_t *ctx, const char **pos) {
if ((*pos)[0] == '#') {
diff --git a/src/print.h b/src/print.h
index 1b9645fa..080c187b 100644
--- a/src/print.h
+++ b/src/print.h
@@ -83,10 +83,18 @@ int _print_double(FILE *f, double x);
int _print_hex(FILE *f, hex_format_t hex);
int _print_hex_double(FILE *f, hex_double_t hex);
int _print_oct(FILE *f, oct_format_t oct);
-PRINT_FN _print_float(FILE *f, float x) { return _print_double(f, (double)x); }
-PRINT_FN _print_pointer(FILE *f, void *p) { return _print_hex(f, hex((uint64_t)p)); }
-PRINT_FN _print_bool(FILE *f, bool b) { return fputs(b ? "yes" : "no", f); }
-PRINT_FN _print_str(FILE *f, const char *s) { return fputs(s ? s : "(null)", f); }
+PRINT_FN _print_float(FILE *f, float x) {
+ return _print_double(f, (double)x);
+}
+PRINT_FN _print_pointer(FILE *f, void *p) {
+ return _print_hex(f, hex((uint64_t)p));
+}
+PRINT_FN _print_bool(FILE *f, bool b) {
+ return fputs(b ? "yes" : "no", f);
+}
+PRINT_FN _print_str(FILE *f, const char *s) {
+ return fputs(s ? s : "(null)", f);
+}
int _print_char(FILE *f, char c);
int _print_quoted(FILE *f, quoted_t quoted);
PRINT_FN _print_string_slice(FILE *f, string_slice_t slice) {
diff --git a/src/stdlib/bigint.c b/src/stdlib/bigint.c
index 4a5b2565..d47dfee8 100644
--- a/src/stdlib/bigint.c
+++ b/src/stdlib/bigint.c
@@ -431,7 +431,9 @@ PUREFUNC Closure_t Int$onward(Int_t first, Int_t step) {
}
public
-Int_t Int$from_str(const char *str) { return Int$parse(Text$from_str(str), NONE_INT, NULL); }
+Int_t Int$from_str(const char *str) {
+ return Int$parse(Text$from_str(str), NONE_INT, NULL);
+}
public
OptionalInt_t Int$parse(Text_t text, OptionalInt_t base, Text_t *remainder) {
diff --git a/src/stdlib/bigint.h b/src/stdlib/bigint.h
index d5bad85f..d7eae403 100644
--- a/src/stdlib/bigint.h
+++ b/src/stdlib/bigint.h
@@ -170,10 +170,22 @@ MACROLIKE PUREFUNC bool Int$is_negative(Int_t x) {
// Int constructors:
PUREFUNC Int_t Int$from_num64(double n, bool truncate);
-MACROLIKE PUREFUNC Int_t Int$from_num32(float n, bool truncate) { return Int$from_num64((double)n, truncate); }
+MACROLIKE PUREFUNC Int_t Int$from_num32(float n, bool truncate) {
+ return Int$from_num64((double)n, truncate);
+}
PUREFUNC Int_t Int$from_int64(int64_t i);
-MACROLIKE CONSTFUNC Int_t Int$from_int32(Int32_t i) { return Int$from_int64((Int32_t)i); }
-MACROLIKE CONSTFUNC Int_t Int$from_int16(Int16_t i) { return I_small(i); }
-MACROLIKE CONSTFUNC Int_t Int$from_int8(Int8_t i) { return I_small(i); }
-MACROLIKE CONSTFUNC Int_t Int$from_byte(Byte_t b) { return I_small(b); }
-MACROLIKE CONSTFUNC Int_t Int$from_bool(Bool_t b) { return I_small(b); }
+MACROLIKE CONSTFUNC Int_t Int$from_int32(Int32_t i) {
+ return Int$from_int64((Int32_t)i);
+}
+MACROLIKE CONSTFUNC Int_t Int$from_int16(Int16_t i) {
+ return I_small(i);
+}
+MACROLIKE CONSTFUNC Int_t Int$from_int8(Int8_t i) {
+ return I_small(i);
+}
+MACROLIKE CONSTFUNC Int_t Int$from_byte(Byte_t b) {
+ return I_small(b);
+}
+MACROLIKE CONSTFUNC Int_t Int$from_bool(Bool_t b) {
+ return I_small(b);
+}
diff --git a/src/stdlib/bools.h b/src/stdlib/bools.h
index 52bd45a8..17ff3681 100644
--- a/src/stdlib/bools.h
+++ b/src/stdlib/bools.h
@@ -13,11 +13,23 @@
PUREFUNC Text_t Bool$as_text(const void *b, bool colorize, const TypeInfo_t *type);
OptionalBool_t Bool$parse(Text_t text, Text_t *remainder);
-MACROLIKE Bool_t Bool$from_int(Int_t i) { return (i.small != 0); }
-MACROLIKE Bool_t Bool$from_int64(Int64_t i) { return (i != 0); }
-MACROLIKE Bool_t Bool$from_int32(Int32_t i) { return (i != 0); }
-MACROLIKE Bool_t Bool$from_int16(Int16_t i) { return (i != 0); }
-MACROLIKE Bool_t Bool$from_int8(Int8_t i) { return (i != 0); }
-MACROLIKE Bool_t Bool$from_byte(uint8_t b) { return (b != 0); }
+MACROLIKE Bool_t Bool$from_int(Int_t i) {
+ return (i.small != 0);
+}
+MACROLIKE Bool_t Bool$from_int64(Int64_t i) {
+ return (i != 0);
+}
+MACROLIKE Bool_t Bool$from_int32(Int32_t i) {
+ return (i != 0);
+}
+MACROLIKE Bool_t Bool$from_int16(Int16_t i) {
+ return (i != 0);
+}
+MACROLIKE Bool_t Bool$from_int8(Int8_t i) {
+ return (i != 0);
+}
+MACROLIKE Bool_t Bool$from_byte(uint8_t b) {
+ return (b != 0);
+}
extern const TypeInfo_t Bool$info;
diff --git a/src/stdlib/bytes.c b/src/stdlib/bytes.c
index 23a7ced8..2b2a6507 100644
--- a/src/stdlib/bytes.c
+++ b/src/stdlib/bytes.c
@@ -31,7 +31,9 @@ PUREFUNC public Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo
}
public
-CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) { return low <= x && x <= high; }
+CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) {
+ return low <= x && x <= high;
+}
public
OptionalByte_t Byte$parse(Text_t text, OptionalInt_t base, Text_t *remainder) {
@@ -68,7 +70,9 @@ public
bool Byte$get_bit(Byte_t x, Int_t bit_index) {
if (Int$compare_value(bit_index, I(1)) < 0) fail("Invalid bit index (expected 1 or higher): ", bit_index);
if (Int$compare_value(bit_index, I(8)) > 0)
- fail("Bit index is too large! There are only 8 bits in a byte, but index is: ", bit_index);
+ fail("Bit index is too large! There are only 8 bits in a byte, but index "
+ "is: ",
+ bit_index);
return ((x & (Byte_t)(1L << (Int64$from_int(bit_index, true) - 1L))) != 0);
}
diff --git a/src/stdlib/bytes.h b/src/stdlib/bytes.h
index 6581f300..b0a1c213 100644
--- a/src/stdlib/bytes.h
+++ b/src/stdlib/bytes.h
@@ -21,8 +21,12 @@ Byte_t Byte$from_int16(int16_t i, bool truncate);
OptionalByte_t Byte$parse(Text_t text, OptionalInt_t base, Text_t *remainder);
Closure_t Byte$to(Byte_t first, Byte_t last, OptionalInt8_t step);
-MACROLIKE Byte_t Byte$from_int8(int8_t i) { return (Byte_t)i; }
-MACROLIKE Byte_t Byte$from_bool(bool b) { return (Byte_t)b; }
+MACROLIKE Byte_t Byte$from_int8(int8_t i) {
+ return (Byte_t)i;
+}
+MACROLIKE Byte_t Byte$from_bool(bool b) {
+ return (Byte_t)b;
+}
CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high);
extern const Byte_t Byte$min;
diff --git a/src/stdlib/intX.c.h b/src/stdlib/intX.c.h
index cba25bae..19f838d7 100644
--- a/src/stdlib/intX.c.h
+++ b/src/stdlib/intX.c.h
@@ -104,7 +104,9 @@ Text_t NAMESPACED(as_text)(const void *i, bool colorize, const TypeInfo_t *info)
return colorize ? Text$concat(Text("\033[35m"), text, Text("\033[m")) : text;
}
public
-Text_t NAMESPACED(value_as_text)(INT_T i) { return _int64_to_text((int64_t)i); }
+Text_t NAMESPACED(value_as_text)(INT_T i) {
+ return _int64_to_text((int64_t)i);
+}
public
PUREFUNC int32_t NAMESPACED(compare)(const void *x, const void *y, const TypeInfo_t *info) {
(void)info;
@@ -120,7 +122,9 @@ CONSTFUNC bool NAMESPACED(is_between)(const INT_T x, const INT_T low, const INT_
return low <= x && x <= high;
}
public
-CONSTFUNC INT_T NAMESPACED(clamped)(INT_T x, INT_T min, INT_T max) { return x < min ? min : (x > max ? max : x); }
+CONSTFUNC INT_T NAMESPACED(clamped)(INT_T x, INT_T min, INT_T max) {
+ return x < min ? min : (x > max ? max : x);
+}
public
Text_t NAMESPACED(hex)(INT_T i, Int_t digits_int, bool uppercase, bool prefix) {
Int_t as_int = Int$from_int64((int64_t)i);
diff --git a/src/stdlib/intX.h b/src/stdlib/intX.h
index e9ecbfa1..3b8a5679 100644
--- a/src/stdlib/intX.h
+++ b/src/stdlib/intX.h
@@ -49,8 +49,12 @@ Closure_t NAMESPACED(onward)(INTX_T first, INTX_T step);
PUREFUNC OPT_T NAMESPACED(parse)(Text_t text, OptionalInt_t base, Text_t *remainder);
CONSTFUNC bool NAMESPACED(is_between)(const INTX_T x, const INTX_T low, const INTX_T high);
CONSTFUNC INTX_T NAMESPACED(clamped)(INTX_T x, INTX_T min, INTX_T max);
-MACROLIKE CONSTFUNC INTX_T NAMESPACED(from_byte)(Byte_t b) { return (INTX_T)b; }
-MACROLIKE CONSTFUNC INTX_T NAMESPACED(from_bool)(Bool_t b) { return (INTX_T)b; }
+MACROLIKE CONSTFUNC INTX_T NAMESPACED(from_byte)(Byte_t b) {
+ return (INTX_T)b;
+}
+MACROLIKE CONSTFUNC INTX_T NAMESPACED(from_bool)(Bool_t b) {
+ return (INTX_T)b;
+}
CONSTFUNC INTX_T NAMESPACED(gcd)(INTX_T x, INTX_T y);
extern const INTX_T NAMESPACED(min), NAMESPACED(max);
extern const TypeInfo_t NAMESPACED(info);
@@ -75,15 +79,25 @@ MACROLIKE INTX_T NAMESPACED(modulo)(INTX_T D, INTX_T d) {
return r;
}
-MACROLIKE INTX_T NAMESPACED(modulo1)(INTX_T D, INTX_T d) { return NAMESPACED(modulo)(D - 1, d) + 1; }
+MACROLIKE INTX_T NAMESPACED(modulo1)(INTX_T D, INTX_T d) {
+ return NAMESPACED(modulo)(D - 1, d) + 1;
+}
-MACROLIKE PUREFUNC INTX_T NAMESPACED(wrapping_plus)(INTX_T x, INTX_T y) { return (INTX_T)((UINTX_T)x + (UINTX_T)y); }
+MACROLIKE PUREFUNC INTX_T NAMESPACED(wrapping_plus)(INTX_T x, INTX_T y) {
+ return (INTX_T)((UINTX_T)x + (UINTX_T)y);
+}
-MACROLIKE PUREFUNC INTX_T NAMESPACED(wrapping_minus)(INTX_T x, INTX_T y) { return (INTX_T)((UINTX_T)x + (UINTX_T)y); }
+MACROLIKE PUREFUNC INTX_T NAMESPACED(wrapping_minus)(INTX_T x, INTX_T y) {
+ return (INTX_T)((UINTX_T)x + (UINTX_T)y);
+}
-MACROLIKE PUREFUNC INTX_T NAMESPACED(unsigned_left_shifted)(INTX_T x, INTX_T y) { return (INTX_T)((UINTX_T)x << y); }
+MACROLIKE PUREFUNC INTX_T NAMESPACED(unsigned_left_shifted)(INTX_T x, INTX_T y) {
+ return (INTX_T)((UINTX_T)x << y);
+}
-MACROLIKE PUREFUNC INTX_T NAMESPACED(unsigned_right_shifted)(INTX_T x, INTX_T y) { return (INTX_T)((UINTX_T)x >> y); }
+MACROLIKE PUREFUNC INTX_T NAMESPACED(unsigned_right_shifted)(INTX_T x, INTX_T y) {
+ return (INTX_T)((UINTX_T)x >> y);
+}
void NAMESPACED(serialize)(const void *obj, FILE *out, Table_t *, const TypeInfo_t *);
void NAMESPACED(deserialize)(FILE *in, void *outval, List_t *, const TypeInfo_t *);
diff --git a/src/stdlib/lists.c b/src/stdlib/lists.c
index 3149cf82..3cc99b17 100644
--- a/src/stdlib/lists.c
+++ b/src/stdlib/lists.c
@@ -441,10 +441,14 @@ List_t List$sample(List_t list, Int_t int_n, List_t weights, OptionalClosure_t r
}
public
-List_t List$from(List_t list, Int_t first) { return List$slice(list, first, I_small(-1)); }
+List_t List$from(List_t list, Int_t first) {
+ return List$slice(list, first, I_small(-1));
+}
public
-List_t List$to(List_t list, Int_t last) { return List$slice(list, I_small(1), last); }
+List_t List$to(List_t list, Int_t last) {
+ return List$slice(list, I_small(1), last);
+}
public
List_t List$by(List_t list, Int_t int_stride, int64_t padded_item_size) {
@@ -555,7 +559,9 @@ bool List$has(List_t list, void *item, const TypeInfo_t *type) {
}
public
-void List$clear(List_t *list) { *list = list->atomic ? EMPTY_ATOMIC_LIST : EMPTY_LIST; }
+void List$clear(List_t *list) {
+ *list = list->atomic ? EMPTY_ATOMIC_LIST : EMPTY_LIST;
+}
public
int32_t List$compare(const void *vx, const void *vy, const TypeInfo_t *type) {
diff --git a/src/stdlib/numX.c.h b/src/stdlib/numX.c.h
index a8ab0de8..2d652ebe 100644
--- a/src/stdlib/numX.c.h
+++ b/src/stdlib/numX.c.h
@@ -68,7 +68,9 @@ PUREFUNC int32_t NAMESPACED(compare)(const void *x, const void *y, const TypeInf
}
#elif NUMX_C_H__BITS == 32
public
-PUREFUNC Text_t NAMESPACED(value_as_text)(NUM_T x) { return Num$value_as_text((double)x); }
+PUREFUNC Text_t NAMESPACED(value_as_text)(NUM_T x) {
+ return Num$value_as_text((double)x);
+}
public
PUREFUNC Text_t NAMESPACED(as_text)(const void *x, bool colorize, const TypeInfo_t *info) {
(void)info;
@@ -185,7 +187,9 @@ CONSTFUNC NUM_T NAMESPACED(mod1)(NUM_T num, NUM_T modulus) {
}
public
-CONSTFUNC NUM_T NAMESPACED(mix)(NUM_T amount, NUM_T x, NUM_T y) { return (SUFFIXED(1.0) - amount) * x + amount * y; }
+CONSTFUNC NUM_T NAMESPACED(mix)(NUM_T amount, NUM_T x, NUM_T y) {
+ return (SUFFIXED(1.0) - amount) * x + amount * y;
+}
public
CONSTFUNC bool NAMESPACED(is_between)(const NUM_T x, const NUM_T low, const NUM_T high) {
@@ -222,11 +226,17 @@ CONSTFUNC bool NAMESPACED(is_none)(const void *n, const TypeInfo_t *info) {
}
public
-CONSTFUNC bool NAMESPACED(isinf)(NUM_T n) { return (fpclassify(n) == FP_INFINITE); }
+CONSTFUNC bool NAMESPACED(isinf)(NUM_T n) {
+ return (fpclassify(n) == FP_INFINITE);
+}
public
-CONSTFUNC bool NAMESPACED(finite)(NUM_T n) { return (fpclassify(n) != FP_INFINITE); }
+CONSTFUNC bool NAMESPACED(finite)(NUM_T n) {
+ return (fpclassify(n) != FP_INFINITE);
+}
public
-CONSTFUNC bool NAMESPACED(isnan)(NUM_T n) { return (fpclassify(n) == FP_NAN); }
+CONSTFUNC bool NAMESPACED(isnan)(NUM_T n) {
+ return (fpclassify(n) == FP_NAN);
+}
public
const TypeInfo_t NAMESPACED(info) = {
diff --git a/src/stdlib/numX.h b/src/stdlib/numX.h
index 210c4cc7..2ff2cc36 100644
--- a/src/stdlib/numX.h
+++ b/src/stdlib/numX.h
@@ -52,17 +52,29 @@ CONSTFUNC bool NAMESPACED(is_between)(const NUM_T x, const NUM_T low, const NUM_
CONSTFUNC NUM_T NAMESPACED(clamped)(NUM_T x, NUM_T low, NUM_T high);
#if NUMX_H__BITS == 64
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_num32)(float n) { return (NUM_T)n; }
+MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_num32)(float n) {
+ return (NUM_T)n;
+}
#elif NUMX_H__BITS == 32
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_num64)(double n) { return (NUM_T)n; }
+MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_num64)(double n) {
+ return (NUM_T)n;
+}
#endif
CONSTFUNC NUM_T NAMESPACED(from_int)(Int_t i, bool truncate);
CONSTFUNC NUM_T NAMESPACED(from_int64)(Int64_t i, bool truncate);
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int32)(Int32_t i) { return (NUM_T)i; }
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int16)(Int16_t i) { return (NUM_T)i; }
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int8)(Int8_t i) { return (NUM_T)i; }
-MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_byte)(Byte_t i) { return (NUM_T)i; }
+MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int32)(Int32_t i) {
+ return (NUM_T)i;
+}
+MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int16)(Int16_t i) {
+ return (NUM_T)i;
+}
+MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_int8)(Int8_t i) {
+ return (NUM_T)i;
+}
+MACROLIKE CONSTFUNC NUM_T NAMESPACED(from_byte)(Byte_t i) {
+ return (NUM_T)i;
+}
extern const TypeInfo_t NAMESPACED(info);
diff --git a/src/stdlib/paths.c b/src/stdlib/paths.c
index 678e143a..0e9a14b9 100644
--- a/src/stdlib/paths.c
+++ b/src/stdlib/paths.c
@@ -99,7 +99,9 @@ Path_t Path$from_str(const char *str) {
}
public
-Path_t Path$from_text(Text_t text) { return Path$from_str(Text$as_c_string(text)); }
+Path_t Path$from_text(Text_t text) {
+ return Path$from_str(Text$as_c_string(text));
+}
public
Path_t Path$expand_home(Path_t path) {
@@ -646,7 +648,9 @@ OptionalPath_t Path$write_unique_bytes(Path_t path, List_t bytes) {
}
public
-OptionalPath_t Path$write_unique(Path_t path, Text_t text) { return Path$write_unique_bytes(path, Text$utf8(text)); }
+OptionalPath_t Path$write_unique(Path_t path, Text_t text) {
+ return Path$write_unique_bytes(path, Text$utf8(text));
+}
public
OptionalPath_t Path$parent(Path_t path) {
@@ -710,7 +714,9 @@ Path_t Path$child(Path_t path, Text_t name) {
}
public
-Path_t Path$sibling(Path_t path, Text_t name) { return Path$child(Path$parent(path), name); }
+Path_t Path$sibling(Path_t path, Text_t name) {
+ return Path$child(Path$parent(path), name);
+}
public
OptionalPath_t Path$with_extension(Path_t path, Text_t extension, bool replace) {
@@ -866,7 +872,9 @@ int Path$print(FILE *f, Path_t path) {
}
public
-const char *Path$as_c_string(Path_t path) { return String(path); }
+const char *Path$as_c_string(Path_t path) {
+ return String(path);
+}
public
Text_t Path$as_text(const void *obj, bool color, const TypeInfo_t *type) {
diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c
index 81cccceb..a89ae85f 100644
--- a/src/stdlib/tables.c
+++ b/src/stdlib/tables.c
@@ -138,7 +138,8 @@ static void Table$set_bucket(Table_t *t, const void *entry, int32_t index, const
bucket->occupied = 1;
bucket->index = index;
bucket->next_bucket = END_OF_CHAIN;
- } else { // Collided with the start of a chain, put the new entry in chain position #2
+ } else { // Collided with the start of a chain, put the new entry in chain
+ // position #2
buckets[t->bucket_info->last_free] =
(bucket_t){.occupied = 1, .index = index, .next_bucket = bucket->next_bucket};
bucket->next_bucket = t->bucket_info->last_free;
@@ -317,7 +318,9 @@ CONSTFUNC public void *Table$entry(Table_t t, int64_t n) {
}
public
-void Table$clear(Table_t *t) { *t = EMPTY_TABLE; }
+void Table$clear(Table_t *t) {
+ *t = EMPTY_TABLE;
+}
public
Table_t Table$sorted(Table_t t, const TypeInfo_t *type) {
@@ -536,7 +539,8 @@ Table_t Table$from_entries(List_t entries, const TypeInfo_t *type) {
// "set intersection" in formal terms
public
Table_t Table$intersection(Table_t a, Table_t b, const TypeInfo_t *type) {
- // Return a table such that t[k]==a[k] for all k such that a.has(k), b.has(k), and a[k]==b[k]
+ // Return a table such that t[k]==a[k] for all k such that a.has(k), b.has(k),
+ // and a[k]==b[k]
Table_t result = EMPTY_TABLE;
const size_t offset = value_offset(type);
for (Table_t *t = &a; t; t = t->fallback) {
@@ -554,8 +558,8 @@ Table_t Table$intersection(Table_t a, Table_t b, const TypeInfo_t *type) {
// "set union" in formal terms
public
Table_t Table$with(Table_t a, Table_t b, const TypeInfo_t *type) {
- // return a table such that t[k]==b[k] for all k such that b.has(k), and t[k]==a[k] for all k such that a.has(k) and
- // not b.has(k)
+ // return a table such that t[k]==b[k] for all k such that b.has(k), and
+ // t[k]==a[k] for all k such that a.has(k) and not b.has(k)
Table_t result = EMPTY_TABLE;
const size_t offset = value_offset(type);
for (Table_t *t = &a; t; t = t->fallback) {
@@ -597,7 +601,8 @@ Table_t Table$difference(Table_t a, Table_t b, const TypeInfo_t *type) {
// "without" is "set difference" in formal terms
public
Table_t Table$without(Table_t a, Table_t b, const TypeInfo_t *type) {
- // Return a table such that t[k]==a[k] for all k such that not b.has(k) or b[k] != a[k]
+ // Return a table such that t[k]==a[k] for all k such that not b.has(k) or
+ // b[k] != a[k]
Table_t result = EMPTY_TABLE;
const size_t offset = value_offset(type);
for (Table_t *t = &a; t; t = t->fallback) {
@@ -656,12 +661,18 @@ void *Table$str_reserve(Table_t *t, const char *key, const void *value) {
}
public
-void Table$str_set(Table_t *t, const char *key, const void *value) { Table$set(t, &key, &value, &CStrToVoidStarTable); }
+void Table$str_set(Table_t *t, const char *key, const void *value) {
+ Table$set(t, &key, &value, &CStrToVoidStarTable);
+}
public
-void Table$str_remove(Table_t *t, const char *key) { return Table$remove(t, &key, &CStrToVoidStarTable); }
+void Table$str_remove(Table_t *t, const char *key) {
+ return Table$remove(t, &key, &CStrToVoidStarTable);
+}
-CONSTFUNC public void *Table$str_entry(Table_t t, int64_t n) { return Table$entry(t, n); }
+CONSTFUNC public void *Table$str_entry(Table_t t, int64_t n) {
+ return Table$entry(t, n);
+}
PUREFUNC public bool Table$is_none(const void *obj, const TypeInfo_t *info) {
(void)info;
diff --git a/src/stdlib/tables.h b/src/stdlib/tables.h
index 93da465e..f3f9d2c7 100644
--- a/src/stdlib/tables.h
+++ b/src/stdlib/tables.h
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <stdint.h>
-#include <string.h>
+#include <string.h> // IWYU pragma: export
#include "datatypes.h"
#include "lists.h"
diff --git a/src/stdlib/text.c b/src/stdlib/text.c
index ce48091a..ccb2510f 100644
--- a/src/stdlib/text.c
+++ b/src/stdlib/text.c
@@ -670,10 +670,14 @@ Text_t Text$slice(Text_t text, Int_t first_int, Int_t last_int) {
}
public
-Text_t Text$from(Text_t text, Int_t first) { return Text$slice(text, first, I_small(-1)); }
+Text_t Text$from(Text_t text, Int_t first) {
+ return Text$slice(text, first, I_small(-1));
+}
public
-Text_t Text$to(Text_t text, Int_t last) { return Text$slice(text, I_small(1), last); }
+Text_t Text$to(Text_t text, Int_t last) {
+ return Text$slice(text, I_small(1), last);
+}
public
Text_t Text$reversed(Text_t text) {
@@ -815,7 +819,9 @@ OptionalText_t Text$from_strn(const char *str, size_t len) {
}
public
-OptionalText_t Text$from_str(const char *str) { return str ? Text$from_strn(str, strlen(str)) : Text(""); }
+OptionalText_t Text$from_str(const char *str) {
+ return str ? Text$from_strn(str, strlen(str)) : Text("");
+}
static void u8_buf_append(Text_t text, Byte_t **buf, int64_t *capacity, int64_t *i) {
switch (text.tag) {
diff --git a/src/stdlib/text.h b/src/stdlib/text.h
index 44b7d736..abf8bd3c 100644
--- a/src/stdlib/text.h
+++ b/src/stdlib/text.h
@@ -33,7 +33,9 @@ static inline Text_t Text_from_str_literal(const char *str) {
return (Text_t){.length = strlen(str), .tag = TEXT_ASCII, .ascii = str};
}
-static inline Text_t Text_from_text(Text_t t) { return t; }
+static inline Text_t Text_from_text(Text_t t) {
+ return t;
+}
#define convert_to_text(x) \
_Generic(x, \
diff --git a/src/types.c b/src/types.c
index ca44479e..3c2347a5 100644
--- a/src/types.c
+++ b/src/types.c
@@ -136,7 +136,9 @@ bool type_is_a(type_t *t, type_t *req) {
return false;
}
-type_t *non_optional(type_t *t) { return t->tag == OptionalType ? Match(t, OptionalType)->type : t; }
+type_t *non_optional(type_t *t) {
+ return t->tag == OptionalType ? Match(t, OptionalType)->type : t;
+}
PUREFUNC type_t *value_type(type_t *t) {
while (t->tag == PointerType)
@@ -457,7 +459,9 @@ PUREFUNC bool can_promote(type_t *actual, type_t *needed) {
return false;
}
-PUREFUNC bool is_int_type(type_t *t) { return t->tag == IntType || t->tag == BigIntType || t->tag == ByteType; }
+PUREFUNC bool is_int_type(type_t *t) {
+ return t->tag == IntType || t->tag == BigIntType || t->tag == ByteType;
+}
PUREFUNC bool is_numeric_type(type_t *t) {
return t->tag == IntType || t->tag == BigIntType || t->tag == NumType || t->tag == ByteType;