From 41b7cf934f8af2a9fb622790bd28e2e8742ba380 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 9 Oct 2011 22:50:12 -0700 Subject: 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. --- ChangeLog | 9 +++++++++ lib.h | 4 ++++ stream.c | 15 +++------------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index d94cf00b..5a39964d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-10-09 Kaz Kylheku + + 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 * lib.h (wli, lit_noex): We need null characters on both ends diff --git a/lib.h b/lib.h index eb42e96c..235ab169 100644 --- a/lib.h +++ b/lib.h @@ -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) diff --git a/stream.c b/stream.c index 84d417a7..d9885971 100644 --- a/stream.c +++ b/stream.c @@ -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 = { -- cgit v1.2.3