forked from syndicate-lang/preserves
Repair accidentally-dropped-buffer error
This commit is contained in:
parent
b24aca8f0f
commit
96f5c9f434
|
@ -215,6 +215,7 @@ impl<R: io::Read> io::Read for RollingBuffer<R> {
|
||||||
|
|
||||||
fn convert(c: Convert) -> io::Result<()> {
|
fn convert(c: Convert) -> io::Result<()> {
|
||||||
let mut r = RollingBuffer::new(io::stdin());
|
let mut r = RollingBuffer::new(io::stdin());
|
||||||
|
let mut source = IOBinarySource::new(&mut r);
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
let mut w: Box<dyn FnMut(&IOValue) -> io::Result<()>> = match c.output_format {
|
let mut w: Box<dyn FnMut(&IOValue) -> io::Result<()>> = match c.output_format {
|
||||||
OutputFormat::Text => {
|
OutputFormat::Text => {
|
||||||
|
@ -235,7 +236,7 @@ fn convert(c: Convert) -> io::Result<()> {
|
||||||
};
|
};
|
||||||
loop {
|
loop {
|
||||||
let is_text = {
|
let is_text = {
|
||||||
let peek_buf = r.peek_buf()?;
|
let peek_buf = source.read.peek_buf()?;
|
||||||
if peek_buf.is_empty() {
|
if peek_buf.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -248,7 +249,7 @@ fn convert(c: Convert) -> io::Result<()> {
|
||||||
InputFormat::Binary => return Err(io::Error::new(
|
InputFormat::Binary => return Err(io::Error::new(
|
||||||
io::ErrorKind::InvalidData, "Expected binary input, saw text input")),
|
io::ErrorKind::InvalidData, "Expected binary input, saw text input")),
|
||||||
}
|
}
|
||||||
TextReader::new(&mut IOBinarySource::new(&mut r), ViaCodec::new(IOValueDomainCodec))
|
TextReader::new(&mut source, ViaCodec::new(IOValueDomainCodec))
|
||||||
.next(c.annotations.into())?
|
.next(c.annotations.into())?
|
||||||
} else {
|
} else {
|
||||||
match c.input_format {
|
match c.input_format {
|
||||||
|
@ -256,7 +257,7 @@ fn convert(c: Convert) -> io::Result<()> {
|
||||||
InputFormat::Text => return Err(io::Error::new(
|
InputFormat::Text => return Err(io::Error::new(
|
||||||
io::ErrorKind::InvalidData, "Expected text input, saw binary input")),
|
io::ErrorKind::InvalidData, "Expected text input, saw binary input")),
|
||||||
}
|
}
|
||||||
PackedReader::new(&mut IOBinarySource::new(&mut r), IOValueDomainCodec)
|
PackedReader::new(&mut source, IOValueDomainCodec)
|
||||||
.next(c.annotations.into())?
|
.next(c.annotations.into())?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -264,7 +265,7 @@ fn convert(c: Convert) -> io::Result<()> {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
w(&value)?;
|
w(&value)?;
|
||||||
r.discard_to_pos();
|
source.read.discard_to_pos();
|
||||||
count += 1;
|
count += 1;
|
||||||
if let Some(limit) = c.limit {
|
if let Some(limit) = c.limit {
|
||||||
if count >= limit {
|
if count >= limit {
|
||||||
|
|
Loading…
Reference in New Issue