[Cmake-commits] [cmake-commits] king committed cmInstallCommand.cxx 1.49 1.50

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Feb 24 11:41:06 EST 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv7123/Source

Modified Files:
	cmInstallCommand.cxx 
Log Message:
ENH: Refactor install(DIRECTORY) argument parsing

We previously used several booleans with at most one set to true at a
time to track argument parsing state.  This refactors it to use one
enumeration.


Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.49
retrieving revision 1.50
diff -C 2 -d -r1.49 -r1.50
*** cmInstallCommand.cxx	1 Oct 2008 13:04:27 -0000	1.49
--- cmInstallCommand.cxx	24 Feb 2009 16:41:00 -0000	1.50
***************
*** 851,863 ****
  cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
  {
!   bool doing_dirs = true;
!   bool doing_destination = false;
!   bool doing_pattern = false;
!   bool doing_regex = false;
!   bool doing_permissions_file = false;
!   bool doing_permissions_dir = false;
!   bool doing_permissions_match = false;
!   bool doing_configurations = false;
!   bool doing_component = false;
    bool in_match_mode = false;
    std::vector<std::string> dirs;
--- 851,858 ----
  cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
  {
!   enum Doing { DoingNone, DoingDirs, DoingDestination, DoingPattern,
!                DoingRegex, DoingPermsFile, DoingPermsDir, DoingPermsMatch,
!                DoingConfigurations, DoingComponent };
!   Doing doing = DoingDirs;
    bool in_match_mode = false;
    std::vector<std::string> dirs;
***************
*** 882,906 ****
  
        // Switch to setting the destination property.
!       doing_dirs = false;
!       doing_destination = true;
!       doing_pattern = false;
!       doing_regex = false;
!       doing_permissions_file = false;
!       doing_permissions_dir = false;
!       doing_configurations = false;
!       doing_component = false;
        }
      else if(args[i] == "PATTERN")
        {
        // Switch to a new pattern match rule.
!       doing_dirs = false;
!       doing_destination = false;
!       doing_pattern = true;
!       doing_regex = false;
!       doing_permissions_file = false;
!       doing_permissions_dir = false;
!       doing_permissions_match = false;
!       doing_configurations = false;
!       doing_component = false;
        in_match_mode = true;
        }
--- 877,886 ----
  
        // Switch to setting the destination property.
!       doing = DoingDestination;
        }
      else if(args[i] == "PATTERN")
        {
        // Switch to a new pattern match rule.
!       doing = DoingPattern;
        in_match_mode = true;
        }
***************
*** 908,920 ****
        {
        // Switch to a new regex match rule.
!       doing_dirs = false;
!       doing_destination = false;
!       doing_pattern = false;
!       doing_regex = true;
!       doing_permissions_file = false;
!       doing_permissions_dir = false;
!       doing_permissions_match = false;
!       doing_configurations = false;
!       doing_component = false;
        in_match_mode = true;
        }
--- 888,892 ----
        {
        // Switch to a new regex match rule.
!       doing = DoingRegex;
        in_match_mode = true;
        }
***************
*** 922,926 ****
        {
        // Add this property to the current match rule.
!       if(!in_match_mode || doing_pattern || doing_regex)
          {
          cmOStringStream e;
--- 894,898 ----
        {
        // Add this property to the current match rule.
!       if(!in_match_mode || doing == DoingPattern || doing == DoingRegex)
          {
          cmOStringStream e;
***************
*** 931,935 ****
          }
        literal_args += " EXCLUDE";
!       doing_permissions_match = false;
        }
      else if(args[i] == "PERMISSIONS")
--- 903,907 ----
          }
        literal_args += " EXCLUDE";
!       doing = DoingNone;
        }
      else if(args[i] == "PERMISSIONS")
***************
*** 946,950 ****
        // Switch to setting the current match permissions property.
        literal_args += " PERMISSIONS";
!       doing_permissions_match = true;
        }
      else if(args[i] == "FILE_PERMISSIONS")
--- 918,922 ----
        // Switch to setting the current match permissions property.
        literal_args += " PERMISSIONS";
!       doing = DoingPermsMatch;
        }
      else if(args[i] == "FILE_PERMISSIONS")
***************
*** 960,971 ****
  
        // Switch to setting the file permissions property.
!       doing_dirs = false;
!       doing_destination = false;
!       doing_pattern = false;
!       doing_regex = false;
!       doing_permissions_file = true;
!       doing_permissions_dir = false;
!       doing_configurations = false;
!       doing_component = false;
        }
      else if(args[i] == "DIRECTORY_PERMISSIONS")
--- 932,936 ----
  
        // Switch to setting the file permissions property.
!       doing = DoingPermsFile;
        }
      else if(args[i] == "DIRECTORY_PERMISSIONS")
***************
*** 981,992 ****
  
        // Switch to setting the directory permissions property.
!       doing_dirs = false;
!       doing_destination = false;
!       doing_pattern = false;
!       doing_regex = false;
!       doing_permissions_file = false;
!       doing_permissions_dir = true;
!       doing_configurations = false;
!       doing_component = false;
        }
      else if(args[i] == "USE_SOURCE_PERMISSIONS")
