8033581: Incorrect comment aligment

8033798: javap output has unnecessary trailing whitespace
8033726: StackMapTable does not unindent properly

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2014-02-06 18:54:13 -08:00
parent 67d15f03e0
commit 29f985089a
4 changed files with 127 additions and 26 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -151,12 +151,22 @@ public class BasicWriter {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
case ' ':
pendingSpaces++;
break;
case '\n':
println();
break;
default:
if (buffer.length() == 0)
indent();
if (pendingSpaces > 0) {
for (int sp = 0; sp < pendingSpaces; sp++)
buffer.append(' ');
pendingSpaces = 0;
}
buffer.append(c);
}
}
@ -164,6 +174,8 @@ public class BasicWriter {
}
protected void println() {
// ignore/discard pending spaces
pendingSpaces = 0;
out.println(buffer);
buffer.setLength(0);
}
@ -173,26 +185,21 @@ public class BasicWriter {
}
protected void tab() {
if (buffer.length() == 0)
indent();
space(indentCount * indentWidth + tabColumn - buffer.length());
int col = indentCount * indentWidth + tabColumn;
pendingSpaces += (col <= buffer.length() ? 1 : col - buffer.length());
}
private void indent() {
space(indentCount * indentWidth);
pendingSpaces += (indentCount * indentWidth);
}
private void space(int n) {
for (int i = 0; i < n; i++)
buffer.append(' ');
}
private PrintWriter out;
private StringBuilder buffer;
private final PrintWriter out;
private final StringBuilder buffer;
private int indentCount;
private int indentWidth;
private int tabColumn;
private final int indentWidth;
private final int tabColumn;
private boolean pendingNewline;
private int pendingSpaces;
}
}