summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-09 22:06:39 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-10-09 22:06:39 -0700
commitb9a153ac4e4690112877e4817b840ebdc7427c5a (patch)
tree59410247bec7842e4c7e180b98f80764f40fa5d5 /lib.h
parent889501071aeae561b026fc298e0442d2ef4e433f (diff)
downloadtxr-b9a153ac4e4690112877e4817b840ebdc7427c5a.tar.gz
txr-b9a153ac4e4690112877e4817b840ebdc7427c5a.tar.bz2
txr-b9a153ac4e4690112877e4817b840ebdc7427c5a.zip
Following up to previous commit's TODO.
* filter.c (struct filter_par): wchar_t becomes wchli_t. * lib.h (wchli_t): New type: an incomplete structure type, so that a pointer to this type is incompatible with anything else. (wli): Macro produces const wchli_t * pointer instead of const wchar_t *. (auto_str, static_str): Accept a const wchli_t * instead of const wchar_t *, making it impossible to misuse these functions by passing in a literal. * stream.c (string_out_put_char): These type changes showed this hack to have a bug. Confronted with the need to cast from const wchar_t * to const wchli_t *, it's obvious that the conversion has to be done properly with the + 1 in the one platform case, but not the other. * txr.c (version): Type changed to const wchli_t. * txr.h (version): Declaration updated.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib.h b/lib.h
index 592e187b..26bd1003 100644
--- a/lib.h
+++ b/lib.h
@@ -188,27 +188,29 @@ INLINE type_t type(val obj)
return tag(obj) ? (type_t) tag(obj) : obj->t.type;
}
+typedef struct wli wchli_t;
+
#if LIT_ALIGN < 4
-#define wli(lit) (L ## "\0" lit)
+#define wli(lit) ((const wchli_t *) L ## "\0" lit)
#else
-#define wli(lit) (L ## lit)
+#define wli(lit) ((const wchli_t *) L ## lit)
#endif
-INLINE val auto_str(const wchar_t *str)
+INLINE val auto_str(const wchli_t *str)
{
#if LIT_ALIGN < 4
- return (val) ((cnum) (str + 1) | TAG_LIT);
+ return (val) (((cnum) str + 1) | TAG_LIT);
#else
- return (val) ((cnum) (str) | TAG_LIT);
+ return (val) (((cnum) str) | TAG_LIT);
#endif
}
-INLINE val static_str(const wchar_t *str)
+INLINE val static_str(const wchli_t *str)
{
#if LIT_ALIGN < 4
- return (val) ((cnum) (str + 1) | TAG_LIT);
+ return (val) (((cnum) str + 1) | TAG_LIT);
#else
- return (val) ((cnum) (str) | TAG_LIT);
+ return (val) (((cnum) str) | TAG_LIT);
#endif
}