From b5f2d0d763539df04e74d81e625cd7e89081785b Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Wed, 21 Jan 2009 12:08:11 +0000
Subject: [PATCH] trunk preprocessor: no longer impose that extension be .dyn
 or .mod

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2360 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 DynareMain.cc | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/DynareMain.cc b/DynareMain.cc
index 6f6add5a..574c4964 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2008 Dynare Team
+ * Copyright (C) 2003-2009 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -23,9 +23,8 @@ using namespace std;
 #include <sstream>
 #include <fstream>
 
+#include <cstdlib>
 #include <cstring>
-#include <cctype>    // for tolower()
-#include <algorithm> // for transform()
 
 #include "macro/MacroDriver.hh"
 
@@ -92,16 +91,11 @@ main(int argc, char** argv)
   cout << "Starting Dynare ..." << endl
        << "Starting preprocessing of the model file ..." << endl;
 
-  // Construct basename (check file extension is correct then remove it)
+  // Construct basename (i.e. remove file extension if there is one)
   string basename = argv[1];
-  string ext = basename.substr(basename.size() - 4);
-  transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int)) tolower); // Convert ext to lowercase
-  if (ext != string(".mod") && ext != string(".dyn"))
-    {
-      cerr << "mod_file extension must be .mod or .dyn!" << endl;
-      exit(EXIT_FAILURE);
-    }
-  basename.erase(basename.size() - 4, 4);
+  size_t pos = basename.find_last_of('.');
+  if (pos != string::npos)
+    basename.erase(pos);
 
   // Do macro processing
   MacroDriver m;
-- 
GitLab