Repair rebase errors

This commit is contained in:
Tony Garnock-Jones 2022-11-08 21:06:13 +01:00
parent d1bcf790b2
commit 0f3bca673a
1 changed files with 8 additions and 8 deletions

View File

@ -121,16 +121,16 @@ impl<'de, 'src, S: BinarySource<'de>> TextReader<'de, 'src, S>
fn read_hex_float<N: NestedValue>(&mut self, bytecount: usize) -> io::Result<N> {
if self.next_byte()? != b'"' {
return Err(io_syntax_error("Missing open-double-quote in hex-encoded floating-point number"));
return Err(self.syntax_error("Missing open-double-quote in hex-encoded floating-point number"));
}
let bs = self.read_hex_binary()?;
if bs.len() != bytecount {
return Err(io_syntax_error("Incorrect number of bytes in hex-encoded floating-point number"));
return Err(self.syntax_error("Incorrect number of bytes in hex-encoded floating-point number"));
}
match bytecount {
4 => Ok(Value::from(f32::from_bits(u32::from_be_bytes(bs.try_into().unwrap()))).wrap()),
8 => Ok(Value::from(f64::from_bits(u64::from_be_bytes(bs.try_into().unwrap()))).wrap()),
_ => Err(io_syntax_error("Unsupported byte count in hex-encoded floating-point number")),
_ => Err(self.syntax_error("Unsupported byte count in hex-encoded floating-point number")),
}
}
@ -312,23 +312,23 @@ impl<'de, 'src, S: BinarySource<'de>> TextReader<'de, 'src, S>
match c {
b'(' | b')' | b'{' | b'}' | b'[' | b']' | b'<' | b'>' |
b'"' | b';' | b',' | b'@' | b'#' | b':' | b'|' | b' ' => {
let s = decode_utf8(bs)?;
let s = self.decode_utf8(bs)?;
return match NUMBER_RE.captures(&s) {
None => Ok(N::symbol(&s)),
Some(m) => match m.get(2) {
None => Ok(N::new(s.parse::<BigInt>().map_err(
|_| io_syntax_error(&format!(
|_| self.syntax_error(&format!(
"Invalid signed-integer number: {:?}", s)))?)),
Some(_) => {
if let Some(maybe_f) = m.get(7) {
let s = m[1].to_owned() + &m[3];
if maybe_f.range().is_empty() {
Ok(N::new(s.parse::<f64>().map_err(
|_| io_syntax_error(&format!(
|_| self.syntax_error(&format!(
"Invalid double-precision number: {:?}", s)))?))
} else {
Ok(N::new(s.parse::<f32>().map_err(
|_| io_syntax_error(&format!(
|_| self.syntax_error(&format!(
"Invalid single-precision number: {:?}", s)))?))
}
} else {
@ -396,7 +396,7 @@ impl<'de, 'src, S: BinarySource<'de>> Reader<'de> for TextReader<'de, 'src, S>
b'"' => N::new(&self.read_hex_binary()?[..]),
b'f' => self.read_hex_float(4)?,
b'd' => self.read_hex_float(8)?,
_ => return Err(io_syntax_error("Invalid #x syntax")),
_ => return Err(self.syntax_error("Invalid #x syntax")),
},
b'[' => self.read_base64_binary()?,
b'!' => Value::Embedded(decode_embedded.decode_embedded(self, read_annotations)?).wrap(),