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

Side by Side Diff: src/ostreams.cc

Issue 554223002: Fixed printing of JS code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « src/ostreams.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 <algorithm> 5 #include <algorithm>
6 #include <cctype>
6 #include <cmath> 7 #include <cmath>
7 8
8 #include "src/base/platform/platform.h" // For isinf/isnan with MSVC 9 #include "src/base/platform/platform.h" // For isinf/isnan with MSVC
9 #include "src/ostreams.h" 10 #include "src/ostreams.h"
10 11
11 #if V8_OS_WIN 12 #if V8_OS_WIN
12 #define snprintf sprintf_s 13 #define snprintf sprintf_s
13 #endif 14 #endif
14 15
15 namespace v8 { 16 namespace v8 {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 159
159 160
160 OFStream& OFStream::flush() { 161 OFStream& OFStream::flush() {
161 if (f_) fflush(f_); 162 if (f_) fflush(f_);
162 return *this; 163 return *this;
163 } 164 }
164 165
165 166
166 OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) { 167 OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) {
167 char buf[10]; 168 char buf[10];
168 const char* format = (0x20 <= c.value && c.value <= 0x7F) && (c.value != 0x52) 169 const char* format =
169 ? "%c" 170 (std::isprint(c.value) || std::isspace(c.value)) && c.value != '\\'
170 : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x"; 171 ? "%c"
172 : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
171 snprintf(buf, sizeof(buf), format, c.value); 173 snprintf(buf, sizeof(buf), format, c.value);
172 return os << buf; 174 return os << buf;
173 } 175 }
174 176
175 177
176 OStream& operator<<(OStream& os, const AsUC16& c) { 178 OStream& operator<<(OStream& os, const AsUC16& c) {
177 char buf[10]; 179 char buf[10];
178 const char* format = (0x20 <= c.value && c.value <= 0x7F) 180 const char* format =
179 ? "%c" 181 std::isprint(c.value) ? "%c" : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
180 : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
181 snprintf(buf, sizeof(buf), format, c.value); 182 snprintf(buf, sizeof(buf), format, c.value);
182 return os << buf; 183 return os << buf;
183 } 184 }
184 } } // namespace v8::internal 185 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ostreams.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698