[cfe-commits] r49891 - /cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
Chris Lattner
sabre at nondot.org
Thu Apr 17 21:54:20 PDT 2008
Author: lattner
Date: Thu Apr 17 23:54:20 2008
New Revision: 49891
URL: http://llvm.org/viewvc/llvm-project?rev=49891&view=rev
Log:
Make tab insertion really right: the number of spaces inserted
depends on the column number of the start of the tab.
Modified:
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=49891&r1=49890&r2=49891&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Thu Apr 17 23:54:20 2008
@@ -107,37 +107,47 @@
assert (C <= FileEnd);
RewriteBuffer &RB = R.getEditBuffer(FileID);
-
+
+ unsigned ColNo = 0;
for (unsigned FilePos = 0; C != FileEnd ; ++C, ++FilePos) {
-
switch (*C) {
- default: break;
+ default: ++ColNo; break;
+ case '\n':
+ case '\r':
+ ColNo = 0;
+ break;
case ' ':
if (EscapeSpaces)
RB.ReplaceText(FilePos, 1, " ", 6);
+ ++ColNo;
break;
- case '\t':
+ case '\t': {
if (!ReplaceTabs)
break;
+ unsigned NumSpaces = 8-(ColNo&7);
if (EscapeSpaces)
RB.ReplaceText(FilePos, 1, " "
- " ", 6*8);
+ " ", 6*NumSpaces);
else
- RB.ReplaceText(FilePos, 1, " ", 8);
+ RB.ReplaceText(FilePos, 1, " ", NumSpaces);
+ ColNo += NumSpaces;
break;
-
+ }
case '<':
RB.ReplaceText(FilePos, 1, "<", 4);
+ ++ColNo;
break;
case '>':
RB.ReplaceText(FilePos, 1, ">", 4);
+ ++ColNo;
break;
case '&':
RB.ReplaceText(FilePos, 1, "&", 5);
+ ++ColNo;
break;
}
}
More information about the cfe-commits
mailing list