diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-23 12:42:10 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-23 12:42:10 -0400 |
| commit | a1978752141835c386012fff15ceb36261f37997 (patch) | |
| tree | 988084e503a9118ceb48b99b8c8cb0b3453f172b /builtins | |
| parent | dceb9255736c69538293ee551272cda1b03a9fd3 (diff) | |
Bugfix for say() when length is >512, and added back the `newline`
optional parameter (default=yes)
Diffstat (limited to 'builtins')
| -rw-r--r-- | builtins/functions.c | 6 | ||||
| -rw-r--r-- | builtins/functions.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/builtins/functions.c b/builtins/functions.c index d71587b9..3eea3c89 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -233,14 +233,16 @@ public void end_test(void *expr, const TypeInfo *type, CORD expected, const char } } -public void say(CORD text) +public void say(CORD text, bool newline) { uint8_t buf[512] = {0}; size_t buf_len = sizeof(buf)-1; const char *str = CORD_to_const_char_star(text); uint8_t *normalized = u8_normalize(UNINORM_NFD, (uint8_t*)str, strlen(str), buf, &buf_len); if (normalized) { - puts((char*)normalized); + write(STDOUT_FILENO, normalized, buf_len); + if (newline) + write(STDOUT_FILENO, "\n", 1); if (normalized != buf) free(normalized); } diff --git a/builtins/functions.h b/builtins/functions.h index ac4fbf81..70266ba6 100644 --- a/builtins/functions.h +++ b/builtins/functions.h @@ -21,7 +21,7 @@ void end_test(void *expr, const TypeInfo *type, CORD expected, const char *filen #define test(expr, type, expected, filename, start, end) {\ start_test(filename, start, end); \ end_test(expr, type, expected, filename, start, end); } -void say(CORD text); +void say(CORD text, bool newline); uint32_t generic_hash(const void *obj, const TypeInfo *type); int32_t generic_compare(const void *x, const void *y, const TypeInfo *type); |
