Commit b5f2d0d7 authored by sebastien's avatar sebastien
Browse files

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
parent 9a418489
/*
* 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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment