From 0b64c61fc9c453eb572170e215fe16caf22ee7b5 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan.bastani@ens.fr>
Date: Mon, 2 Jan 2012 22:44:50 +0100
Subject: [PATCH] preprocessor: check size of domain argument

---
 preprocessor/ComputingTasks.cc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc
index 6d321dcd0..55de98bcb 100644
--- a/preprocessor/ComputingTasks.cc
+++ b/preprocessor/ComputingTasks.cc
@@ -1674,6 +1674,7 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct)
       cerr << "ERROR: You must pass the shape option to the prior statement." << endl;
       exit(EXIT_FAILURE);
     }
+
   if (options_list.num_options.find("date1") != options_list.num_options.end() ||
       options_list.num_options.find("date2") != options_list.num_options.end())
     if (options_list.num_options.find("date1") == options_list.num_options.end() ||
@@ -1683,6 +1684,19 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct)
              << "Please inform Dynare Team." << endl;
         exit(EXIT_FAILURE);
       }
+
+  OptionsList::num_options_t::const_iterator it_num = options_list.num_options.find("domain");
+  if (it_num != options_list.num_options.end())
+    {
+      using namespace boost;
+      vector<string> tokenizedDomain;
+      split(tokenizedDomain, it_num->second, is_any_of("[ ]"), token_compress_on);
+      if (tokenizedDomain.size() != 4)
+        {
+          cerr << "ERROR: You must pass exactly two values to the domain option." << endl;
+          exit(EXIT_FAILURE);
+        }
+    }
 }
 
 void
-- 
GitLab