Browse Source

[2123] Scope of variables

Michal 'vorner' Vaner 12 years ago
parent
commit
4fc454db42
3 changed files with 3 additions and 4 deletions
  1. 1 1
      src/lib/config/module_spec.cc
  2. 1 1
      src/lib/util/filename.cc
  3. 1 2
      src/lib/util/strutil.cc

+ 1 - 1
src/lib/config/module_spec.cc

@@ -476,9 +476,9 @@ ModuleSpec::validateSpecList(ConstElementPtr spec, ConstElementPtr data,
     typedef std::pair<std::string, ConstElementPtr> maptype;
     typedef std::pair<std::string, ConstElementPtr> maptype;
     
     
     BOOST_FOREACH(maptype m, data->mapValue()) {
     BOOST_FOREACH(maptype m, data->mapValue()) {
-        bool found = false;
         // Ignore 'version' as a config element
         // Ignore 'version' as a config element
         if (m.first.compare("version") != 0) {
         if (m.first.compare("version") != 0) {
+            bool found = false;
             BOOST_FOREACH(ConstElementPtr cur_spec_el, spec->listValue()) {
             BOOST_FOREACH(ConstElementPtr cur_spec_el, spec->listValue()) {
                 if (cur_spec_el->get("item_name")->stringValue().compare(m.first) == 0) {
                 if (cur_spec_el->get("item_name")->stringValue().compare(m.first) == 0) {
                     found = true;
                     found = true;

+ 1 - 1
src/lib/util/filename.cc

@@ -34,9 +34,9 @@ Filename::split(const string& full_name, string& directory,
     string& name, string& extension) const
     string& name, string& extension) const
 {
 {
     directory = name = extension = "";
     directory = name = extension = "";
-    bool dir_present = false;
     if (!full_name.empty()) {
     if (!full_name.empty()) {
 
 
+        bool dir_present = false;
         // Find the directory.
         // Find the directory.
         size_t last_slash = full_name.find_last_of('/');
         size_t last_slash = full_name.find_last_of('/');
         if (last_slash != string::npos) {
         if (last_slash != string::npos) {

+ 1 - 2
src/lib/util/strutil.cc

@@ -39,10 +39,9 @@ normalizeSlash(std::string& name) {
 
 
 string
 string
 trim(const string& instring) {
 trim(const string& instring) {
-    static const char* blanks = " \t\n";
-
     string retstring = "";
     string retstring = "";
     if (!instring.empty()) {
     if (!instring.empty()) {
+        static const char* blanks = " \t\n";
 
 
         // Search for first non-blank character in the string
         // Search for first non-blank character in the string
         size_t first = instring.find_first_not_of(blanks);
         size_t first = instring.find_first_not_of(blanks);