--- a/hotspot/src/share/vm/utilities/ostream.cpp Tue Apr 01 16:14:18 2008 -0700
+++ b/hotspot/src/share/vm/utilities/ostream.cpp Thu Apr 03 06:41:16 2008 -0700
@@ -52,8 +52,9 @@
_precount += _position + 1;
_position = 0;
} else if (ch == '\t') {
- _position += 8;
- _precount -= 7; // invariant: _precount + _position == total count
+ int tw = 8 - (_position & 7);
+ _position += tw;
+ _precount -= tw-1; // invariant: _precount + _position == total count
} else {
_position += 1;
}
@@ -133,7 +134,17 @@
}
void outputStream::fill_to(int col) {
- while (position() < col) sp();
+ int need_fill = col - position();
+ sp(need_fill);
+}
+
+void outputStream::move_to(int col, int slop, int min_space) {
+ if (position() >= col + slop)
+ cr();
+ int need_fill = col - position();
+ if (need_fill < min_space)
+ need_fill = min_space;
+ sp(need_fill);
}
void outputStream::put(char ch) {
@@ -142,8 +153,23 @@
write(buf, 1);
}
-void outputStream::sp() {
- this->write(" ", 1);
+#define SP_USE_TABS false
+
+void outputStream::sp(int count) {
+ if (count < 0) return;
+ if (SP_USE_TABS && count >= 8) {
+ int target = position() + count;
+ while (count >= 8) {
+ this->write("\t", 1);
+ count -= 8;
+ }
+ count = target - position();
+ }
+ while (count > 0) {
+ int nw = (count > 8) ? 8 : count;
+ this->write(" ", nw);
+ count -= nw;
+ }
}
void outputStream::cr() {