changeset 598:13ff06605226

To prevert source-overwriting in the future, forbit output files with the same name as the source file.
author Christian Kamm <kamm incasoftware de>
date Sun, 14 Sep 2008 22:49:19 +0200
parents 8cc0c46064b1
children 4435f57956e7
files dmd/module.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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()