Minor code cleanups

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29917 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-08-27 22:10:29 +00:00
parent 30967a54f4
commit 232885873f

View File

@ -214,8 +214,8 @@ static bool EatsUnboundedNumberOfValues(const Option *O) {
/// using strdup (), so it is the caller's responsibility to free () /// using strdup (), so it is the caller's responsibility to free ()
/// them later. /// them later.
/// ///
static void ParseCStringVector (std::vector<char *> &output, static void ParseCStringVector(std::vector<char *> &output,
const char *input) { const char *input) {
// Characters which will be treated as token separators: // Characters which will be treated as token separators:
static const char *delims = " \v\f\t\r\n"; static const char *delims = " \v\f\t\r\n";
@ -265,26 +265,25 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar,
assert(envVar && "Environment variable name missing"); assert(envVar && "Environment variable name missing");
// Get the environment variable they want us to parse options out of. // Get the environment variable they want us to parse options out of.
const char *envValue = getenv (envVar); const char *envValue = getenv(envVar);
if (!envValue) if (!envValue)
return; return;
// Get program's "name", which we wouldn't know without the caller // Get program's "name", which we wouldn't know without the caller
// telling us. // telling us.
std::vector<char *> newArgv; std::vector<char*> newArgv;
newArgv.push_back (strdup (progName)); newArgv.push_back(strdup(progName));
// Parse the value of the environment variable into a "command line" // Parse the value of the environment variable into a "command line"
// and hand it off to ParseCommandLineOptions(). // and hand it off to ParseCommandLineOptions().
ParseCStringVector (newArgv, envValue); ParseCStringVector(newArgv, envValue);
int newArgc = newArgv.size (); int newArgc = newArgv.size();
ParseCommandLineOptions (newArgc, &newArgv[0], Overview); ParseCommandLineOptions(newArgc, &newArgv[0], Overview);
// Free all the strdup()ed strings. // Free all the strdup()ed strings.
for (std::vector<char *>::iterator i = newArgv.begin (), e = newArgv.end (); for (std::vector<char*>::iterator i = newArgv.begin(), e = newArgv.end();
i != e; ++i) { i != e; ++i)
free (*i); free (*i);
}
} }
/// LookupOption - Lookup the option specified by the specified option on the /// LookupOption - Lookup the option specified by the specified option on the