Skip to content

Commit

Permalink
potion_io_error takes char* now
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Jun 12, 2013
1 parent b88a94e commit 399eac7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions core/file.c
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 3 additions & 1 deletion core/potion.h
Expand Up @@ -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))

Expand Down Expand Up @@ -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)));
Expand Down

0 comments on commit 399eac7

Please sign in to comment.