summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--filter.c2
-rw-r--r--lib.h18
-rw-r--r--stream.c3
-rw-r--r--txr.c2
-rw-r--r--txr.h2
6 files changed, 39 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 53cca13c..3f7588f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
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.
+
+ * 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.
+
+2011-10-09 Kaz Kylheku <kaz@kylheku.com>
+
Ported to Cygwin.
TODO: there should be some type safety with the new wli macro
diff --git a/filter.c b/filter.c
index 776a9113..3d7050b7 100644
--- a/filter.c
+++ b/filter.c
@@ -128,7 +128,7 @@ val get_filter_trie(val sym)
}
struct filter_pair {
- const wchar_t *key, *value;
+ const wchli_t *key, *value;
};
static val build_filter(struct filter_pair *pair, val compress_p)
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
}
diff --git a/stream.c b/stream.c
index f15e7b2a..84d417a7 100644
--- a/stream.c
+++ b/stream.c
@@ -420,12 +420,13 @@ static val string_out_put_char(val stream, val ch)
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
- return string_out_put_string(stream, auto_str(mini));
}
static struct strm_ops string_out_ops = {
diff --git a/txr.c b/txr.c
index 1f0d7197..fa7cc8ee 100644
--- a/txr.c
+++ b/txr.c
@@ -43,7 +43,7 @@
#include "utf8.h"
#include "txr.h"
-const wchar_t *version = wli("038");
+const wchli_t *version = wli("038");
const wchar_t *progname = L"txr";
const wchar_t *spec_file = L"stdin";
val spec_file_str;
diff --git a/txr.h b/txr.h
index e8e12a67..1b0f23f7 100644
--- a/txr.h
+++ b/txr.h
@@ -32,6 +32,6 @@ extern int opt_gc_debug;
extern int opt_vg_debug;
#endif
extern int opt_derivative_regex;
-extern const wchar_t *version;
+extern const wchli_t *version;
extern const wchar_t *progname;
extern int output_produced;