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

Side by Side Diff: runtime/bin/process_patch.dart

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
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 patch class _WindowsCodePageDecoder { 5 patch class _WindowsCodePageDecoder {
6 /* patch */ static String _decodeBytes(List<int> bytes) 6 /* patch */ static String _decodeBytes(List<int> bytes)
7 native "SystemEncodingToString"; 7 native "SystemEncodingToString";
8 } 8 }
9 9
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 String _windowsArgumentEscape(String argument) { 100 String _windowsArgumentEscape(String argument) {
101 var result = argument; 101 var result = argument;
102 if (argument.contains('\t') || argument.contains(' ')) { 102 if (argument.contains('\t') || argument.contains(' ')) {
103 // Produce something that the C runtime on Windows will parse 103 // Produce something that the C runtime on Windows will parse
104 // back as this string. 104 // back as this string.
105 105
106 // Replace any number of '\' followed by '"' with 106 // Replace any number of '\' followed by '"' with
107 // twice as many '\' followed by '\"'. 107 // twice as many '\' followed by '\"'.
108 var backslash = '\\'.charCodeAt(0); 108 var backslash = '\\'.codeUnitAt(0);
109 var sb = new StringBuffer(); 109 var sb = new StringBuffer();
110 var nextPos = 0; 110 var nextPos = 0;
111 var quotePos = argument.indexOf('"', nextPos); 111 var quotePos = argument.indexOf('"', nextPos);
112 while (quotePos != -1) { 112 while (quotePos != -1) {
113 var numBackslash = 0; 113 var numBackslash = 0;
114 var pos = quotePos - 1; 114 var pos = quotePos - 1;
115 while (pos >= 0 && argument.charCodeAt(pos) == backslash) { 115 while (pos >= 0 && argument.codeUnitAt(pos) == backslash) {
116 numBackslash++; 116 numBackslash++;
117 pos--; 117 pos--;
118 } 118 }
119 sb.add(argument.substring(nextPos, quotePos - numBackslash)); 119 sb.add(argument.substring(nextPos, quotePos - numBackslash));
120 for (var i = 0; i < numBackslash; i++) { 120 for (var i = 0; i < numBackslash; i++) {
121 sb.add(r'\\'); 121 sb.add(r'\\');
122 } 122 }
123 sb.add(r'\"'); 123 sb.add(r'\"');
124 nextPos = quotePos + 1; 124 nextPos = quotePos + 1;
125 quotePos = argument.indexOf('"', nextPos); 125 quotePos = argument.indexOf('"', nextPos);
126 } 126 }
127 sb.add(argument.substring(nextPos, argument.length)); 127 sb.add(argument.substring(nextPos, argument.length));
128 result = sb.toString(); 128 result = sb.toString();
129 129
130 // Add '"' at the beginning and end and replace all '\' at 130 // Add '"' at the beginning and end and replace all '\' at
131 // the end with two '\'. 131 // the end with two '\'.
132 sb = new StringBuffer('"'); 132 sb = new StringBuffer('"');
133 sb.add(result); 133 sb.add(result);
134 nextPos = argument.length - 1; 134 nextPos = argument.length - 1;
135 while (argument.charCodeAt(nextPos) == backslash) { 135 while (argument.codeUnitAt(nextPos) == backslash) {
136 sb.add('\\'); 136 sb.add('\\');
137 nextPos--; 137 nextPos--;
138 } 138 }
139 sb.add('"'); 139 sb.add('"');
140 result = sb.toString(); 140 result = sb.toString();
141 } 141 }
142 142
143 return result; 143 return result;
144 } 144 }
145 145
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 class _ProcessResult implements ProcessResult { 371 class _ProcessResult implements ProcessResult {
372 const _ProcessResult(int this.exitCode, 372 const _ProcessResult(int this.exitCode,
373 String this.stdout, 373 String this.stdout,
374 String this.stderr); 374 String this.stderr);
375 375
376 final int exitCode; 376 final int exitCode;
377 final String stdout; 377 final String stdout;
378 final String stderr; 378 final String stderr;
379 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698