OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #elif defined(OS_POSIX) | 10 #elif defined(OS_POSIX) |
11 #include <limits.h> | 11 #include <limits.h> |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // TODO(evan): quoting? | 367 // TODO(evan): quoting? |
368 command_line_string_.append(L" "); | 368 command_line_string_.append(L" "); |
369 command_line_string_.append(value); | 369 command_line_string_.append(value); |
370 loose_values_.push_back(value); | 370 loose_values_.push_back(value); |
371 } | 371 } |
372 | 372 |
373 void CommandLine::AppendArguments(const CommandLine& other, | 373 void CommandLine::AppendArguments(const CommandLine& other, |
374 bool include_program) { | 374 bool include_program) { |
375 // Verify include_program is used correctly. | 375 // Verify include_program is used correctly. |
376 // Logic could be shorter but this is clearer. | 376 // Logic could be shorter but this is clearer. |
377 DCHECK(include_program ? !other.program().empty() : other.program().empty()); | 377 DCHECK_EQ(include_program, !other.GetProgram().empty()); |
378 command_line_string_ += L" " + other.command_line_string_; | 378 command_line_string_ += L" " + other.command_line_string_; |
379 std::map<std::string, StringType>::const_iterator i; | 379 std::map<std::string, StringType>::const_iterator i; |
380 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) | 380 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) |
381 switches_[i->first] = i->second; | 381 switches_[i->first] = i->second; |
382 } | 382 } |
383 | 383 |
384 void CommandLine::PrependWrapper(const std::wstring& wrapper) { | 384 void CommandLine::PrependWrapper(const std::wstring& wrapper) { |
385 // The wrapper may have embedded arguments (like "gdb --args"). In this case, | 385 // The wrapper may have embedded arguments (like "gdb --args"). In this case, |
386 // we don't pretend to do anything fancy, we just split on spaces. | 386 // we don't pretend to do anything fancy, we just split on spaces. |
387 std::vector<std::wstring> wrapper_and_args; | 387 std::vector<std::wstring> wrapper_and_args; |
(...skipping 18 matching lines...) Expand all Loading... |
406 } | 406 } |
407 | 407 |
408 void CommandLine::AppendLooseValue(const std::wstring& value) { | 408 void CommandLine::AppendLooseValue(const std::wstring& value) { |
409 argv_.push_back(base::SysWideToNativeMB(value)); | 409 argv_.push_back(base::SysWideToNativeMB(value)); |
410 } | 410 } |
411 | 411 |
412 void CommandLine::AppendArguments(const CommandLine& other, | 412 void CommandLine::AppendArguments(const CommandLine& other, |
413 bool include_program) { | 413 bool include_program) { |
414 // Verify include_program is used correctly. | 414 // Verify include_program is used correctly. |
415 // Logic could be shorter but this is clearer. | 415 // Logic could be shorter but this is clearer. |
416 DCHECK(include_program ? !other.program().empty() : other.program().empty()); | 416 DCHECK_EQ(include_program, !other.GetProgram().empty()); |
417 | |
418 size_t first_arg = include_program ? 0 : 1; | 417 size_t first_arg = include_program ? 0 : 1; |
419 for (size_t i = first_arg; i < other.argv_.size(); ++i) | 418 for (size_t i = first_arg; i < other.argv_.size(); ++i) |
420 argv_.push_back(other.argv_[i]); | 419 argv_.push_back(other.argv_[i]); |
421 std::map<std::string, StringType>::const_iterator i; | 420 std::map<std::string, StringType>::const_iterator i; |
422 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) | 421 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) |
423 switches_[i->first] = i->second; | 422 switches_[i->first] = i->second; |
424 } | 423 } |
425 | 424 |
426 void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { | 425 void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { |
427 // The wrapper may have embedded arguments (like "gdb --args"). In this case, | 426 // The wrapper may have embedded arguments (like "gdb --args"). In this case, |
428 // we don't pretend to do anything fancy, we just split on spaces. | 427 // we don't pretend to do anything fancy, we just split on spaces. |
429 const std::string wrapper = base::SysWideToNativeMB(wrapper_wide); | 428 const std::string wrapper = base::SysWideToNativeMB(wrapper_wide); |
430 std::vector<std::string> wrapper_and_args; | 429 std::vector<std::string> wrapper_and_args; |
431 SplitString(wrapper, ' ', &wrapper_and_args); | 430 SplitString(wrapper, ' ', &wrapper_and_args); |
432 argv_.insert(argv_.begin(), wrapper_and_args.begin(), wrapper_and_args.end()); | 431 argv_.insert(argv_.begin(), wrapper_and_args.begin(), wrapper_and_args.end()); |
433 } | 432 } |
434 | 433 |
435 #endif | 434 #endif |
OLD | NEW |