r187957 - Revert r187935 "Support for double width characters."
Arnold Schwaighofer
aschwaighofer at apple.com
Wed Aug 7 19:19:56 PDT 2013
Author: arnolds
Date: Wed Aug 7 21:19:56 2013
New Revision: 187957
URL: http://llvm.org/viewvc/llvm-project?rev=187957&view=rev
Log:
Revert r187935 "Support for double width characters."
It broke a public build bot.
Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=187957&r1=187956&r2=187957&view=diff
==============================================================================
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Aug 7 21:19:56 2013
@@ -20,7 +20,6 @@
#include "clang/Format/Format.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/Locale.h"
#include <algorithm>
namespace clang {
@@ -39,15 +38,6 @@ static bool IsBlank(char C) {
}
}
-static unsigned columnWidth(StringRef Text, encoding::Encoding Encoding) {
- if (Encoding == encoding::Encoding_UTF8) {
- int ContentWidth = llvm::sys::locale::columnWidth(Text);
- if (ContentWidth >= 0)
- return ContentWidth;
- }
- return encoding::getCodePointCount(Text, Encoding);
-}
-
static BreakableToken::Split getCommentSplit(StringRef Text,
unsigned ContentStartColumn,
unsigned ColumnLimit,
@@ -59,12 +49,9 @@ static BreakableToken::Split getCommentS
unsigned MaxSplitBytes = 0;
for (unsigned NumChars = 0;
- NumChars < MaxSplit && MaxSplitBytes < Text.size();) {
- unsigned NumBytes =
+ NumChars < MaxSplit && MaxSplitBytes < Text.size(); ++NumChars)
+ MaxSplitBytes +=
encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding);
- NumChars += columnWidth(Text.substr(MaxSplitBytes, NumBytes), Encoding);
- MaxSplitBytes += NumBytes;
- }
StringRef::size_type SpaceOffset = Text.find_last_of(Blanks, MaxSplitBytes);
if (SpaceOffset == StringRef::npos ||
@@ -97,8 +84,9 @@ static BreakableToken::Split getStringSp
return BreakableToken::Split(StringRef::npos, 0);
if (ColumnLimit <= ContentStartColumn)
return BreakableToken::Split(StringRef::npos, 0);
- unsigned MaxSplit = std::min<unsigned>(ColumnLimit - ContentStartColumn,
- columnWidth(Text, Encoding) - 1);
+ unsigned MaxSplit =
+ std::min<unsigned>(ColumnLimit - ContentStartColumn,
+ encoding::getCodePointCount(Text, Encoding) - 1);
StringRef::size_type SpaceOffset = 0;
StringRef::size_type SlashOffset = 0;
StringRef::size_type WordStartOffset = 0;
@@ -110,7 +98,7 @@ static BreakableToken::Split getStringSp
Chars += Advance;
} else {
Advance = encoding::getCodePointNumBytes(Text[0], Encoding);
- Chars += columnWidth(Text.substr(0, Advance), Encoding);
+ Chars += 1;
}
if (Chars > MaxSplit)
@@ -143,7 +131,7 @@ unsigned BreakableSingleLineToken::getLi
unsigned BreakableSingleLineToken::getLineLengthAfterSplit(
unsigned LineIndex, unsigned Offset, StringRef::size_type Length) const {
return StartColumn + Prefix.size() + Postfix.size() +
- columnWidth(Line.substr(Offset, Length), Encoding);
+ encoding::getCodePointCount(Line.substr(Offset, Length), Encoding);
}
BreakableSingleLineToken::BreakableSingleLineToken(
@@ -341,7 +329,8 @@ unsigned BreakableBlockComment::getLineC
unsigned BreakableBlockComment::getLineLengthAfterSplit(
unsigned LineIndex, unsigned Offset, StringRef::size_type Length) const {
return getContentStartColumn(LineIndex, Offset) +
- columnWidth(Lines[LineIndex].substr(Offset, Length), Encoding) +
+ encoding::getCodePointCount(Lines[LineIndex].substr(Offset, Length),
+ Encoding) +
// The last line gets a "*/" postfix.
(LineIndex + 1 == Lines.size() ? 2 : 0);
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=187957&r1=187956&r2=187957&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Aug 7 21:19:56 2013
@@ -5704,15 +5704,15 @@ TEST_F(FormatTest, CountsUTF8CharactersP
verifyFormat("\"ÐÐ´Ð½Ð°Ð¶Ð´Ñ Ð² ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ...\"",
getLLVMStyleWithColumns(35));
verifyFormat("\"ä¸ äº ä¸ å äº å
ä¸ å
« ä¹ å\"",
- getLLVMStyleWithColumns(31));
+ getLLVMStyleWithColumns(21));
verifyFormat("// ÐÐ´Ð½Ð°Ð¶Ð´Ñ Ð² ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ...",
getLLVMStyleWithColumns(36));
verifyFormat("// ä¸ äº ä¸ å äº å
ä¸ å
« ä¹ å",
- getLLVMStyleWithColumns(32));
+ getLLVMStyleWithColumns(22));
verifyFormat("/* ÐÐ´Ð½Ð°Ð¶Ð´Ñ Ð² ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ... */",
getLLVMStyleWithColumns(39));
verifyFormat("/* ä¸ äº ä¸ å äº å
ä¸ å
« ä¹ å */",
- getLLVMStyleWithColumns(35));
+ getLLVMStyleWithColumns(25));
}
TEST_F(FormatTest, SplitsUTF8Strings) {
@@ -5723,12 +5723,11 @@ TEST_F(FormatTest, SplitsUTF8Strings) {
"\"поÑÑ,\"",
format("\"ÐднаждÑ, в ÑÑÑдÑнÑÑ Ð·Ð¸Ð¼Ð½ÑÑ Ð¿Ð¾ÑÑ,\"",
getLLVMStyleWithColumns(13)));
- EXPECT_EQ("\"ä¸ äº ä¸ \"\n"
- "\"å äºå
\"\n"
- "\"ä¸ å
« ä¹ \"\n"
- "\"å\"",
- format("\"ä¸ äº ä¸ å äºå
ä¸ å
« ä¹ å\"",
- getLLVMStyleWithColumns(11)));
+ EXPECT_EQ("\"ä¸ äº ä¸ å \"\n"
+ "\"äº å
ä¸ å
« \"\n"
+ "\"ä¹ å\"",
+ format("\"ä¸ äº ä¸ å äº å
ä¸ å
« ä¹ å\"",
+ getLLVMStyleWithColumns(10)));
}
TEST_F(FormatTest, SplitsUTF8LineComments) {
@@ -5740,9 +5739,9 @@ TEST_F(FormatTest, SplitsUTF8LineComment
getLLVMStyleWithColumns(13)));
EXPECT_EQ("// ä¸äºä¸\n"
"// åäºå
ä¸\n"
- "// å
« ä¹\n"
- "// å",
- format("// ä¸äºä¸ åäºå
ä¸ å
« ä¹ å", getLLVMStyleWithColumns(9)));
+ "// å
«\n"
+ "// ä¹ å",
+ format("// ä¸äºä¸ åäºå
ä¸ å
« ä¹ å", getLLVMStyleWithColumns(6)));
}
TEST_F(FormatTest, SplitsUTF8BlockComments) {
@@ -5759,17 +5758,16 @@ TEST_F(FormatTest, SplitsUTF8BlockCommen
getLLVMStyleWithColumns(13)));
EXPECT_EQ("/* ä¸äºä¸\n"
" * åäºå
ä¸\n"
- " * å
« ä¹\n"
- " * å */",
- format("/* ä¸äºä¸ åäºå
ä¸ å
« ä¹ å */", getLLVMStyleWithColumns(9)));
+ " * å
«\n"
+ " * ä¹ å\n"
+ " */",
+ format("/* ä¸äºä¸ åäºå
ä¸ å
« ä¹ å */", getLLVMStyleWithColumns(6)));
EXPECT_EQ("/* ð£ð®ð¼ð½ ð£ð¬ð²ð¯\n"
" * ððªð¥ð\n"
" * ðð¿ð±-ð */",
format("/* ð£ð®ð¼ð½ ð£ð¬ð²ð¯ ððªð¥ð ðð¿ð±-ð */", getLLVMStyleWithColumns(12)));
}
-#endif // _MSC_VER
-
TEST_F(FormatTest, FormatsWithWebKitStyle) {
FormatStyle Style = getWebKitStyle();
@@ -5849,5 +5847,7 @@ TEST_F(FormatTest, FormatsWithWebKitStyl
format("if (aaaaaaaaaaaaaaa || bbbbbbbbbbbbbbb) { i++; }", Style));
}
+#endif
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list