From 8d9cd83e6d80b47887dd80b03b939dda7e0104cc Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 28 Jan 2018 17:11:05 -0800 Subject: [PATCH] add some more comments on CSIParser --- src/term/csi.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/term/csi.rs b/src/term/csi.rs index 34db8e453..a5f3f9904 100644 --- a/src/term/csi.rs +++ b/src/term/csi.rs @@ -55,6 +55,11 @@ pub struct CSIParser<'a> { /// arrived and subsequent characters were ignored. ignore: bool, byte: char, + /// While params is_some we have more data to consume. The advance_by + /// method updates the slice as we consume data. + /// In a number of cases an empty params list is used to indicate + /// default values, especially for SGR, so we need to be careful not + /// to update params to an empty slice. params: Option<&'a [i64]>, } @@ -73,6 +78,10 @@ impl<'a> CSIParser<'a> { } } + /// Consume some number of elements from params and update it. + /// Take care to avoid setting params back to an empty slice + /// as this would trigger returning a default value and/or + /// an unterminated parse loop. fn advance_by(&mut self, n: usize, params: &'a [i64]) { let (_, next) = params.split_at(n); if next.len() != 0 {