From: Martin Mares Date: Sat, 14 Mar 2009 22:57:02 +0000 (+0100) Subject: The judge IO streams remember the basename of the file instead of its full name X-Git-Tag: python-dummy-working~128 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=be4113bc5fb67c79fc6c105db9a3e0571ebab8c1;p=eval.git The judge IO streams remember the basename of the file instead of its full name --- diff --git a/judge/io.c b/judge/io.c index bfc828a..39e220f 100644 --- a/judge/io.c +++ b/judge/io.c @@ -15,12 +15,14 @@ struct stream *sopen_fd(char *name, int fd) { - struct stream *s = xmalloc(sizeof(*s) + BUFSIZE + strlen(name) + 1); + char *slash = strrchr(name, '/'); + char *basename = (slash ? slash+1 : name); + struct stream *s = xmalloc(sizeof(*s) + BUFSIZE + strlen(basename) + 1); s->fd = fd; s->pos = s->stop = s->buf; s->end = s->buf + BUFSIZE; s->name = s->end; - strcpy(s->name, name); + strcpy(s->name, basename); return s; }