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;
}
}