summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--lib.h4
-rw-r--r--stream.c15
3 files changed, 16 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index d94cf00b..5a39964d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
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 = {