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

Side by Side Diff: src/ostreams.cc

Issue 386973003: Made printing of special FP values portable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | 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 <cmath>
6 7
7 #include "src/ostreams.h" 8 #include "src/ostreams.h"
8 9
9 #if V8_OS_WIN 10 #if V8_OS_WIN
10 #define snprintf sprintf_s 11 #define snprintf sprintf_s
11 #endif 12 #endif
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 16
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return print(hex_ ? "%llx" : "%lld", x); 57 return print(hex_ ? "%llx" : "%lld", x);
57 } 58 }
58 59
59 60
60 OStream& OStream::operator<<(unsigned long long x) { // NOLINT(runtime/int) 61 OStream& OStream::operator<<(unsigned long long x) { // NOLINT(runtime/int)
61 return print(hex_ ? "%llx" : "%llu", x); 62 return print(hex_ ? "%llx" : "%llu", x);
62 } 63 }
63 64
64 65
65 OStream& OStream::operator<<(double x) { 66 OStream& OStream::operator<<(double x) {
67 if (std::isinf(x)) return *this << (x < 0 ? "-inf" : "inf");
68 if (std::isnan(x)) return *this << "nan";
66 return print("%g", x); 69 return print("%g", x);
67 } 70 }
68 71
69 72
70 OStream& OStream::operator<<(void* x) { 73 OStream& OStream::operator<<(void* x) {
71 return print("%p", x); 74 return print("%p", x);
72 } 75 }
73 76
74 77
75 OStream& OStream::operator<<(char x) { 78 OStream& OStream::operator<<(char x) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 164
162 OStream& operator<<(OStream& os, const AsUC16& c) { 165 OStream& operator<<(OStream& os, const AsUC16& c) {
163 char buf[10]; 166 char buf[10];
164 const char* format = (0x20 <= c.value && c.value <= 0x7F) 167 const char* format = (0x20 <= c.value && c.value <= 0x7F)
165 ? "%c" 168 ? "%c"
166 : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x"; 169 : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x";
167 snprintf(buf, sizeof(buf), format, c.value); 170 snprintf(buf, sizeof(buf), format, c.value);
168 return os << buf; 171 return os << buf;
169 } 172 }
170 } } // namespace v8::internal 173 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698