OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "tools/gn/escape.h" | 5 #include "tools/gn/escape.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/containers/stack_container.h" | 9 #include "base/containers/stack_container.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "build/build_config.h" |
9 | 12 |
10 namespace { | 13 namespace { |
11 | 14 |
12 // A "1" in this lookup table means that char is valid in the Posix shell. | 15 // A "1" in this lookup table means that char is valid in the Posix shell. |
13 const char kShellValid[0x80] = { | 16 const char kShellValid[0x80] = { |
14 // 00-1f: all are invalid | 17 // 00-1f: all are invalid |
15 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 18 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
16 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 19 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
17 // ' ' ! " # $ % & ' ( ) * + , - . / | 20 // ' ' ! " # $ % & ' ( ) * + , - . / |
18 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, | 21 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 200 } |
198 | 201 |
199 void EscapeStringToStream(std::ostream& out, | 202 void EscapeStringToStream(std::ostream& out, |
200 const base::StringPiece& str, | 203 const base::StringPiece& str, |
201 const EscapeOptions& options) { | 204 const EscapeOptions& options) { |
202 base::StackString<256> escaped; | 205 base::StackString<256> escaped; |
203 EscapeStringToString(str, options, &escaped.container(), nullptr); | 206 EscapeStringToString(str, options, &escaped.container(), nullptr); |
204 if (!escaped->empty()) | 207 if (!escaped->empty()) |
205 out.write(escaped->data(), escaped->size()); | 208 out.write(escaped->data(), escaped->size()); |
206 } | 209 } |
OLD | NEW |