diff --git a/core/file.c b/core/file.c index ba82f137..555de288 100644 --- a/core/file.c +++ b/core/file.c @@ -31,8 +31,8 @@ typedef vPN(File) pn_file; -PN potion_io_error(Potion *P, PN msg) { - return potion_error(P, potion_str_format(P, "Error %s: %s", PN_STR_PTR(msg), strerror(errno)), +PN potion_io_error(Potion *P, const char *msg) { + return potion_error(P, potion_str_format(P, "Error %s: %s", msg, strerror(errno)), 0, 0, 0); } @@ -62,7 +62,7 @@ PN potion_file_new(Potion *P, PN cl, PN self, PN path, PN modestr) { return PN_NIL; } if ((fd = open(PN_STR_PTR(path), mode, 0755)) == -1) - return potion_io_error(P, PN_STR("open")); + return potion_io_error(P, "open"); ((struct PNFile *)self)->fd = fd; ((struct PNFile *)self)->path = path; ((struct PNFile *)self)->mode = mode; @@ -106,7 +106,7 @@ PN potion_file_read(Potion *P, PN cl, pn_file self, PN n) { char buf[n]; int r = read(self->fd, buf, n); if (r == -1) { - return potion_io_error(P, PN_STR("read")); + return potion_io_error(P, "read"); //perror("read"); // TODO: error //return PN_NUM(-1); @@ -148,7 +148,7 @@ PN potion_file_write(Potion *P, PN cl, pn_file self, PN obj) { } int r = write(self->fd, ptr, len); if (r == -1) - return potion_io_error(P, PN_STR("write")); + return potion_io_error(P, "write"); return PN_NUM(r); } diff --git a/core/potion.h b/core/potion.h index c4c38b98..9c2e43c2 100644 --- a/core/potion.h +++ b/core/potion.h @@ -194,6 +194,8 @@ struct PNVtable; #define PN_PROTO(x) ((struct PNProto *)(x)) #define PN_FUNC(f, s) potion_closure_new(P, (PN_F)f, potion_sig(P, s), 0) #define PN_DEREF(x) ((struct PNWeakRef *)(x))->data +#define PN_DATA(x) (PN)((struct PNData *)(x))->data +#define PN_DATA_t(x,t) (t)((struct PNData *)(x))->data #define PN_TOUCH(x) potion_gc_update(P, (PN)(x)) #define PN_ALIGN(o, x) (((((o) - 1) / (x)) + 1) * (x)) @@ -717,7 +719,7 @@ void potion_destroy(Potion *); PN potion_error(Potion *, PN, long, long, PN); void potion_fatal(char *); void potion_allocation_error(void); -PN potion_io_error(Potion *, PN); +PN potion_io_error(Potion *, const char *); PN potion_type_error(Potion *, PN); void potion_syntax_error(Potion *, const char *, ...) __attribute__ ((format (printf, 2, 3)));