"...composable_kernel_rocm.git" did not exist on "20b1ae7cedcab951ff9499d5cf812176cf71b7e4"
Commit bc3f72b5 authored by Jesse Beder's avatar Jesse Beder
Browse files

Switched the stream << for c-strings to take a templated array param (since we...

Switched the stream << for c-strings to take a templated array param (since we never stream user-built c-strings, only string literals). For this, refactored the escape character display
parent 77296927
...@@ -25,9 +25,9 @@ namespace YAML ...@@ -25,9 +25,9 @@ namespace YAML
const char *str() const { const char *str() const {
if(m_pStream) { if(m_pStream) {
return NULL; return 0;
} else { } else {
m_buffer[m_pos] = NULL; m_buffer[m_pos] = '\0';
return &m_buffer[0]; return &m_buffer[0];
} }
} }
...@@ -49,8 +49,9 @@ namespace YAML ...@@ -49,8 +49,9 @@ namespace YAML
bool m_comment; bool m_comment;
}; };
inline ostream_wrapper& operator << (ostream_wrapper& stream, const char *str) { template<std::size_t N>
stream.write(str, std::strlen(str)); inline ostream_wrapper& operator << (ostream_wrapper& stream, const char (&str)[N]) {
stream.write(str, N-1);
return stream; return stream;
} }
......
...@@ -188,24 +188,22 @@ namespace YAML ...@@ -188,24 +188,22 @@ namespace YAML
void WriteDoubleQuoteEscapeSequence(ostream_wrapper& out, int codePoint) { void WriteDoubleQuoteEscapeSequence(ostream_wrapper& out, int codePoint) {
static const char hexDigits[] = "0123456789abcdef"; static const char hexDigits[] = "0123456789abcdef";
char escSeq[] = "\\U00000000"; out << "\\";
int digits = 8; int digits = 8;
if (codePoint < 0xFF) { if(codePoint < 0xFF) {
escSeq[1] = 'x'; out << "x";
digits = 2; digits = 2;
} else if (codePoint < 0xFFFF) { } else if(codePoint < 0xFFFF) {
escSeq[1] = 'u'; out << "u";
digits = 4; digits = 4;
} } else {
out << "U";
digits = 8;
}
// Write digits into the escape sequence // Write digits into the escape sequence
int i = 2; for (; digits > 0; --digits)
for (; digits > 0; --digits, ++i) { out << hexDigits[(codePoint >> (4 * (digits - 1))) & 0xF];
escSeq[i] = hexDigits[(codePoint >> (4 * (digits - 1))) & 0xF];
}
escSeq[i] = 0; // terminate with NUL character
out << escSeq;
} }
bool WriteAliasName(ostream_wrapper& out, const std::string& str) { bool WriteAliasName(ostream_wrapper& out, const std::string& str) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment