Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: base/command_line.cc

Issue 4928002: Changing the installer switches from wchar_t[] to char[].... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/command_line_unittest.cc » ('j') | base/command_line_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 30 matching lines...) Expand all
475 void CommandLine::AppendArgNative(const std::string& value) { 484 void CommandLine::AppendArgNative(const std::string& value) {
476 DCHECK(IsStringUTF8(value)); 485 DCHECK(IsStringUTF8(value));
477 argv_.push_back(value); 486 argv_.push_back(value);
478 } 487 }
479 488
480 void CommandLine::AppendArguments(const CommandLine& other, 489 void CommandLine::AppendArguments(const CommandLine& other,
481 bool include_program) { 490 bool include_program) {
482 // Verify include_program is used correctly. 491 // Verify include_program is used correctly.
483 // Logic could be shorter but this is clearer. 492 // Logic could be shorter but this is clearer.
484 DCHECK_EQ(include_program, !other.GetProgram().empty()); 493 DCHECK_EQ(include_program, !other.GetProgram().empty());
485 size_t first_arg = include_program ? 0 : 1; 494
486 for (size_t i = first_arg; i < other.argv_.size(); ++i) 495 if (include_program)
496 argv_[0] = other.argv_[0];
497
498 // Skip the first arg when copying since it's the program but push all
499 // arguments to our arg vector.
500 for (size_t i = 1; i < other.argv_.size(); ++i)
487 argv_.push_back(other.argv_[i]); 501 argv_.push_back(other.argv_[i]);
502
488 std::map<std::string, StringType>::const_iterator i; 503 std::map<std::string, StringType>::const_iterator i;
489 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) 504 for (i = other.switches_.begin(); i != other.switches_.end(); ++i)
490 switches_[i->first] = i->second; 505 switches_[i->first] = i->second;
491 } 506 }
492 507
493 void CommandLine::PrependWrapper(const std::string& wrapper) { 508 void CommandLine::PrependWrapper(const std::string& wrapper) {
494 // The wrapper may have embedded arguments (like "gdb --args"). In this case, 509 // The wrapper may have embedded arguments (like "gdb --args"). In this case,
495 // we don't pretend to do anything fancy, we just split on spaces. 510 // we don't pretend to do anything fancy, we just split on spaces.
496 std::vector<std::string> wrapper_and_args; 511 std::vector<std::string> wrapper_and_args;
497 base::SplitString(wrapper, ' ', &wrapper_and_args); 512 base::SplitString(wrapper, ' ', &wrapper_and_args);
(...skipping 24 matching lines...) Expand all
522 537
523 // private 538 // private
524 CommandLine::CommandLine() { 539 CommandLine::CommandLine() {
525 } 540 }
526 541
527 // static 542 // static
528 CommandLine* CommandLine::ForCurrentProcessMutable() { 543 CommandLine* CommandLine::ForCurrentProcessMutable() {
529 DCHECK(current_process_commandline_); 544 DCHECK(current_process_commandline_);
530 return current_process_commandline_; 545 return current_process_commandline_;
531 } 546 }
OLDNEW
« no previous file with comments | « no previous file | base/command_line_unittest.cc » ('j') | base/command_line_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698