Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid warnings about renamed options with --help-aliases.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 27 Jul 2017 07:26:55 +0000 (09:26 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 27 Jul 2017 11:54:52 +0000 (13:54 +0200)
src/xbt/config.cpp

index 02512d8..7fbfdf0 100644 (file)
@@ -265,6 +265,7 @@ private:
   xbt_dict_t options;
   // alias -> xbt_dict_elm_t from options:
   xbt_dict_t aliases;
   xbt_dict_t options;
   // alias -> xbt_dict_elm_t from options:
   xbt_dict_t aliases;
+  bool warn_for_aliases;
 
 public:
   Config();
 
 public:
   Config();
@@ -312,9 +313,10 @@ static void xbt_cfgelm_free(void *data)
     delete (simgrid::config::ConfigurationElement*) data;
 }
 
     delete (simgrid::config::ConfigurationElement*) data;
 }
 
-Config::Config() :
-  options(xbt_dict_new_homogeneous(xbt_cfgelm_free)),
-  aliases(xbt_dict_new_homogeneous(nullptr))
+Config::Config()
+    : options(xbt_dict_new_homogeneous(xbt_cfgelm_free))
+    , aliases(xbt_dict_new_homogeneous(nullptr))
+    , warn_for_aliases(true)
 {}
 
 Config::~Config()
 {}
 
 Config::~Config()
@@ -333,7 +335,7 @@ xbt_dictelm_t Config::getDictElement(const char* name)
     return res;
   // The aliases dict stores pointers to the options dictelm:
   res = (xbt_dictelm_t) xbt_dict_get_or_null(aliases, name);
     return res;
   // The aliases dict stores pointers to the options dictelm:
   res = (xbt_dictelm_t) xbt_dict_get_or_null(aliases, name);
-  if (res)
+  if (res && warn_for_aliases)
     XBT_INFO("Option %s has been renamed to %s. Consider switching.", name, res->key);
   return res;
 }
     XBT_INFO("Option %s has been renamed to %s. Consider switching.", name, res->key);
   return res;
 }
@@ -394,8 +396,11 @@ void Config::showAliases()
     names.push_back(name);
   std::sort(begin(names), end(names), [](char* a, char* b) { return strcmp(a, b) < 0; });
 
     names.push_back(name);
   std::sort(begin(names), end(names), [](char* a, char* b) { return strcmp(a, b) < 0; });
 
+  bool old_warn_for_aliases = false;
+  std::swap(warn_for_aliases, old_warn_for_aliases);
   for (auto name : names)
     printf("   %s: %s\n", name, (*this)[name].getDescription().c_str());
   for (auto name : names)
     printf("   %s: %s\n", name, (*this)[name].getDescription().c_str());
+  std::swap(warn_for_aliases, old_warn_for_aliases);
 }
 
 /** @brief Displays the declared options and their description */
 }
 
 /** @brief Displays the declared options and their description */