summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-09 22:41:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-10-09 22:41:07 -0700
commit4c7f6f212eca77c2aae3d4bbc9b6be7f683cf260 (patch)
tree2dc0c663922f14ffca2555c882e10b4fc7a8815e /lib.h
parentb9a153ac4e4690112877e4817b840ebdc7427c5a (diff)
downloadtxr-4c7f6f212eca77c2aae3d4bbc9b6be7f683cf260.tar.gz
txr-4c7f6f212eca77c2aae3d4bbc9b6be7f683cf260.tar.bz2
txr-4c7f6f212eca77c2aae3d4bbc9b6be7f683cf260.zip
* 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.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h4
1 files changed, 2 insertions, 2 deletions
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