diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | lib.h | 4 | ||||
-rw-r--r-- | stream.c | 15 |
3 files changed, 16 insertions, 12 deletions
@@ -1,5 +1,14 @@ 2011-10-09 Kaz Kylheku <kaz@kylheku.com> + One more swing at this with the axe. + + * lib.h (wini, wref): New macros. + + * stream.c (string_out_put_char): Rewritten with macros to eliminate + preprocessor #if test. + +2011-10-09 Kaz Kylheku <kaz@kylheku.com> + * lib.h (wli, lit_noex): We need null characters on both ends so that this hack is correct for null strings. When recovering the wchar_t pointer from a null literal object, we wil increment @@ -192,8 +192,12 @@ typedef struct wli wchli_t; #if LIT_ALIGN < 4 #define wli(lit) ((const wchli_t *) L"\0" L ## lit L"\0") +#define wini(ini) L"\0" L ## ini L"\0" +#define wref(arr) ((arr) + 1) #else #define wli(lit) ((const wchli_t *) L ## lit) +#define wini(ini) L ## ini +#define wref(arr) (arr) #endif INLINE val auto_str(const wchli_t *str) @@ -415,18 +415,9 @@ static val string_out_put_string(val stream, val str) static val string_out_put_char(val stream, val ch) { -#if LIT_ALIGN < 4 - wchar_t mini[3]; - mini[0] = 0; - mini[1] = c_chr(ch); - mini[2] = 0; - return string_out_put_string(stream, auto_str((const wchli_t *) (mini + 1))); -#else - wchar_t mini[2]; - mini[0] = c_chr(ch); - mini[1] = 0; - return string_out_put_string(stream, auto_str((const wchli_t *) mini)); -#endif + wchar_t onech[] = wini(" "); + wref(onech)[0] = c_chr(ch); + return string_out_put_string(stream, auto_str((const wchli_t *) wref(onech))); } static struct strm_ops string_out_ops = { |