]> granicus.if.org Git - llvm/commitdiff
Add new CommaSeparated option modifier
authorChris Lattner <sabre@nondot.org>
Thu, 22 May 2003 20:26:17 +0000 (20:26 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 22 May 2003 20:26:17 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6294 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/CommandLine.cpp
support/lib/Support/CommandLine.cpp

index a46c68c986ea3c5d9333e65433e5f07c8be5427e..a0eca7a8ed4099602d8364d6e9cbff4e13048b58 100644 (file)
@@ -318,6 +318,26 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
       continue;
     }
 
+    // Check to see if this option accepts a comma separated list of values.  If
+    // it does, we have to split up the value into multiple values...
+    if (Handler->getMiscFlags() & CommaSeparated) {
+      std::string Val(Value);
+      std::string::size_type Pos = Val.find(',');
+
+      while (Pos != std::string::npos) {
+        // Process the portion before the comma...
+        ErrorParsing |= ProvideOption(Handler, ArgName,
+                                      std::string(Val.begin(),
+                                                  Val.begin()+Pos).c_str(),
+                                      argc, argv, i);
+        // Erase the portion before the comma, AND the comma...
+        Val.erase(Val.begin(), Val.begin()+Pos+1);
+        Value += Pos+1;  // Increment the original value pointer as well...
+
+        // Check for another comma...
+        Pos = Val.find(',');
+      }
+    }
     ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i);
   }
 
index a46c68c986ea3c5d9333e65433e5f07c8be5427e..a0eca7a8ed4099602d8364d6e9cbff4e13048b58 100644 (file)
@@ -318,6 +318,26 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
       continue;
     }
 
+    // Check to see if this option accepts a comma separated list of values.  If
+    // it does, we have to split up the value into multiple values...
+    if (Handler->getMiscFlags() & CommaSeparated) {
+      std::string Val(Value);
+      std::string::size_type Pos = Val.find(',');
+
+      while (Pos != std::string::npos) {
+        // Process the portion before the comma...
+        ErrorParsing |= ProvideOption(Handler, ArgName,
+                                      std::string(Val.begin(),
+                                                  Val.begin()+Pos).c_str(),
+                                      argc, argv, i);
+        // Erase the portion before the comma, AND the comma...
+        Val.erase(Val.begin(), Val.begin()+Pos+1);
+        Value += Pos+1;  // Increment the original value pointer as well...
+
+        // Check for another comma...
+        Pos = Val.find(',');
+      }
+    }
     ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i);
   }