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