summaryrefslogtreecommitdiffstats
path: root/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx')
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx126
1 files changed, 47 insertions, 79 deletions
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index f27caa9..f3dbcb9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -15,8 +15,8 @@
#include <cmVersion.h>
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
- std::string const& filename):
- File(filename.c_str(), std::ios::binary)
+ std::string const& filename)
+ : File(filename.c_str(), std::ios::binary)
{
StartGroup();
WriteHeader();
@@ -37,74 +37,50 @@ void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{
typedef unsigned char rtf_byte_t;
- for(size_t i = 0; i < text.size(); ++i)
- {
+ for (size_t i = 0; i < text.size(); ++i) {
rtf_byte_t c = rtf_byte_t(text[i]);
- switch(c)
- {
- case '\\':
- File << "\\\\";
- break;
- case '{':
- File << "\\{";
- break;
- case '}':
- File << "\\}";
- break;
- case '\n':
- File << "\\par\r\n";
- break;
- case '\r':
- continue;
- default:
- {
- if(c <= 0x7F)
- {
+ switch (c) {
+ case '\\':
+ File << "\\\\";
+ break;
+ case '{':
+ File << "\\{";
+ break;
+ case '}':
+ File << "\\}";
+ break;
+ case '\n':
+ File << "\\par\r\n";
+ break;
+ case '\r':
+ continue;
+ default: {
+ if (c <= 0x7F) {
File << c;
- }
- else
- {
- if(c <= 0xC0)
- {
- EmitInvalidCodepoint(c);
- }
- else if(c < 0xE0 && i+1 < text.size())
- {
- EmitUnicodeCodepoint(
- (text[i+1] & 0x3F) |
- ((c & 0x1F) << 6)
- );
- i+= 1;
- }
- else if(c < 0xF0 && i+2 < text.size())
- {
- EmitUnicodeCodepoint(
- (text[i+2] & 0x3F) |
- ((text[i+1] & 0x3F) << 6) |
- ((c & 0xF) << 12)
- );
- i += 2;
- }
- else if(c < 0xF8 && i+3 < text.size())
- {
- EmitUnicodeCodepoint(
- (text[i+3] & 0x3F) |
- ((text[i+2] & 0x3F) << 6) |
- ((text[i+1] & 0x3F) << 12) |
- ((c & 0x7) << 18)
- );
- i += 3;
- }
- else
- {
- EmitInvalidCodepoint(c);
- }
+ } else {
+ if (c <= 0xC0) {
+ EmitInvalidCodepoint(c);
+ } else if (c < 0xE0 && i + 1 < text.size()) {
+ EmitUnicodeCodepoint((text[i + 1] & 0x3F) | ((c & 0x1F) << 6));
+ i += 1;
+ } else if (c < 0xF0 && i + 2 < text.size()) {
+ EmitUnicodeCodepoint((text[i + 2] & 0x3F) |
+ ((text[i + 1] & 0x3F) << 6) |
+ ((c & 0xF) << 12));
+ i += 2;
+ } else if (c < 0xF8 && i + 3 < text.size()) {
+ EmitUnicodeCodepoint(
+ (text[i + 3] & 0x3F) | ((text[i + 2] & 0x3F) << 6) |
+ ((text[i + 1] & 0x3F) << 12) | ((c & 0x7) << 18));
+ i += 3;
+ } else {
+ EmitInvalidCodepoint(c);
}
}
- break;
- }
+ } break;
}
+ }
}
void cmWIXRichTextFormatWriter::WriteHeader()
@@ -190,33 +166,25 @@ void cmWIXRichTextFormatWriter::EndGroup()
void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
{
// Do not emit byte order mark (BOM)
- if(c == 0xFEFF)
- {
+ if (c == 0xFEFF) {
return;
- }
- else if(c <= 0xFFFF)
- {
+ } else if (c <= 0xFFFF) {
EmitUnicodeSurrogate(c);
- }
- else
- {
+ } else {
c -= 0x10000;
EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800);
EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00);
- }
+ }
}
void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
{
ControlWord("u");
- if(c <= 32767)
- {
+ if (c <= 32767) {
File << c;
- }
- else
- {
+ } else {
File << (c - 65536);
- }
+ }
File << "?";
}