From 431bc19d2fa2782d172079d5b62167eabf6192e8 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sun, 14 Sep 2008 22:49:19 +0200 Subject: [PATCH] To prevert source-overwriting in the future, forbit output files with the same name as the source file. --- dmd/module.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dmd/module.c b/dmd/module.c index 25dbb47f..003b2471 100644 --- a/dmd/module.c +++ b/dmd/module.c @@ -172,6 +172,15 @@ void Module::buildTargetFiles() objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext); docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext); hdrfile = Module::buildFilePath(global.params.hdrname, global.params.hdrdir, global.hdr_ext); + + // safety check: never allow obj, doc or hdr file to have the source file's name + if(stricmp(FileName::name(objfile->name->str), FileName::name((char*)this->arg)) == 0 || + stricmp(FileName::name(docfile->name->str), FileName::name((char*)this->arg)) == 0 || + stricmp(FileName::name(hdrfile->name->str), FileName::name((char*)this->arg)) == 0) + { + error("Object-, ddoc-, and header- output files with the same name as the source file are forbidden"); + fatal(); + } } void Module::deleteObjFile()