--- 946,950 ----
  
        // Switch to setting the directory permissions property.
!       doing = DoingPermsDir;
        }
      else if(args[i] == "USE_SOURCE_PERMISSIONS")
***************
*** 1002,1014 ****
  
        // Add this option literally.
-       doing_dirs = false;
-       doing_destination = false;
-       doing_pattern = false;
-       doing_regex = false;
-       doing_permissions_file = false;
-       doing_permissions_dir = false;
-       doing_configurations = false;
-       doing_component = false;
        literal_args += " USE_SOURCE_PERMISSIONS";
        }
      else if(args[i] == "FILES_MATCHING")
--- 960,965 ----
  
        // Add this option literally.
        literal_args += " USE_SOURCE_PERMISSIONS";
+       doing = DoingNone;
        }
      else if(args[i] == "FILES_MATCHING")
***************
*** 1024,1037 ****
  
        // Add this option literally.
-       doing_dirs = false;
-       doing_destination = false;
-       doing_pattern = false;
-       doing_regex = false;
-       doing_permissions_file = false;
-       doing_permissions_dir = false;
-       doing_permissions_match = false;
-       doing_configurations = false;
-       doing_component = false;
        literal_args += " FILES_MATCHING";
        }
      else if(args[i] == "CONFIGURATIONS")
--- 975,980 ----
  
        // Add this option literally.
        literal_args += " FILES_MATCHING";
+       doing = DoingNone;
        }
      else if(args[i] == "CONFIGURATIONS")
***************
*** 1047,1058 ****
  
        // Switch to setting the configurations property.
!       doing_dirs = false;
!       doing_destination = false;
!       doing_pattern = false;
!       doing_regex = false;
!       doing_permissions_file = false;
!       doing_permissions_dir = false;
!       doing_configurations = true;
!       doing_component = false;
        }
      else if(args[i] == "COMPONENT")
--- 990,994 ----
  
        // Switch to setting the configurations property.
!       doing = DoingConfigurations;
        }
      else if(args[i] == "COMPONENT")
***************
*** 1068,1081 ****
  
        // Switch to setting the component property.
!       doing_dirs = false;
!       doing_destination = false;
!       doing_pattern = false;
!       doing_regex = false;
!       doing_permissions_file = false;
!       doing_permissions_dir = false;
!       doing_configurations = false;
!       doing_component = true;
        }
!     else if(doing_dirs)
        {
        // Convert this directory to a full path.
--- 1004,1010 ----
  
        // Switch to setting the component property.
!       doing = DoingComponent;
        }
!     else if(doing == DoingDirs)
        {
        // Convert this directory to a full path.
***************
*** 1102,1115 ****
        dirs.push_back(dir);
        }
!     else if(doing_configurations)
        {
        configurations.push_back(args[i]);
        }
!     else if(doing_destination)
        {
        destination = args[i].c_str();
!       doing_destination = false;
        }
!     else if(doing_pattern)
        {
        // Convert the pattern to a regular expression.  Require a
--- 1031,1044 ----
        dirs.push_back(dir);
        }
!     else if(doing == DoingConfigurations)
        {
        configurations.push_back(args[i]);
        }
!     else if(doing == DoingDestination)
        {
        destination = args[i].c_str();
!       doing = DoingNone;
        }
!     else if(doing == DoingPattern)
        {
        // Convert the pattern to a regular expression.  Require a
***************
*** 1122,1128 ****
        literal_args += regex;
        literal_args += "$\"";
!       doing_pattern = false;
        }
!     else if(doing_regex)
        {
        literal_args += " REGEX \"";
--- 1051,1057 ----
        literal_args += regex;
        literal_args += "$\"";
!       doing = DoingNone;
        }
!     else if(doing == DoingRegex)
        {
        literal_args += " REGEX \"";
***************
*** 1136,1147 ****
        literal_args += regex;
        literal_args += "\"";
!       doing_regex = false;
        }
!     else if(doing_component)
        {
        component = args[i];
!       doing_component = false;
        }
!     else if(doing_permissions_file)
       {
       // Check the requested permission.
--- 1065,1076 ----
        literal_args += regex;
        literal_args += "\"";
!       doing = DoingNone;
        }
!     else if(doing == DoingComponent)
        {
        component = args[i];
!       doing = DoingNone;
        }
!     else if(doing == DoingPermsFile)
       {
       // Check the requested permission.
***************
*** 1155,1159 ****
          }
        }
!     else if(doing_permissions_dir)
        {
        // Check the requested permission.
--- 1084,1088 ----
          }
        }
!     else if(doing == DoingPermsDir)
        {
        // Check the requested permission.
***************
*** 1167,1171 ****
          }
        }
!     else if(doing_permissions_match)
        {
        // Check the requested permission.
--- 1096,1100 ----
          }
        }
!     else if(doing == DoingPermsMatch)
        {
        // Check the requested permission.



More information about the Cmake-commits mailing list