diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-09 17:30:22 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-09 17:30:22 -0400 |
| commit | 6abd4e80244a7fa73a7213101b1d61e4df1b6689 (patch) | |
| tree | a15391b7e34ac4fdafda47318bc9650e2f69fa45 | |
| parent | a24e521fa7e793af3f4056c65e5b89bdb74ff492 (diff) | |
Add fail_text() so there isn't a hacky/broken fail() with promotion to
CString
| -rw-r--r-- | environment.c | 2 | ||||
| -rw-r--r-- | stdlib/stdlib.c | 5 | ||||
| -rw-r--r-- | stdlib/stdlib.h | 1 |
3 files changed, 7 insertions, 1 deletions
diff --git a/environment.c b/environment.c index 5c9bbe95..ca33ee49 100644 --- a/environment.c +++ b/environment.c @@ -54,7 +54,7 @@ env_t *new_compilation_unit(CORD libname) .next=new(arg_t, .name="code", .type=Type(IntType, .bits=TYPE_IBITS32), .default_val=FakeAST(InlineCCode, .code="1", .type=Type(IntType, .bits=TYPE_IBITS32)))), .ret=Type(AbortType))}}, - {"fail", {.code="fail", .type=Type(FunctionType, .args=new(arg_t, .name="message", .type=Type(CStringType)), .ret=Type(AbortType))}}, + {"fail", {.code="fail_text", .type=Type(FunctionType, .args=new(arg_t, .name="message", .type=TEXT_TYPE), .ret=Type(AbortType))}}, {"sleep", {.code="sleep_num", .type=Type(FunctionType, .args=new(arg_t, .name="seconds", .type=Type(NumType, .bits=TYPE_NBITS64)), .ret=Type(VoidType))}}, {"now", {.code="Moment$now", .type=Type(FunctionType, .args=NULL, .ret=Type(MomentType))}}, {"USE_COLOR", {.code="USE_COLOR", .type=Type(BoolType)}}, diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c index a2c08ff0..d48255b7 100644 --- a/stdlib/stdlib.c +++ b/stdlib/stdlib.c @@ -531,6 +531,11 @@ public _Noreturn void fail(const char *fmt, ...) _exit(1); } +public _Noreturn void fail_text(Text_t message) +{ + fail("%k", &message); +} + __attribute__((format(printf, 4, 5))) public _Noreturn void fail_source(const char *filename, int64_t start, int64_t end, const char *fmt, ...) { diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 7c9bd7e1..1625dd88 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -25,6 +25,7 @@ void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, int spe _tomo_parse_args(argc, argv, usage, help, sizeof((cli_arg_t[]){__VA_ARGS__})/sizeof(cli_arg_t), (cli_arg_t[]){__VA_ARGS__}) __attribute__((format(printf, 1, 2))) _Noreturn void fail(const char *fmt, ...); +_Noreturn void fail_text(Text_t message); __attribute__((format(printf, 4, 5))) _Noreturn void fail_source(const char *filename, int64_t start, int64_t end, const char *fmt, ...); Text_t builtin_last_err(); |
