Skip to content

Commit

Permalink
No smask panics jrmuizel#24 jrmuizel#27
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Feb 12, 2023
1 parent 8b1f1c4 commit e8e0c56
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,10 +1410,10 @@ impl Path {
Path { ops: Vec::new() }
}
fn current_point(&self) -> Res<(f64, f64)> {
let v = match self.ops.last().ok_or("empty path")? {
&PathOp::MoveTo(x, y) => (x, y),
&PathOp::LineTo(x, y) => (x, y),
&PathOp::CurveTo(_, _, _, _, x, y) => (x, y),
let v = match *self.ops.last().ok_or("empty path")? {
PathOp::MoveTo(x, y) => (x, y),
PathOp::LineTo(x, y) => (x, y),
PathOp::CurveTo(_, _, _, _, x, y) => (x, y),
_ => return Err("Unimplemented: current_point for path with no current point".into()),
};
Ok(v)
Expand Down Expand Up @@ -1475,7 +1475,7 @@ fn make_colorspace<'a>(
_ => {
let colorspaces: &Dictionary = get(doc, resources, b"ColorSpace");
let cs = maybe_get_array(doc, colorspaces, name)
.unwrap_or_else(|| panic!("missing colorspace {:?}", name));
.ok_or(format!("missing colorspace {:?}", name))?;
let cs_name = pdf_to_utf8(cs[0].as_name().expect("first arg must be a name"))?;
match cs_name.as_ref() {
"Separation" => {
Expand Down Expand Up @@ -1800,7 +1800,8 @@ impl<'a> Processor<'a> {
let ext_gstate: &Dictionary = get(doc, resources, b"ExtGState");
let name = operation.operands[0].as_name()?;
let state: &Dictionary = get(doc, ext_gstate, name);
apply_state(&mut gs, state);
// We throw away a potential Error here to be more lenient while parsing
let _error_maybe = apply_state(&mut gs, state);
}
"i" => {
dlog!(
Expand Down

0 comments on commit e8e0c56

Please sign in to comment.