summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib.h4
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f7588f4..d94cf00b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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
+ unconditionally, since it always points to a null character.
+ We end up skipping past null terminator #1, but safely landing on #2.
+
+2011-10-09 Kaz Kylheku <kaz@kylheku.com>
+
Following up to previous commit's TODO.
* filter.c (struct filter_par): wchar_t becomes wchli_t.
diff --git a/lib.h b/lib.h
index 26bd1003..eb42e96c 100644
--- a/lib.h
+++ b/lib.h
@@ -191,7 +191,7 @@ INLINE type_t type(val obj)
typedef struct wli wchli_t;
#if LIT_ALIGN < 4
-#define wli(lit) ((const wchli_t *) L ## "\0" lit)
+#define wli(lit) ((const wchli_t *) L"\0" L ## lit L"\0")
#else
#define wli(lit) ((const wchli_t *) L ## lit)
#endif
@@ -235,7 +235,7 @@ INLINE val chr(wchar_t ch)
}
#if LIT_ALIGN < 4
-#define lit_noex(strlit) ((obj_t *) ((cnum) (L ## "\0" L ## strlit + 1) | TAG_LIT))
+#define lit_noex(strlit) ((obj_t *) ((cnum) (L"\0" L ## strlit L"\0" + 1) | TAG_LIT))
#else
#define lit_noex(strlit) ((obj_t *) ((cnum) (L ## strlit) | TAG_LIT))
#endif