]> mj.ucw.cz Git - eval.git/commitdiff
The judge IO streams remember the basename of the file instead of its full name
authorMartin Mares <mj@ucw.cz>
Sat, 14 Mar 2009 22:57:02 +0000 (23:57 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 14 Mar 2009 22:57:02 +0000 (23:57 +0100)
judge/io.c

index bfc828ac4242c67952b62a2fdb8cd7e4e6e806d4..39e220f17f00ba53474d05e57f558ca1d5884d41 100644 (file)
 
 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;
 }