diff options
author | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
commit | 6bcea4ff932144a5fd02affefd45164fbf471e67 (patch) | |
tree | a8e078c679b12f0daebe10ed254239cb0d79e146 /deps/v8/src/ostreams.cc | |
parent | 4fae2356d105e394115188a814097c4a95ae0c5d (diff) | |
download | node-new-6bcea4ff932144a5fd02affefd45164fbf471e67.tar.gz |
deps: update v8 to 3.29.93.1
Diffstat (limited to 'deps/v8/src/ostreams.cc')
-rw-r--r-- | deps/v8/src/ostreams.cc | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/deps/v8/src/ostreams.cc b/deps/v8/src/ostreams.cc index 62304eb908..e927e6bbfd 100644 --- a/deps/v8/src/ostreams.cc +++ b/deps/v8/src/ostreams.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/ostreams.h" + #include <algorithm> -#include <cctype> #include <cmath> #include "src/base/platform/platform.h" // For isinf/isnan with MSVC -#include "src/ostreams.h" #if V8_OS_WIN #define snprintf sprintf_s @@ -164,22 +164,26 @@ OFStream& OFStream::flush() { } -OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) { +// Locale-independent predicates. +static bool IsPrint(uint16_t c) { return 0x20 <= c && c <= 0x7e; } +static bool IsSpace(uint16_t c) { return (0x9 <= c && c <= 0xd) || c == 0x20; } +static bool IsOK(uint16_t c) { return (IsPrint(c) || IsSpace(c)) && c != '\\'; } + + +static OStream& PrintUC16(OStream& os, uint16_t c, bool (*pred)(uint16_t)) { char buf[10]; - const char* format = - (std::isprint(c.value) || std::isspace(c.value)) && c.value != '\\' - ? "%c" - : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x"; - snprintf(buf, sizeof(buf), format, c.value); + const char* format = pred(c) ? "%c" : (c <= 0xff) ? "\\x%02x" : "\\u%04x"; + snprintf(buf, sizeof(buf), format, c); return os << buf; } +OStream& operator<<(OStream& os, const AsReversiblyEscapedUC16& c) { + return PrintUC16(os, c.value, IsOK); +} + + OStream& operator<<(OStream& os, const AsUC16& c) { - char buf[10]; - const char* format = - std::isprint(c.value) ? "%c" : (c.value <= 0xff) ? "\\x%02x" : "\\u%04x"; - snprintf(buf, sizeof(buf), format, c.value); - return os << buf; + return PrintUC16(os, c.value, IsPrint); } } } // namespace v8::internal |