From be4113bc5fb67c79fc6c105db9a3e0571ebab8c1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 14 Mar 2009 23:57:02 +0100 Subject: [PATCH] The judge IO streams remember the basename of the file instead of its full name --- judge/io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } -- 2.39.2