From 0c86abee82a66963ec3c46e36c63ba8df89e1fa9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 5 Dec 2009 10:44:04 -0800 Subject: More void * to mem_t * conversion. --- ChangeLog | 12 ++++++++++++ stream.c | 12 ++++++------ utf8.c | 4 ++-- utf8.h | 4 ++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5aa6a7b5..dbc6d93a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-12-05 Kaz Kylheku + + More void * to mem_t * conversion. + + * stream.c (stdio_put_char_callback, stdio_get_char_callback, + stdio_put_string, stdio_put_char, stdio_snarf_line, stdio_get_char): + Convert void * to mem_t *. + + * utf8.c (utf8_encode, utf8_decode): Convert void * to mem_t *. + + * utf8.h (utf8_encode, utf8_decode): Update declarations. + 2009-12-04 Kaz Kylheku Eliminate the void * disease. Generic pointers are of mem_t * diff --git a/stream.c b/stream.c index 6f72964e..1f133315 100644 --- a/stream.c +++ b/stream.c @@ -112,12 +112,12 @@ static val stdio_maybe_write_error(val stream) stream, num(errno), string_utf8(strerror(errno)), nao); } -static int stdio_put_char_callback(int ch, void *f) +static int stdio_put_char_callback(int ch, mem_t *f) { return putc(ch, (FILE *) f) != EOF; } -static int stdio_get_char_callback(void *f) +static int stdio_get_char_callback(mem_t *f) { return getc((FILE *) f); } @@ -129,7 +129,7 @@ static val stdio_put_string(val stream, val str) if (h->f != 0) { const wchar_t *s = c_str(str); while (*s) { - if (!utf8_encode(*s++, stdio_put_char_callback, h->f)) + if (!utf8_encode(*s++, stdio_put_char_callback, (mem_t *) h->f)) return stdio_maybe_write_error(stream); } return t; @@ -140,7 +140,7 @@ static val stdio_put_string(val stream, val str) static val stdio_put_char(val stream, val ch) { struct stdio_handle *h = (struct stdio_handle *) stream->co.handle; - return h->f != 0 && utf8_encode(c_chr(ch), stdio_put_char_callback, h->f) + return h->f != 0 && utf8_encode(c_chr(ch), stdio_put_char_callback, (mem_t *) h->f) ? t : stdio_maybe_write_error(stream); } @@ -152,7 +152,7 @@ static wchar_t *snarf_line(struct stdio_handle *h) wchar_t *buf = 0; for (;;) { - wint_t ch = utf8_decode(&h->ud, stdio_get_char_callback, h->f); + wint_t ch = utf8_decode(&h->ud, stdio_get_char_callback, (mem_t *) h->f); if (ch == WEOF && buf == 0) break; @@ -193,7 +193,7 @@ static val stdio_get_char(val stream) { struct stdio_handle *h = (struct stdio_handle *) stream->co.handle; if (h->f) { - wint_t ch = utf8_decode(&h->ud, stdio_get_char_callback, h->f); + wint_t ch = utf8_decode(&h->ud, stdio_get_char_callback, (mem_t *) h->f); return (ch != WEOF) ? chr(ch) : stdio_maybe_read_error(stream); } return stdio_maybe_read_error(stream); diff --git a/utf8.c b/utf8.c index 96905b0f..efe2afb9 100644 --- a/utf8.c +++ b/utf8.c @@ -184,7 +184,7 @@ char *utf8_dup_to(const wchar_t *wstr) return str; } -int utf8_encode(wchar_t wch, int (*put)(int ch, void *ctx), void *ctx) +int utf8_encode(wchar_t wch, int (*put)(int ch, mem_t *ctx), mem_t *ctx) { if (wch < 0x80) { return put(wch, ctx); @@ -212,7 +212,7 @@ void utf8_decoder_init(utf8_decoder_t *ud) ud->head = ud->tail = ud->back = 0; } -wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(void *ctx), void *ctx) +wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(mem_t *ctx), mem_t *ctx) { for (;;) { int ch; diff --git a/utf8.h b/utf8.h index 159a7e8a..f5c64cde 100644 --- a/utf8.h +++ b/utf8.h @@ -42,9 +42,9 @@ typedef struct utf8_decoder { int buf[8]; } utf8_decoder_t; -int utf8_encode(wchar_t, int (*put)(int ch, void *ctx), void *ctx); +int utf8_encode(wchar_t, int (*put)(int ch, mem_t *ctx), mem_t *ctx); void utf8_decoder_init(utf8_decoder_t *); -wint_t utf8_decode(utf8_decoder_t *,int (*get)(void *ctx), void *ctx); +wint_t utf8_decode(utf8_decoder_t *,int (*get)(mem_t *ctx), mem_t *ctx); FILE *w_fopen(const wchar_t *, const wchar_t *); FILE *w_popen(const wchar_t *, const wchar_t *); -- cgit v1.2.3