file.h is now stdio.h-free

This commit is contained in:
Yuichi Nishiwaki 2015-06-19 05:13:57 +09:00
parent a0d6c5800c
commit 20cb77bbbe
5 changed files with 12 additions and 7 deletions

View File

@ -4,6 +4,8 @@
#include "picrin.h" #include "picrin.h"
#include <stdio.h>
PIC_NORETURN static void PIC_NORETURN static void
file_error(pic_state *pic, const char *msg) file_error(pic_state *pic, const char *msg)
{ {

View File

@ -50,9 +50,9 @@ foreach my $file (@ARGV) {
} }
pic_catch { pic_catch {
/* error! */ /* error! */
fputs("fatal error: failure in loading $dirname/$basename\\n", stderr); xfputs(pic, "fatal error: failure in loading $dirname/$basename\\n", xstderr);
fputs(pic_errmsg(pic), stderr); xfputs(pic, pic_errmsg(pic), xstderr);
abort(); pic_panic(pic, "load error");
} }
EOL EOL
} }

View File

@ -105,7 +105,7 @@ int x_flushbuf(pic_state *pic, int x, xFILE *fp) {
} }
fp->ptr = fp->base; fp->ptr = fp->base;
fp->cnt = BUFSIZ - 1; fp->cnt = XBUFSIZ - 1;
} }
if (num_written == bufsize) { if (num_written == bufsize) {

View File

@ -5,8 +5,6 @@
extern "C" { extern "C" {
#endif #endif
#include <stdio.h>
#ifndef EOF #ifndef EOF
# define EOF (-1) # define EOF (-1)
#endif #endif

View File

@ -4,6 +4,8 @@
#include "picrin.h" #include "picrin.h"
#include <stdio.h>
pic_value pic_value
pic_eof_object() pic_eof_object()
{ {
@ -69,7 +71,10 @@ file_seek(pic_state PIC_UNUSED(*pic), void *cookie, long pos, int whence) {
whence = SEEK_END; whence = SEEK_END;
break; break;
} }
return fseek(cookie, pos, whence); if (fseek(cookie, pos, whence) == 0) {
return ftell(cookie);
}
return -1;
} }
static int static int