mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
Merge
This commit is contained in:
commit
1659f11da6
48 changed files with 1729 additions and 667 deletions
|
@ -52,8 +52,9 @@ void outputStream::update_position(const char* s, size_t len) {
|
|||
_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::vprint_cr(const char* format, va_list argptr) {
|
|||
}
|
||||
|
||||
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 @@ void outputStream::put(char ch) {
|
|||
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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue