Skip to content

Commit

Permalink
#153 fixed buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Jun 29, 2019
1 parent 0e7a582 commit 48489d0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions jansi/src/main/java/org/fusesource/jansi/FilterPrintStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,23 @@ public void flush()
ps.flush();
}

private void write(char buf[]) {
private void write(char buf[], int len) {
for (char c : buf)
{
if (filter(c))
{
if (len-- > 0) {
return;
}
if (filter(c)) {
ps.print(c);
}
}
}

private void write(String s) {
char[] buf = (s.length() < strToCharBuffer.length)? strToCharBuffer : new char[s.length()];
s.getChars(0, s.length(), buf, 0);
write(buf);
int len = s.length();
char[] buf = (len < strToCharBuffer.length)? strToCharBuffer : new char[len];
s.getChars(0, len, buf, 0);
write(buf, len);
}

private void newLine() {
Expand Down Expand Up @@ -156,7 +159,7 @@ public void print(double d) {

@Override
public void print(char s[]) {
write(s);
write(s, s.length);
}

@Override
Expand Down

0 comments on commit 48489d0

Please sign in to comment.