# HG changeset patch # User Christian Kamm # Date 1221425359 -7200 # Node ID 13ff066052269964539a50d3ce7882b070227714 # Parent 8cc0c46064b196464c618f96842f390fe0cefdf3 To prevert source-overwriting in the future, forbit output files with the same name as the source file. diff -r 8cc0c46064b1 -r 13ff06605226 dmd/module.c --- a/dmd/module.c Sun Sep 14 22:08:39 2008 +0200 +++ b/dmd/module.c Sun Sep 14 22:49:19 2008 +0200 @@ -172,6 +172,15 @@ 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()