feat: add Std::Fmt — string formatting module
- C runtime: bux_float_to_string() for float64 → String conversion
- String.bux: add String_FromFloat, extern decl for bux_float_to_string
- library/std/Fmt.bux: Fmt_Fmt1, Fmt_Fmt2, Fmt_Fmt3, Fmt_FmtInt, Fmt_FmtInt2,
Fmt_FmtFloat, Fmt_FmtBool — positional {0}, {1}, {2} placeholders
- Refactor examples to use Fmt:
factorial.bux, fibonacci.bux, process.bux, os_time.bux
This commit is contained in:
@@ -430,6 +430,12 @@ char* bux_str_join2(const char* a, const char* b, const char* sep) {
|
||||
|
||||
/* Simple string format: replace {0}, {1}, ... with string arguments.
|
||||
Returns formatted string. Supports up to 8 arguments. */
|
||||
char* bux_float_to_string(double f) {
|
||||
char* buf = (char*)bux_alloc(64);
|
||||
snprintf(buf, 64, "%g", f);
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* bux_str_format(const char* pattern,
|
||||
const char* a0, const char* a1, const char* a2, const char* a3,
|
||||
const char* a4, const char* a5, const char* a6, const char* a7) {
|
||||
|
||||
Reference in New Issue
Block a user