porting over some minor changes to LLT

This commit is contained in:
JeffBezanson 2010-05-02 18:28:53 +00:00
parent b7f08e854f
commit 8d7576250d
8 changed files with 25 additions and 16 deletions

View File

@ -10,7 +10,7 @@ static char hexdig[] = "0123456789abcdef";
display a given number of bytes from a buffer, with the first display a given number of bytes from a buffer, with the first
address label being startoffs 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 offs=0;
size_t i, pos; size_t i, pos;

View File

@ -3,7 +3,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
#include <math.h> #include <math.h>
#include "ieee754.h" #include "ieee754.h"
#include "dtypes.h" #include "dtypes.h"
@ -62,7 +61,7 @@ u_int32_t int64to32hash(u_int64_t key)
#include "lookup3.c" #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; 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); 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; u_int32_t c=0xcafe8881, b=0x4d6a087c;

View File

@ -10,7 +10,7 @@ u_int32_t int64to32hash(u_int64_t key);
#else #else
#define inthash int32hash #define inthash int32hash
#endif #endif
u_int64_t memhash(char* buf, size_t n); u_int64_t memhash(const char* buf, size_t n);
u_int32_t memhash32(char* buf, size_t n); u_int32_t memhash32(const char* buf, size_t n);
#endif #endif

View File

@ -371,7 +371,7 @@ size_t ios_write(ios_t *s, char *data, size_t n)
wrote = _write_grow(s, data, n); wrote = _write_grow(s, data, n);
} }
else if (s->bm == bm_none) { 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; return wrote;
} }
else if (n <= space) { else if (n <= space) {
@ -395,7 +395,7 @@ size_t ios_write(ios_t *s, char *data, size_t n)
s->state = bst_wr; s->state = bst_wr;
ios_flush(s); ios_flush(s);
if (n > MOST_OF(s->maxsize)) { 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 wrote;
} }
return ios_write(s, data, n); return ios_write(s, data, n);
@ -414,17 +414,22 @@ off_t ios_seek(ios_t *s, off_t pos)
return s->bpos; return s->bpos;
} }
// TODO // TODO
return 0;
} }
off_t ios_seek_end(ios_t *s) off_t ios_seek_end(ios_t *s)
{ {
s->_eof = 1; s->_eof = 1;
// TODO
return 0;
} }
off_t ios_skip(ios_t *s, off_t offs) off_t ios_skip(ios_t *s, off_t offs)
{ {
if (offs < 0) if (offs < 0)
s->_eof = 0; s->_eof = 0;
// TODO
return 0;
} }
off_t ios_pos(ios_t *s) off_t ios_pos(ios_t *s)
@ -879,7 +884,6 @@ int ios_peekutf8(ios_t *s, uint32_t *pwc)
int c; int c;
size_t sz; size_t sz;
char c0; char c0;
char buf[8];
c = ios_peekc(s); c = ios_peekc(s);
if (c == IOS_EOF) 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; char *str=NULL;
int c; int c;
@ -944,7 +950,7 @@ int ios_vprintf(ios_t *s, char *format, va_list args)
return c; return c;
} }
int ios_printf(ios_t *s, char *format, ...) int ios_printf(ios_t *s, const char *format, ...)
{ {
va_list args; va_list args;
int c; int c;

View File

@ -1,6 +1,8 @@
#ifndef __IOS_H_ #ifndef __IOS_H_
#define __IOS_H_ #define __IOS_H_
#include <stdarg.h>
// this flag controls when data actually moves out to the underlying I/O // 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 // channel. memory streams are a special case of this where the data
// never moves out. // 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_putint(ios_t *s, int n);
int ios_pututf8(ios_t *s, uint32_t wc); int ios_pututf8(ios_t *s, uint32_t wc);
int ios_putstringz(ios_t *s, char *str, bool_t do_write_nulterm); int ios_putstringz(ios_t *s, char *str, bool_t do_write_nulterm);
int ios_printf(ios_t *s, char *format, ...); int ios_printf(ios_t *s, const char *format, ...);
int ios_vprintf(ios_t *s, char *format, va_list args); 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 */ /* high-level stream functions - input */
int ios_getnum(ios_t *s, char *data, uint32_t type); int ios_getnum(ios_t *s, char *data, uint32_t type);

View File

@ -108,7 +108,7 @@ void timestring(double seconds, char *buffer, size_t len)
#if defined(LINUX) || defined(MACOSX) #if defined(LINUX) || defined(MACOSX)
extern char *strptime(const char *s, const char *format, struct tm *tm); 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 *fmt = "%c"; /* needed to suppress GCC warning */
char *res; char *res;

View File

@ -4,7 +4,7 @@
u_int64_t i64time(); u_int64_t i64time();
double clock_now(); double clock_now();
void timestring(double seconds, char *buffer, size_t len); void timestring(double seconds, char *buffer, size_t len);
double parsetime(char *str); double parsetime(const char *str);
void sleep_ms(int ms); void sleep_ms(int ms);
void timeparts(int32_t *buf, double t); void timeparts(int32_t *buf, double t);

View File

@ -240,6 +240,8 @@ size_t u8_strlen(const char *s)
return count; return count;
} }
int wcwidth(wchar_t c);
size_t u8_strwidth(const char *s) size_t u8_strwidth(const char *s)
{ {
u_int32_t ch; u_int32_t ch;