OLD | NEW |
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 String _windowsArgumentEscape(String argument) { | 102 String _windowsArgumentEscape(String argument) { |
103 var result = argument; | 103 var result = argument; |
104 if (argument.contains('\t') || argument.contains(' ')) { | 104 if (argument.contains('\t') || argument.contains(' ')) { |
105 // Produce something that the C runtime on Windows will parse | 105 // Produce something that the C runtime on Windows will parse |
106 // back as this string. | 106 // back as this string. |
107 | 107 |
108 // Replace any number of '\' followed by '"' with | 108 // Replace any number of '\' followed by '"' with |
109 // twice as many '\' followed by '\"'. | 109 // twice as many '\' followed by '\"'. |
110 var backslash = '\\'.charCodeAt(0); | 110 var backslash = '\\'.codeUnitAt(0); |
111 var sb = new StringBuffer(); | 111 var sb = new StringBuffer(); |
112 var nextPos = 0; | 112 var nextPos = 0; |
113 var quotePos = argument.indexOf('"', nextPos); | 113 var quotePos = argument.indexOf('"', nextPos); |
114 while (quotePos != -1) { | 114 while (quotePos != -1) { |
115 var numBackslash = 0; | 115 var numBackslash = 0; |
116 var pos = quotePos - 1; | 116 var pos = quotePos - 1; |
117 while (pos >= 0 && argument.charCodeAt(pos) == backslash) { | 117 while (pos >= 0 && argument.codeUnitAt(pos) == backslash) { |
118 numBackslash++; | 118 numBackslash++; |
119 pos--; | 119 pos--; |
120 } | 120 } |
121 sb.add(argument.substring(nextPos, quotePos - numBackslash)); | 121 sb.add(argument.substring(nextPos, quotePos - numBackslash)); |
122 for (var i = 0; i < numBackslash; i++) { | 122 for (var i = 0; i < numBackslash; i++) { |
123 sb.add(r'\\'); | 123 sb.add(r'\\'); |
124 } | 124 } |
125 sb.add(r'\"'); | 125 sb.add(r'\"'); |
126 nextPos = quotePos + 1; | 126 nextPos = quotePos + 1; |
127 quotePos = argument.indexOf('"', nextPos); | 127 quotePos = argument.indexOf('"', nextPos); |
128 } | 128 } |
129 sb.add(argument.substring(nextPos, argument.length)); | 129 sb.add(argument.substring(nextPos, argument.length)); |
130 result = sb.toString(); | 130 result = sb.toString(); |
131 | 131 |
132 // Add '"' at the beginning and end and replace all '\' at | 132 // Add '"' at the beginning and end and replace all '\' at |
133 // the end with two '\'. | 133 // the end with two '\'. |
134 sb = new StringBuffer('"'); | 134 sb = new StringBuffer('"'); |
135 sb.add(result); | 135 sb.add(result); |
136 nextPos = argument.length - 1; | 136 nextPos = argument.length - 1; |
137 while (argument.charCodeAt(nextPos) == backslash) { | 137 while (argument.codeUnitAt(nextPos) == backslash) { |
138 sb.add('\\'); | 138 sb.add('\\'); |
139 nextPos--; | 139 nextPos--; |
140 } | 140 } |
141 sb.add('"'); | 141 sb.add('"'); |
142 result = sb.toString(); | 142 result = sb.toString(); |
143 } | 143 } |
144 | 144 |
145 return result; | 145 return result; |
146 } | 146 } |
147 | 147 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 class _ProcessResult implements ProcessResult { | 327 class _ProcessResult implements ProcessResult { |
328 const _ProcessResult(int this.exitCode, | 328 const _ProcessResult(int this.exitCode, |
329 String this.stdout, | 329 String this.stdout, |
330 String this.stderr); | 330 String this.stderr); |
331 | 331 |
332 final int exitCode; | 332 final int exitCode; |
333 final String stdout; | 333 final String stdout; |
334 final String stderr; | 334 final String stderr; |
335 } | 335 } |
OLD | NEW |