]> mj.ucw.cz Git - eval.git/blobdiff - judge/io.c
Eval: Added STACK_LIMIT.
[eval.git] / 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;
 }