diff --git a/vtparse/src/lib.rs b/vtparse/src/lib.rs index 270ea02d7..d393fff39 100644 --- a/vtparse/src/lib.rs +++ b/vtparse/src/lib.rs @@ -29,12 +29,21 @@ fn lookup(state: State, b: u8) -> (Action, State) { } #[inline(always)] +#[cfg(not(test))] fn lookup_entry(state: State) -> Action { unsafe { *ENTRY.get_unchecked(state as usize) } } #[inline(always)] -#[cfg(debug_assertions)] +#[cfg(test)] +fn lookup_entry(state: State) -> Action { + *ENTRY + .get(state as usize) + .unwrap_or_else(|| panic!("State {:?} has no entry in ENTRY", state)) +} + +#[inline(always)] +#[cfg(test)] fn lookup_exit(state: State) -> Action { *EXIT .get(state as usize) @@ -42,7 +51,7 @@ fn lookup_exit(state: State) -> Action { } #[inline(always)] -#[cfg(not(debug_assertions))] +#[cfg(not(test))] fn lookup_exit(state: State) -> Action { unsafe { *EXIT.get_unchecked(state as usize) } } diff --git a/vtparse/src/transitions.rs b/vtparse/src/transitions.rs index 5ad618130..4b1d918ec 100644 --- a/vtparse/src/transitions.rs +++ b/vtparse/src/transitions.rs @@ -308,7 +308,7 @@ pub(crate) static TRANSITIONS: [[u16; 256]; 15] = [ define_table!(apc_string), ]; -pub(crate) static ENTRY: [Action; 15] = [ +pub(crate) static ENTRY: [Action; 17] = [ Action::None, // Ground Action::Clear, // Escape Action::None, // EscapeIntermediate @@ -324,9 +324,11 @@ pub(crate) static ENTRY: [Action; 15] = [ Action::OscStart, // OscString Action::None, // SosPmString Action::ApcStart, // ApcString + Action::None, // Anywhere + Action::None, // Utf8Sequence ]; -pub(crate) static EXIT: [Action; 15] = [ +pub(crate) static EXIT: [Action; 17] = [ Action::None, // Ground Action::None, // Escape Action::None, // EscapeIntermediate @@ -342,6 +344,8 @@ pub(crate) static EXIT: [Action; 15] = [ Action::OscEnd, // OscString Action::None, // SosPmString Action::ApcEnd, // ApcString + Action::None, // Anywhere + Action::None, // Utf8Sequence ]; #[cfg(test)]