diff --git a/contrib/05.r7rs/src/file.c b/contrib/05.r7rs/src/file.c index ba68780c..340a5e6d 100644 --- a/contrib/05.r7rs/src/file.c +++ b/contrib/05.r7rs/src/file.c @@ -4,6 +4,8 @@ #include "picrin.h" +#include + PIC_NORETURN static void file_error(pic_state *pic, const char *msg) { diff --git a/etc/mkloader.pl b/etc/mkloader.pl index 3f5bcb41..602a8aae 100755 --- a/etc/mkloader.pl +++ b/etc/mkloader.pl @@ -50,9 +50,9 @@ foreach my $file (@ARGV) { } pic_catch { /* error! */ - fputs("fatal error: failure in loading $dirname/$basename\\n", stderr); - fputs(pic_errmsg(pic), stderr); - abort(); + xfputs(pic, "fatal error: failure in loading $dirname/$basename\\n", xstderr); + xfputs(pic, pic_errmsg(pic), xstderr); + pic_panic(pic, "load error"); } EOL } diff --git a/extlib/benz/file.c b/extlib/benz/file.c index 2a8b2c18..640a6edb 100644 --- a/extlib/benz/file.c +++ b/extlib/benz/file.c @@ -105,7 +105,7 @@ int x_flushbuf(pic_state *pic, int x, xFILE *fp) { } fp->ptr = fp->base; - fp->cnt = BUFSIZ - 1; + fp->cnt = XBUFSIZ - 1; } if (num_written == bufsize) { diff --git a/extlib/benz/include/picrin/file.h b/extlib/benz/include/picrin/file.h index a38c6a25..b07e1a27 100644 --- a/extlib/benz/include/picrin/file.h +++ b/extlib/benz/include/picrin/file.h @@ -5,8 +5,6 @@ extern "C" { #endif -#include - #ifndef EOF # define EOF (-1) #endif diff --git a/extlib/benz/port.c b/extlib/benz/port.c index 5fadc5d7..518b95b2 100644 --- a/extlib/benz/port.c +++ b/extlib/benz/port.c @@ -4,6 +4,8 @@ #include "picrin.h" +#include + pic_value pic_eof_object() { @@ -69,7 +71,10 @@ file_seek(pic_state PIC_UNUSED(*pic), void *cookie, long pos, int whence) { whence = SEEK_END; break; } - return fseek(cookie, pos, whence); + if (fseek(cookie, pos, whence) == 0) { + return ftell(cookie); + } + return -1; } static int