summaryrefslogtreecommitdiffstats
path: root/base/command_line.cc
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-12 01:14:37 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-12 01:14:37 +0000
commit1a48f315b0ca5c26c4446070edfb5842ed06c8c7 (patch)
tree5049df6b1a7ffe7da8ef72996a313622c286d4f2 /base/command_line.cc
parent59202e06966c69bcde5ea89241a5816e716017cc (diff)
downloadchromium_src-1a48f315b0ca5c26c4446070edfb5842ed06c8c7.zip
chromium_src-1a48f315b0ca5c26c4446070edfb5842ed06c8c7.tar.gz
chromium_src-1a48f315b0ca5c26c4446070edfb5842ed06c8c7.tar.bz2
Get rid of the command-line hacks for posix platforms.
(They didn't work at all on Linux anyway.) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line.cc')
-rw-r--r--base/command_line.cc38
1 files changed, 17 insertions, 21 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index 57d1b12..c5b24d8 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -41,16 +41,6 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
-extern "C" {
-#if defined(OS_MACOSX)
-extern const char** NXArgv;
-extern int NXArgc;
-#elif defined(OS_LINUX)
-extern const char** __libc_argv;
-extern int __libc_argc;
-#endif
-} // extern "C"
-
using namespace std;
// Since we use a lazy match, make sure that longer versions (like L"--")
@@ -58,7 +48,7 @@ using namespace std;
#if defined(OS_WIN)
const wchar_t* const CommandLine::kSwitchPrefixes[] = {L"--", L"-", L"/"};
#elif defined(OS_POSIX)
-// POSIX shells don't use slash as a switch since they mark absolute paths
+// Unixes don't use slash as a switch.
const wchar_t* const CommandLine::kSwitchPrefixes[] = {L"--", L"-"};
#endif
@@ -90,13 +80,9 @@ class CommandLine::Data {
Data() {
Init(GetCommandLineW());
}
-#elif defined(OS_MACOSX)
- Data() {
- Init(NXArgc, NXArgv);
- }
-#elif defined(OS_LINUX)
+#elif defined(OS_POSIX)
Data() {
- Init(__gnuc_argc, __gnuc_argv);
+ // Owner must call Init().
}
#endif
@@ -105,7 +91,7 @@ class CommandLine::Data {
Init(command_line);
}
#elif defined(OS_POSIX)
- Data(const int argc, const char* argv[]) {
+ Data(const int argc, char** argv) {
Init(argc, argv);
}
#endif
@@ -142,8 +128,10 @@ class CommandLine::Data {
if (args)
LocalFree(args);
}
-#elif defined(OS_POSIX) // Does the actual parsing of the command line.
- void Init(int argc, const char* argv[]) {
+
+#elif defined(OS_POSIX)
+ // Does the actual parsing of the command line.
+ void Init(int argc, char** argv) {
if (argc < 1)
return;
program_ = base::SysNativeMBToWide(argv[0]);
@@ -226,6 +214,9 @@ class CommandLine::Data {
CommandLine::CommandLine()
: we_own_data_(false), // The Singleton class will manage it for us.
data_(Singleton<Data>::get()) {
+ DCHECK(!data_->command_line_string().empty()) <<
+ "You must call CommandLine::SetArgcArgv before making any CommandLine "
+ "calls.";
}
#if defined(OS_WIN)
@@ -234,7 +225,7 @@ CommandLine::CommandLine(const wstring& command_line)
data_(new Data(command_line)) {
}
#elif defined(OS_POSIX)
-CommandLine::CommandLine(const int argc, const char* argv[])
+CommandLine::CommandLine(const int argc, char** argv)
: we_own_data_(true),
data_(new Data(argc, argv)) {
}
@@ -245,6 +236,11 @@ CommandLine::~CommandLine() {
delete data_;
}
+// static
+void CommandLine::SetArgcArgv(int argc, char** argv) {
+ Singleton<Data>::get()->Init(argc, argv);
+}
+
bool CommandLine::HasSwitch(const wstring& switch_string) const {
wstring lowercased_switch(switch_string);
Lowercase(&lowercased_switch);