OLD | NEW |
1 // Copyright (c) 2010 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) |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 command_line_string_.append(L" "); | 424 command_line_string_.append(L" "); |
425 command_line_string_.append(WindowsStyleQuote(value)); | 425 command_line_string_.append(WindowsStyleQuote(value)); |
426 args_.push_back(value); | 426 args_.push_back(value); |
427 } | 427 } |
428 | 428 |
429 void CommandLine::AppendArguments(const CommandLine& other, | 429 void CommandLine::AppendArguments(const CommandLine& other, |
430 bool include_program) { | 430 bool include_program) { |
431 // Verify include_program is used correctly. | 431 // Verify include_program is used correctly. |
432 // Logic could be shorter but this is clearer. | 432 // Logic could be shorter but this is clearer. |
433 DCHECK_EQ(include_program, !other.GetProgram().empty()); | 433 DCHECK_EQ(include_program, !other.GetProgram().empty()); |
434 command_line_string_ += L" " + other.command_line_string_; | 434 if (include_program) { |
| 435 DCHECK(program_.empty()); |
| 436 program_ = other.program_; |
| 437 } |
| 438 |
| 439 if (!command_line_string_.empty()) |
| 440 command_line_string_ += L' '; |
| 441 |
| 442 command_line_string_ += other.command_line_string_; |
| 443 |
435 std::map<std::string, StringType>::const_iterator i; | 444 std::map<std::string, StringType>::const_iterator i; |
436 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) | 445 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) |
437 switches_[i->first] = i->second; | 446 switches_[i->first] = i->second; |
438 } | 447 } |
439 | 448 |
440 void CommandLine::PrependWrapper(const std::wstring& wrapper) { | 449 void CommandLine::PrependWrapper(const std::wstring& wrapper) { |
441 if (wrapper.empty()) | 450 if (wrapper.empty()) |
442 return; | 451 return; |
443 // The wrapper may have embedded arguments (like "gdb --args"). In this case, | 452 // The wrapper may have embedded arguments (like "gdb --args"). In this case, |
444 // we don't pretend to do anything fancy, we just split on spaces. | 453 // we don't pretend to do anything fancy, we just split on spaces. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 531 |
523 // private | 532 // private |
524 CommandLine::CommandLine() { | 533 CommandLine::CommandLine() { |
525 } | 534 } |
526 | 535 |
527 // static | 536 // static |
528 CommandLine* CommandLine::ForCurrentProcessMutable() { | 537 CommandLine* CommandLine::ForCurrentProcessMutable() { |
529 DCHECK(current_process_commandline_); | 538 DCHECK(current_process_commandline_); |
530 return current_process_commandline_; | 539 return current_process_commandline_; |
531 } | 540 } |
OLD | NEW |