[vte] parser: Ignore DEL in all states



commit c21e714b44fccdd9374483bbf46767638a902cdd
Author: Christian Persch <chpe src gnome org>
Date:   Tue Mar 27 19:40:13 2018 +0200

    parser: Ignore DEL in all states
    
    DEL does not change state or performs any action.

 src/parser-test.cc |   21 ++++++++++-----------
 src/parser.cc      |   41 ++++++-----------------------------------
 2 files changed, 16 insertions(+), 46 deletions(-)
---
diff --git a/src/parser-test.cc b/src/parser-test.cc
index c2fa3fc..04073d5 100644
--- a/src/parser-test.cc
+++ b/src/parser-test.cc
@@ -491,12 +491,12 @@ test_seq_control(void)
                 { 0x18, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
                 { 0x19, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x1a, VTE_SEQ_CONTROL, VTE_CMD_SUB     },
-                { 0x1b, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
+                { 0x1b, VTE_SEQ_NONE,    VTE_CMD_NONE    },
                 { 0x1c, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x1d, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x1e, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x1f, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
-                { 0x7f, VTE_SEQ_GRAPHIC, VTE_CMD_GRAPHIC }, // FIXMEchpe
+                { 0x7f, VTE_SEQ_NONE,    VTE_CMD_NONE    },
                 { 0x80, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x81, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x82, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
@@ -513,7 +513,7 @@ test_seq_control(void)
                 { 0x8d, VTE_SEQ_CONTROL, VTE_CMD_RI      },
                 { 0x8e, VTE_SEQ_CONTROL, VTE_CMD_SS2     },
                 { 0x8f, VTE_SEQ_CONTROL, VTE_CMD_SS3     },
-                { 0x90, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
+                { 0x90, VTE_SEQ_NONE,    VTE_CMD_NONE    },
                 { 0x91, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x92, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x93, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
@@ -521,22 +521,21 @@ test_seq_control(void)
                 { 0x95, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
                 { 0x96, VTE_SEQ_CONTROL, VTE_CMD_SPA     },
                 { 0x97, VTE_SEQ_CONTROL, VTE_CMD_EPA     },
-                { 0x98, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
+                { 0x98, VTE_SEQ_NONE,    VTE_CMD_NONE    },
                 { 0x99, VTE_SEQ_CONTROL, VTE_CMD_NONE    },
-                { 0x9a, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
-                { 0x9b, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
+                { 0x9a, VTE_SEQ_NONE,    VTE_CMD_NONE    },
+                { 0x9b, VTE_SEQ_NONE,    VTE_CMD_NONE    },
                 { 0x9c, VTE_SEQ_CONTROL, VTE_CMD_ST      },
-                { 0x9d, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
-                { 0x9e, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
-                { 0x9f, VTE_SEQ_IGNORE,  VTE_CMD_NONE    },
+                { 0x9d, VTE_SEQ_NONE,    VTE_CMD_NONE    },
+                { 0x9e, VTE_SEQ_NONE,    VTE_CMD_NONE    },
+                { 0x9f, VTE_SEQ_NONE,    VTE_CMD_NONE    },
         };
 
         for (unsigned int i = 0; i < G_N_ELEMENTS(controls); i++) {
                 vte_parser_reset(parser);
                 struct vte_seq* seq;
                 auto rv = vte_parser_feed(parser, &seq, controls[i].c);
-                g_assert_cmpuint(rv, >=, 0);
-                g_assert_cmpuint(controls[i].type, ==, seq->type);
+                g_assert_cmpuint(controls[i].type, ==, rv);
                 g_assert_cmpuint(controls[i].cmd, ==, seq->command);
         }
 }
diff --git a/src/parser.cc b/src/parser.cc
index b4792dd..9c54e13 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1351,9 +1351,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x5f:                /* '_' */
                         return parser_transition(parser, raw, STATE_ST_IGNORE,
                                                  ACTION_NONE);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1376,9 +1373,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x30 ... 0x7e:        /* ['0' - '~'] */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_ESC_DISPATCH);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1408,9 +1402,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_CSI_DISPATCH);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1440,9 +1431,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_CSI_DISPATCH);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1468,9 +1456,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_CSI_DISPATCH);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1493,9 +1478,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_NONE);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1525,9 +1507,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_DCS_PASS,
                                                  ACTION_DCS_CONSUME);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1557,9 +1536,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_DCS_PASS,
                                                  ACTION_DCS_CONSUME);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1585,9 +1561,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x40 ... 0x7e:        /* ['@' - '~'] */
                         return parser_transition(parser, raw, STATE_DCS_PASS,
                                                  ACTION_DCS_CONSUME);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_IGNORE);
@@ -1597,16 +1570,13 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                                          STATE_DCS_PASS, ACTION_DCS_CONSUME);
         case STATE_DCS_PASS:
                 switch (raw) {
-                case 0x00 ... 0x1a:        /* ASCII \ { ESC, DEL } */
-                case 0x1c ... 0x7e:
+                case 0x00 ... 0x1a:        /* ASCII \ { ESC } */
+                case 0x1c ... 0x7f:
                         return parser_transition(parser, raw, STATE_NONE,
                                                  ACTION_DCS_COLLECT);
                 case 0x1b:                /* ESC */
                         return parser_transition(parser, raw, STATE_DCS_PASS_ESC,
                                                  ACTION_NONE);
-                case 0x7f:                /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 case 0x9c:                /* ST */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_DCS_DISPATCH);
@@ -1676,9 +1646,6 @@ static int parser_feed_to_state(struct vte_parser *parser, uint32_t raw)
                 case 0x20 ... 0x7e:        /* [' ' - '~'] */
                         return parser_transition(parser, raw, STATE_GROUND,
                                                  ACTION_SCI_DISPATCH);
-                case 0x7f:                 /* DEL */
-                        return parser_transition(parser, raw, STATE_NONE,
-                                                 ACTION_IGNORE);
                 }
 
                 return parser_transition(parser, raw, STATE_GROUND,
@@ -1713,6 +1680,10 @@ int vte_parser_feed(struct vte_parser *parser,
                 ret = parser_transition(parser, raw,
                                         STATE_GROUND, ACTION_EXECUTE);
                 break;
+        case 0x7f:                 /* DEL */
+                ret = parser_transition(parser, raw, STATE_NONE,
+                                        ACTION_NONE);
+                break;
         case 0x80 ... 0x8f:        /* C1 \ {DCS, SOS, SCI, CSI, ST, OSC, PM, APC} */
         case 0x91 ... 0x97:
         case 0x99:


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