From 8d7576250d2dbb5e95cba9cfba453e6ae75fab98 Mon Sep 17 00:00:00 2001 From: JeffBezanson Date: Sun, 2 May 2010 18:28:53 +0000 Subject: [PATCH] porting over some minor changes to LLT --- llt/dump.c | 2 +- llt/hashing.c | 5 ++--- llt/hashing.h | 4 ++-- llt/ios.c | 16 +++++++++++----- llt/ios.h | 8 +++++--- llt/timefuncs.c | 2 +- llt/timefuncs.h | 2 +- llt/utf8.c | 2 ++ 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/llt/dump.c b/llt/dump.c index 34b00c1..e50f74a 100644 --- a/llt/dump.c +++ b/llt/dump.c @@ -10,7 +10,7 @@ static char hexdig[] = "0123456789abcdef"; display a given number of bytes from a buffer, with the first address label being startoffs */ -void hexdump(ios_t *dest, char *buffer, size_t len, size_t startoffs) +void hexdump(ios_t *dest, const char *buffer, size_t len, size_t startoffs) { size_t offs=0; size_t i, pos; diff --git a/llt/hashing.c b/llt/hashing.c index 555cab7..098e8c7 100644 --- a/llt/hashing.c +++ b/llt/hashing.c @@ -3,7 +3,6 @@ */ #include #include -#include #include #include "ieee754.h" #include "dtypes.h" @@ -62,7 +61,7 @@ u_int32_t int64to32hash(u_int64_t key) #include "lookup3.c" -u_int64_t memhash(char* buf, size_t n) +u_int64_t memhash(const char* buf, size_t n) { u_int32_t c=0xcafe8881, b=0x4d6a087c; @@ -70,7 +69,7 @@ u_int64_t memhash(char* buf, size_t n) return (u_int64_t)c | (((u_int64_t)b)<<32); } -u_int32_t memhash32(char* buf, size_t n) +u_int32_t memhash32(const char* buf, size_t n) { u_int32_t c=0xcafe8881, b=0x4d6a087c; diff --git a/llt/hashing.h b/llt/hashing.h index e4d4305..9784241 100644 --- a/llt/hashing.h +++ b/llt/hashing.h @@ -10,7 +10,7 @@ u_int32_t int64to32hash(u_int64_t key); #else #define inthash int32hash #endif -u_int64_t memhash(char* buf, size_t n); -u_int32_t memhash32(char* buf, size_t n); +u_int64_t memhash(const char* buf, size_t n); +u_int32_t memhash32(const char* buf, size_t n); #endif diff --git a/llt/ios.c b/llt/ios.c index 7f430e1..73f3eda 100644 --- a/llt/ios.c +++ b/llt/ios.c @@ -371,7 +371,7 @@ size_t ios_write(ios_t *s, char *data, size_t n) wrote = _write_grow(s, data, n); } else if (s->bm == bm_none) { - int result = _os_write_all(s->fd, data, n, &wrote); + _os_write_all(s->fd, data, n, &wrote); return wrote; } else if (n <= space) { @@ -395,7 +395,7 @@ size_t ios_write(ios_t *s, char *data, size_t n) s->state = bst_wr; ios_flush(s); if (n > MOST_OF(s->maxsize)) { - int result = _os_write_all(s->fd, data, n, &wrote); + _os_write_all(s->fd, data, n, &wrote); return wrote; } return ios_write(s, data, n); @@ -414,17 +414,22 @@ off_t ios_seek(ios_t *s, off_t pos) return s->bpos; } // TODO + return 0; } off_t ios_seek_end(ios_t *s) { s->_eof = 1; + // TODO + return 0; } off_t ios_skip(ios_t *s, off_t offs) { if (offs < 0) s->_eof = 0; + // TODO + return 0; } off_t ios_pos(ios_t *s) @@ -879,7 +884,6 @@ int ios_peekutf8(ios_t *s, uint32_t *pwc) int c; size_t sz; char c0; - char buf[8]; c = ios_peekc(s); if (c == IOS_EOF) @@ -913,7 +917,9 @@ void ios_purge(ios_t *s) } } -int ios_vprintf(ios_t *s, char *format, va_list args) +int vasprintf(char **strp, const char *fmt, va_list ap); + +int ios_vprintf(ios_t *s, const char *format, va_list args) { char *str=NULL; int c; @@ -944,7 +950,7 @@ int ios_vprintf(ios_t *s, char *format, va_list args) return c; } -int ios_printf(ios_t *s, char *format, ...) +int ios_printf(ios_t *s, const char *format, ...) { va_list args; int c; diff --git a/llt/ios.h b/llt/ios.h index 35ceef3..1a402b4 100644 --- a/llt/ios.h +++ b/llt/ios.h @@ -1,6 +1,8 @@ #ifndef __IOS_H_ #define __IOS_H_ +#include + // this flag controls when data actually moves out to the underlying I/O // channel. memory streams are a special case of this where the data // never moves out. @@ -103,10 +105,10 @@ int ios_putnum(ios_t *s, char *data, uint32_t type); int ios_putint(ios_t *s, int n); int ios_pututf8(ios_t *s, uint32_t wc); int ios_putstringz(ios_t *s, char *str, bool_t do_write_nulterm); -int ios_printf(ios_t *s, char *format, ...); -int ios_vprintf(ios_t *s, char *format, va_list args); +int ios_printf(ios_t *s, const char *format, ...); +int ios_vprintf(ios_t *s, const char *format, va_list args); -void hexdump(ios_t *dest, char *buffer, size_t len, size_t startoffs); +void hexdump(ios_t *dest, const char *buffer, size_t len, size_t startoffs); /* high-level stream functions - input */ int ios_getnum(ios_t *s, char *data, uint32_t type); diff --git a/llt/timefuncs.c b/llt/timefuncs.c index ae33e20..700dfa9 100644 --- a/llt/timefuncs.c +++ b/llt/timefuncs.c @@ -108,7 +108,7 @@ void timestring(double seconds, char *buffer, size_t len) #if defined(LINUX) || defined(MACOSX) extern char *strptime(const char *s, const char *format, struct tm *tm); -double parsetime(char *str) +double parsetime(const char *str) { char *fmt = "%c"; /* needed to suppress GCC warning */ char *res; diff --git a/llt/timefuncs.h b/llt/timefuncs.h index 1465333..b222572 100644 --- a/llt/timefuncs.h +++ b/llt/timefuncs.h @@ -4,7 +4,7 @@ u_int64_t i64time(); double clock_now(); void timestring(double seconds, char *buffer, size_t len); -double parsetime(char *str); +double parsetime(const char *str); void sleep_ms(int ms); void timeparts(int32_t *buf, double t); diff --git a/llt/utf8.c b/llt/utf8.c index 3102220..a6dd07e 100644 --- a/llt/utf8.c +++ b/llt/utf8.c @@ -240,6 +240,8 @@ size_t u8_strlen(const char *s) return count; } +int wcwidth(wchar_t c); + size_t u8_strwidth(const char *s) { u_int32_t ch;