On Sat, Jan 29, 2022 at 04:09:09PM -0500, Thomas Dickey wrote:
> On Sat, Jan 29, 2022 at 07:51:53PM +0000, Wayne Cuddy via discussions 
> concerning the vile text editor wrote:
> > I'm not sure if this has been reported before, please forgive me if
> > this is repetitious.
> > 
> > I'm running 9.8t and have not had a chance to upgrade to the
> > latest/greatest yet but I don't see mention of this issue being
> > corrected in the changelog. The closest I could find was comments from
> > 9.7y:
> > 
> >     + improve vile-sh-filt for these cases:
> >     + "${number}"
> >     + "$(commands)"
> >     + "$((expression))"
> >     + "${name#value}", etc.
> > 
> > 
> > The issue concerns $((expression)) expansions in variable assignments,
> > but may not be limited to just this case.
> > 
> > var="prefix$((5*5))suffix"
>        ^ string
>                 ^expression
>                      ^ string?
> > 
> > prefix appears correctly highlighted, suffix does not, it seems the
> > syntax highlighting terminates after the final ')' character.
> 
> Just looking at the source, the line
> 
>       <EXPRS>{BACKTIC2_UP}    { handle_backtic2(yytext, yyleng, 
> LEN_BACKTIC2_DOWN, 0); }
> 
> is probably what should trigger on the "))", which takes it into
> 
>     if (FLTSTACK_OK && (which <= 0) && (FLTSTACK_THIS.backtic == test)) {
> 
> and fails there for some reason -- otherwise it would go back to the
> string/literal coloring.
> 
> (I'm in the middle of ncurses, but may dig into it tomorrow to get a better
> answer).

See attached

-- 
Thomas E. Dickey <dic...@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net
--- sh-filt.l   2021/12/12 01:26:53     1.183
+++ sh-filt.l   2022/01/30 20:27:01
@@ -70,6 +70,7 @@
 static void handle_backtic2(const char *text, int length, int test, int which);
 static void handle_backtic1(const char *text, int length, int test, int which);
 static void handle_parens(const char *text, int length, int test, int which, 
int state);
+static void resume_state(void);
 static void save_here(const char *text, int length);
 static void write_vname(const char *text, int length);
 
@@ -198,8 +199,10 @@
                            FLEX_PRINTF((stderr, "cannot pop '$((' level %d\n", 
stk_level));
                            if (!pop_backtic1(yytext, 1, LEN_BACKTIC1_DOWN)) {
                              FLEX_PRINTF((stderr, "cannot pop '$(' level 
%d\n", stk_level));
-                             if (FLTSTACK_OK && stk_state[stk_level-1].state 
== NORMAL)
+                             if (FLTSTACK_OK && stk_state[stk_level-1].state 
== NORMAL) {
                                pop_state();
+                               resume_state();
+                             }
                              flt_putc(R_PAREN);
                            }
                            unput(R_PAREN);
@@ -213,8 +216,10 @@
                        }
 <NORMAL>{BACKTIC1_UP}  { if (!pop_backtic1(yytext, yyleng, LEN_BACKTIC1_DOWN)) 
{
                            FLEX_PRINTF((stderr, "cannot pop '$(' level %d\n", 
stk_level));
-                           if (FLTSTACK_OK && stk_state[stk_level-1].state == 
NORMAL)
+                           if (FLTSTACK_OK && stk_state[stk_level-1].state == 
NORMAL) {
                              pop_state();
+                             resume_state();
+                           }
                            ECHO;
                          }
                        }
@@ -293,6 +298,7 @@
 <KSH_MATH>"))"         {
                          WriteToken(Action_attr); 
                          pop_state();
+                         resume_state();
                        }
 <KSH_MATH>{IDENT1}     |
 <KSH_MATH>{VNAME}      { WriteToken(Ident_attr); }
@@ -312,6 +318,7 @@
                          flt_bfr_append("'", 1);
                          flt_bfr_finish();
                          pop_state();
+                         resume_state();
                        }
 <KSH_CQUOTE>\\[0-7]{1,3}  {
                          flt_bfr_embed(yytext, 1, Action_attr);
@@ -874,6 +881,7 @@
        flt_bfr_append(value + used, length - used);
        flt_bfr_finish();
        pop_state();
+       resume_state();
        FreeAndNull(here_tag);
        here_exp = 0;
        here_next = 0;

Attachment: signature.asc
Description: PGP signature

  • sh-mode highli... Wayne Cuddy via discussions concerning the vile text editor
    • Re: sh-mo... Thomas Dickey
      • Re: s... Thomas Dickey
        • R... Wayne Cuddy via discussions concerning the vile text editor
          • ... Thomas Dickey

Reply via email to