Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix various buffering issues, so we get output.
Need to revisit this area later.
  • Loading branch information
jnthn committed Feb 27, 2013
1 parent 81e35e7 commit 2219d82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -2,7 +2,6 @@

import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -317,9 +316,8 @@ public static String printfh(SixModelObject obj, String data, ThreadContext tc)
try {
if (h.osw == null)
h.osw = new OutputStreamWriter(h.os, "UTF-8");
if (h.bw == null)
h.bw = new BufferedWriter(h.osw);
h.bw.write(data);
h.osw.write(data);
h.osw.flush();
}
catch (IOException e) {
die_s(e.getMessage(), tc);
Expand Down Expand Up @@ -372,6 +370,7 @@ public static String readlineintfh(SixModelObject obj, String prompt, ThreadCont
if (h.br == null)
h.br = new BufferedReader(h.isr);
System.out.print(prompt);
System.out.flush();
return h.br.readLine();
}
catch (IOException e) {
Expand Down Expand Up @@ -448,8 +447,6 @@ public static SixModelObject closefh(SixModelObject obj, ThreadContext tc) {
try {
if (h.br != null)
h.br.close();
else if (h.bw != null)
h.bw.close();
else if (h.isr != null)
h.isr.close();
else if (h.osw != null)
Expand Down
5 changes: 2 additions & 3 deletions src/org/perl6/nqp/sixmodel/reprs/IOHandleInstance.java
Expand Up @@ -17,9 +17,8 @@ public class IOHandleInstance extends SixModelObject {
public OutputStreamWriter osw;

/*
* These further wrap the input stream reader and output stream
* writer for the case of doing line-based I/O.
* This further wraps the input stream reader for the case of doing
* line-based I/O.
*/
public BufferedReader br;
public BufferedWriter bw;
}

0 comments on commit 2219d82

Please sign in to comment.