From c686b931eb275ebb418325bdf8f4d6b88afcac8e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 12 Nov 2017 11:58:02 +0100
Subject: [PATCH] basic stuff working

---
 Common/CommandLine.cpp |  2 +-
 Common/gmsh.cpp        | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index c8bf5ee141..39873e7f89 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1033,11 +1033,11 @@ void GetOptions(int argc, char *argv[])
         else
           Msg::Fatal("Missing number");
       }
-#if defined(HAVE_FLTK)
       else if(!strcmp(argv[i] + 1, "term")) {
         terminal = 1;
         i++;
       }
+#if defined(HAVE_FLTK)
       else if(!strcmp(argv[i] + 1, "dual")) {
         CTX::instance()->mesh.dual = 1;
         i++;
diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp
index 565ffb9eb0..bf8f4e1446 100644
--- a/Common/gmsh.cpp
+++ b/Common/gmsh.cpp
@@ -47,18 +47,24 @@ static void splitOptionName(const std::string &fullName, std::string &category,
                             std::string &name, int &index)
 {
   std::string::size_type d = fullName.find_first_of('.');
+  if(d == std::string::npos){
+    name = fullName;
+    return;
+  }
   category = fullName.substr(0, d);
   std::string::size_type b1 = fullName.find_first_of('[');
   std::string::size_type b2 = fullName.find_last_of(']');
   if(b1 != std::string::npos && b2 != std::string::npos){
-    std::string id = fullName.substr(b1, b2 - b1);
-    name = fullName.substr(d, b1 - d);
+    std::string id = fullName.substr(b1 + 1, b2 - b1 - 1);
+    index = atoi(id.c_str());
+    category = fullName.substr(0, b1);
+    name = fullName.substr(d + 1, b1 - d);
   }
   else{
     index = 0;
-    name = fullName.substr(d);
+    name = fullName.substr(d + 1);
   }
-  Msg::Debug("Decoded option name '%s' . '%s' '[%d]'", category.c_str(),
+  Msg::Debug("Decoded option name '%s' . '%s' (index %d)", category.c_str(),
              name.c_str(), index);
 }
 
-- 
GitLab