bug-ncurses
[Top][All Lists]
Advanced

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

Re: Which string capabilities need script interpreation?


From: Thomas Dickey
Subject: Re: Which string capabilities need script interpreation?
Date: Mon, 24 Aug 2020 18:23:59 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Mon, Aug 24, 2020 at 11:34:25PM +0200, Florian Weimer wrote:
> * Thomas Dickey:
> 
> >> aaa+rv has this:
> >> 
> >>    sgr=\E[%?%p2%t4;%;%?%p4%t5;%;%?%p6%t1;%;%?%p1%p2%|%p3%!%t7;
> >>      %;%?%p7%t8;%;m\016,
> >
> > actually it looks okay to me:

...of course I may be misreading it, but

> >
> >     sgr=\E[
> >             %?
> >                     %p2
> >                     %t4;
> >             %;
> >             %?
> >                     %p4
> >                     %t5;
> >             %;
> >             %?
> >                     %p6
> >                     %t1;
> >             %;
> >             %?
> >                     %p1%p2%|%p3%!

I see (a test for this, tells me that is "true" unless %p3 is nonzero).

        \E[7;m^N            0
        \E[7;m^N            1=p1
        \E[4;7;m^N          2=p2
        \E[4;7;m^N          3=p1,p2
        \E[m^N              4=p3
        \E[m^N              5=p1,p3
        \E[4;m^N            6=p2,p3
        \E[4;m^N            7=p1,p2,p3
        \E[5;7;m^N          8=p4
        \E[5;7;m^N          9=p1,p4
        \E[4;5;7;m^N        10=p2,p4

Perhaps I can make tic tell me that...

> >                     %t7;
> >             %;
> >             %?
> >                     %p7
> >                     %t8;
> >             %;
> >             m\016,
> 
> The result of %p1%p2%| is never consumed, so it can be left on the
> stack if that branch is ever executed.
> 
> >> I think this does not result in a balanced stack.  These in
> >> ndr9500 have this problem, too:
> >> 
> >>   pfloc=\E|%{48}%p1%+%c2%p2\031,
> >>   pfx=\E|%{48}%p1%+%c1%p2\031,
> >
> > These are almost the same.  It's adding ASCII "0" (48) to the parameter,
> > and printing the result as a character.  That "2" or "1" after the "%c"
> > seems to be a literal value.
> 
> In both cases, the value of %p2 is left on the stack.

       pfloc=\E|%{48}%p1%+%c2%p2\031,
                             ^^^ (I see,
                                  and suppose a "%s" after that is expected)

That's "recent" (from 2007), but apparently reporting on something from ~1986.

       pfloc=\E|%{48}%p1%+%c2%p2%s\031,
 
> >> tek4107 uses %! throughout, but I think it's actually to be sent
> >> verbatim.  sgr0 is particularly clear in this regard, I think:
> >> 
> >>   sgr0=\E%!1\E[m$<2>\E%!0,
> >> 
> >> sgr0 does not take any parameters, but may need to access variables,
> >> as can be seen in wy350:
> >> 
> >>   sgr0=\EG0\E(\EH\003%{0}%PA%{0}%PC,
> >> 
> >> So I think %! in sgr0 needs to be quoted.
> >
> > I see - perhaps another check in tic, to warn about quoting that may be
> > needed for output-strings that should use escaping -- along with making
> > tputs remove the escapes.  The existing codes (including Solaris) kind
> > of assume that strings that don't take parameters aren't processed with
> > tparm, making them ready for use in tputs.
> 
> Hmm.  Yes, if there used to be an assumption that parameter-less
> capabilities wouldn't need % processing, that would explain why it's
> so difficult to come by information which capabilities need %
> processing.  Originally, you would just have used the parameter count
> list for that.
> 
> >> > $<...> are padding (time-delays)
> >> >
> >> > and yes, since strings are fed into tparm as data, those could
> >> > be a nuisance.  Since tputs/putp are supposed to accept either
> >> > the result from tparm/tiparm _or_ a string from the terminal
> >> > database, it would be in-scope to improve the %s part by escaping
> >> > the dollar-signs (and backslash-characters, of course).
> >> 
> >> I'm wondering if it would be okay in an alternative implementation to
> >> only honor $<…> that already part of the terminfo entry.  Basically
> >> recognize it at the same time as the % directives, and ignore whatever
> >> strings come in via %s (or other constructs), or strings that are
> >> written directly.
> >
> > At the moment I'm curious if making tputs handle some escapes would
> > be enough.
> 
> What do you mean by that?  Escaping the output of %s, so that it
> cannot contain $< accidentally?

escaping the "$" (I mentioned in a previous reply), and of course
escaping the "\" used for that purpose.

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]