diff src/share/vm/utilities/ostream.cpp @ 102:f96100ac3d12

Merge
author rasbold
date Thu, 03 Apr 2008 06:41:16 -0700
parents 092ea87cc974 c7c777385a15
children d1605aabd0a1 2a1a77d3458f 37f87013dfd8
line wrap: on
line diff
--- a/src/share/vm/utilities/ostream.cpp	Tue Apr 01 16:14:18 2008 -0700
+++ b/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() {