Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
83:d3cd40645d0d | 102:f96100ac3d12 |
---|---|
50 if (ch == '\n') { | 50 if (ch == '\n') { |
51 _newlines += 1; | 51 _newlines += 1; |
52 _precount += _position + 1; | 52 _precount += _position + 1; |
53 _position = 0; | 53 _position = 0; |
54 } else if (ch == '\t') { | 54 } else if (ch == '\t') { |
55 _position += 8; | 55 int tw = 8 - (_position & 7); |
56 _precount -= 7; // invariant: _precount + _position == total count | 56 _position += tw; |
57 _precount -= tw-1; // invariant: _precount + _position == total count | |
57 } else { | 58 } else { |
58 _position += 1; | 59 _position += 1; |
59 } | 60 } |
60 } | 61 } |
61 } | 62 } |
131 const char* str = do_vsnprintf(buffer, O_BUFLEN, format, argptr, true, len); | 132 const char* str = do_vsnprintf(buffer, O_BUFLEN, format, argptr, true, len); |
132 write(str, len); | 133 write(str, len); |
133 } | 134 } |
134 | 135 |
135 void outputStream::fill_to(int col) { | 136 void outputStream::fill_to(int col) { |
136 while (position() < col) sp(); | 137 int need_fill = col - position(); |
138 sp(need_fill); | |
139 } | |
140 | |
141 void outputStream::move_to(int col, int slop, int min_space) { | |
142 if (position() >= col + slop) | |
143 cr(); | |
144 int need_fill = col - position(); | |
145 if (need_fill < min_space) | |
146 need_fill = min_space; | |
147 sp(need_fill); | |
137 } | 148 } |
138 | 149 |
139 void outputStream::put(char ch) { | 150 void outputStream::put(char ch) { |
140 assert(ch != 0, "please fix call site"); | 151 assert(ch != 0, "please fix call site"); |
141 char buf[] = { ch, '\0' }; | 152 char buf[] = { ch, '\0' }; |
142 write(buf, 1); | 153 write(buf, 1); |
143 } | 154 } |
144 | 155 |
145 void outputStream::sp() { | 156 #define SP_USE_TABS false |
146 this->write(" ", 1); | 157 |
158 void outputStream::sp(int count) { | |
159 if (count < 0) return; | |
160 if (SP_USE_TABS && count >= 8) { | |
161 int target = position() + count; | |
162 while (count >= 8) { | |
163 this->write("\t", 1); | |
164 count -= 8; | |
165 } | |
166 count = target - position(); | |
167 } | |
168 while (count > 0) { | |
169 int nw = (count > 8) ? 8 : count; | |
170 this->write(" ", nw); | |
171 count -= nw; | |
172 } | |
147 } | 173 } |
148 | 174 |
149 void outputStream::cr() { | 175 void outputStream::cr() { |
150 this->write("\n", 1); | 176 this->write("\n", 1); |
151 } | 177 } |