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

Side by Side Diff: runtime/bin/process_win.cc

Issue 9701061: Change quoting in Process implementation on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months 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 | tests/standalone/src/io/ProcessCheckArgumentsScript.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <process.h> 5 #include <process.h>
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/process.h" 8 #include "bin/process.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 #include "bin/thread.h" 10 #include "bin/thread.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len); 568 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
569 CloseProcessPipes( 569 CloseProcessPipes(
570 stdin_handles, stdout_handles, stderr_handles, exit_handles); 570 stdin_handles, stdout_handles, stderr_handles, exit_handles);
571 return error_code; 571 return error_code;
572 } 572 }
573 573
574 // Put together command-line string. 574 // Put together command-line string.
575 char* command_line = new char[command_line_length]; 575 char* command_line = new char[command_line_length];
576 int len = 0; 576 int len = 0;
577 int remaining = command_line_length; 577 int remaining = command_line_length;
578 int written = snprintf(command_line + len, remaining, "\"%s\"", path); 578 // Quote the path if it contains a space.
579 char* format = strchr(path, ' ') != NULL ? "\"%s\"" : "%s";
Anton Muhin 2012/03/15 11:52:48 what if argument is already quoted, do we want to
Mads Ager (google) 2012/03/15 14:32:22 We don't care that the argument is already quoted.
580 int written = snprintf(command_line + len, remaining, format, path);
579 len += written; 581 len += written;
580 remaining -= written; 582 remaining -= written;
581 ASSERT(remaining >= 0); 583 ASSERT(remaining >= 0);
582 for (int i = 0; i < arguments_length; i++) { 584 for (int i = 0; i < arguments_length; i++) {
583 written = snprintf(command_line + len, remaining, " \"%s\"", arguments[i]); 585 // Quote the argument if it contains a space or a tab.
586 bool contains_tab_or_space = ((strchr(arguments[i], ' ') != NULL) ||
587 (strchr(arguments[i], '\t') != NULL));
Anton Muhin 2012/03/15 11:52:48 what about other whitespaces?
Mads Ager (google) 2012/03/15 14:32:22 In the command-line that you create the arguments
588 format = contains_tab_or_space ? " \"%s\"" : " %s";
589 written = snprintf(command_line + len, remaining, format, arguments[i]);
584 len += written; 590 len += written;
585 remaining -= written; 591 remaining -= written;
586 ASSERT(remaining >= 0); 592 ASSERT(remaining >= 0);
587 } 593 }
588 594
589 // Create process. 595 // Create process.
590 BOOL result = CreateProcess(NULL, // ApplicationName 596 BOOL result = CreateProcess(NULL, // ApplicationName
591 command_line, 597 command_line,
592 NULL, // ProcessAttributes 598 NULL, // ProcessAttributes
593 NULL, // ThreadAttributes 599 NULL, // ThreadAttributes
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if (!result) { 649 if (!result) {
644 return false; 650 return false;
645 } 651 }
646 return true; 652 return true;
647 } 653 }
648 654
649 655
650 void Process::TerminateExitCodeHandler() { 656 void Process::TerminateExitCodeHandler() {
651 ExitCodeHandler::TerminateExitCodeThread(); 657 ExitCodeHandler::TerminateExitCodeThread();
652 } 658 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/src/io/ProcessCheckArgumentsScript.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698