ash: [PARSER] Add FAKEEOFMARK for expandstr
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 29 Jul 2017 19:12:29 +0000 (21:12 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 29 Jul 2017 19:12:29 +0000 (21:12 +0200)
commit469998015f57a552718420a4050d90e5dae6a6fd
tree7abea9787997b088dbbf5857b8bbe9446a383274
parent0f018b30700989462de0a15b8285206d16170c1f
ash: [PARSER] Add FAKEEOFMARK for expandstr

Upstream commit:

    Date: Thu, 27 Dec 2007 13:54:16 +1100
    [PARSER] Add FAKEEOFMARK for expandstr

    Previously expandstr used the string "" to indicate that it needs to be
    treated just like a here-doc except that there is no terminator.  However,
    the string "" is in fact a valid here-doc terminator so now that we deal
    with it correctly expandstr no longer works in the presence of new-lines
    in the prompt.

    This patch introduces the FAKEEOFMARK macro which does not equal any
    real EOF marker but is distinct from the NULL pointer which is used to
    indicate non-here-doc contexts.

    Thanks to Markus Triska for reporting this regression.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Unfortunately, I did not find the failing example for this old fix.

I also tweaked the code which was added by this commit:
"
Date: Mon Sep 24 18:30:02 2007 +0000
ash: fix prompt expansion (Natanael Copa <natanael.copa@gmail.com>)
"
since other parts of code do expect expandstr() to use DQSYNTAX, not PSSYNTAX.

function                                             old     new   delta
parse_stream                                        2609    2634     +25
setprompt_if                                         128     133      +5
read_profile                                          32      37      +5
evalcommand                                         1334    1339      +5
expandstr                                            122     120      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 40/-2)              Total: 38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c