diff --git a/extlib/benz/error.c b/extlib/benz/error.c index d9ea00dd..8882da54 100644 --- a/extlib/benz/error.c +++ b/extlib/benz/error.c @@ -7,14 +7,14 @@ void pic_panic(pic_state PIC_UNUSED(*pic), const char *msg) { + extern void abort(); + #if DEBUG fprintf(stderr, "abort: %s\n", msg); #else (void)msg; #endif PIC_ABORT(pic); - - PIC_UNREACHABLE(); } void diff --git a/extlib/benz/include/picrin/value.h b/extlib/benz/include/picrin/value.h index 42c65295..c821d06f 100644 --- a/extlib/benz/include/picrin/value.h +++ b/extlib/benz/include/picrin/value.h @@ -220,9 +220,8 @@ pic_valid_int(double v) #else PIC_INLINE bool -pic_valid_int(int v) +pic_valid_int(int PIC_UNUSED(v)) { - PIC_UNUSED(v); return true; } #endif diff --git a/extlib/benz/vm.c b/extlib/benz/vm.c index c6cb42b1..0daf0c72 100644 --- a/extlib/benz/vm.c +++ b/extlib/benz/vm.c @@ -109,9 +109,9 @@ pic_get_args(pic_state *pic, const char *format, ...) #if PIC_ENABLE_FLOAT case 'f': { double *f; + pic_value v; f = va_arg(ap, double *); - pic_value v; v = GET_OPERAND(pic, i); switch (pic_type(v)) { @@ -129,10 +129,10 @@ pic_get_args(pic_state *pic, const char *format, ...) case 'F': { double *f; bool *e; + pic_value v; f = va_arg(ap, double *); e = va_arg(ap, bool *); - pic_value v; v = GET_OPERAND(pic, i); switch (pic_type(v)) { @@ -152,10 +152,10 @@ pic_get_args(pic_state *pic, const char *format, ...) case 'I': { int *k; bool *e; + pic_value v; k = va_arg(ap, int *); e = va_arg(ap, bool *); - pic_value v; v = GET_OPERAND(pic, i); switch (pic_type(v)) { @@ -175,9 +175,9 @@ pic_get_args(pic_state *pic, const char *format, ...) #endif case 'i': { int *k; + pic_value v; k = va_arg(ap, int *); - pic_value v; v = GET_OPERAND(pic, i); switch (pic_type(v)) { @@ -196,12 +196,12 @@ pic_get_args(pic_state *pic, const char *format, ...) } case 'k': { size_t *k; - - k = va_arg(ap, size_t *); pic_value v; int x; size_t s; + k = va_arg(ap, size_t *); + v = GET_OPERAND(pic, i); switch (pic_type(v)) { case PIC_TT_INT: diff --git a/extlib/benz/xfile.c b/extlib/benz/xfile.c index d09bf9bf..a071aced 100644 --- a/extlib/benz/xfile.c +++ b/extlib/benz/xfile.c @@ -94,6 +94,8 @@ xFILE *xfunopen(void *cookie, int (*read)(void *, char *, int), int (*write)(voi } int xfclose(xFILE *fp) { + extern void free(void *); /* FIXME */ + xfflush(fp); fp->flag = 0; if (fp->base != fp->buf) @@ -102,6 +104,7 @@ int xfclose(xFILE *fp) { } int x_fillbuf(xFILE *fp) { + extern void *malloc(size_t); /* FIXME */ int bufsize; if ((fp->flag & (X_READ|X_EOF|X_ERR)) != X_READ) @@ -136,6 +139,7 @@ int x_fillbuf(xFILE *fp) { } int x_flushbuf(int x, xFILE *fp) { + extern void *malloc(size_t); /* FIXME */ int num_written=0, bufsize=0; char c = x; @@ -284,14 +288,15 @@ int xungetc(int c, xFILE *fp) { } size_t xfread(void *ptr, size_t size, size_t count, xFILE *fp) { + char *bptr = ptr; long nbytes; int c; nbytes = size * count; while (nbytes > fp->cnt) { - memcpy((char *)ptr, fp->ptr, fp->cnt); + memcpy(bptr, fp->ptr, fp->cnt); fp->ptr += fp->cnt; - ptr += fp->cnt; + bptr += fp->cnt; nbytes -= fp->cnt; if ((c = x_fillbuf(fp)) == EOF) { return (size * count - nbytes) / size; @@ -299,26 +304,27 @@ size_t xfread(void *ptr, size_t size, size_t count, xFILE *fp) { xungetc(c, fp); } } - memcpy((char *)ptr, fp->ptr, nbytes); + memcpy(bptr, fp->ptr, nbytes); fp->ptr += nbytes; fp->cnt -= nbytes; return count; } size_t xfwrite(const void *ptr, size_t size, size_t count, xFILE *fp) { + const char *bptr = ptr; long nbytes; nbytes = size * count; while (nbytes > fp->cnt) { - memcpy(fp->ptr, (char *)ptr, fp->cnt); + memcpy(fp->ptr, bptr, fp->cnt); fp->ptr += fp->cnt; - ptr += fp->cnt; + bptr += fp->cnt; nbytes -= fp->cnt; if (x_flushbuf(EOF, fp) == EOF) { return (size * count - nbytes) / size; } } - memcpy(fp->ptr, (char *)ptr, nbytes); + memcpy(fp->ptr, bptr, nbytes); fp->ptr += nbytes; fp->cnt -= nbytes; return count;