[vte] sixel: Fix DECGRI for parameter value 0



commit 5fa45b4b177989d35fad927e9f8f9d57d4dbba2a
Author: Christian Persch <chpe src gnome org>
Date:   Thu Feb 10 21:07:24 2022 +0100

    sixel: Fix DECGRI for parameter value 0
    
    A DECGRI 0 should be treated like a DECGRI 1, as per DEC documentation.
    
    Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/2543

 src/sixel-context.hh | 5 ++++-
 src/sixel-test.cc    | 8 ++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/sixel-context.hh b/src/sixel-context.hh
index 60114991..264f3046 100644
--- a/src/sixel-context.hh
+++ b/src/sixel-context.hh
@@ -533,14 +533,17 @@ private:
                  *   args[0]: 1
                  *
                  * References: DEC PPLV2 ยง 5.8
+                 *             DEC STD 070
                  */
 
                 /* DEC terminals limited the repetition count to 255, but the SIXEL
                  * test data includes repeat counts much greater. Since we limit to
                  * k_max_width anyway when executing the repeat on the next sixel,
                  * don't limit here.
+                 *
+                 * A repeat count of 0 is treated like 1.
                  */
-                m_repeat_count = seq.param(0, 1);
+                m_repeat_count = seq.param(0, 1) ? : 1;
         }
 
         void
diff --git a/src/sixel-test.cc b/src/sixel-test.cc
index 3f9fd312..adc7cbac 100644
--- a/src/sixel-test.cc
+++ b/src/sixel-test.cc
@@ -1340,6 +1340,14 @@ test_context_repeat(void)
                 g_assert_cmpuint(*data++, ==, v);
 
         g_assert_cmpuint(size_t(data - pixels.get()), <=, size);
+
+       /* Check that repeat param 0 is trated as 1 */
+       parse_image(context, {DECGRI(0), Sixel(1u << 0)});;
+       assert_image_dimensions(context, 1, 1);
+
+       /* Check that omitted param is treated as default */
+       parse_image(context, {DECGRI(-1), Sixel(1u << 0)});
+       assert_image_dimensions(context, 1, 1);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]