aboutsummaryrefslogtreecommitdiff
path: root/sh.lex.c
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2023-01-29 20:46:19 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-01-29 20:46:19 +0000
commit143ef44f06822f82a8358d4c02f07102d963fe5f (patch)
treef9080b8a265dd926053ee7ae187e8fa46f3fb5e0 /sh.lex.c
parent174d8b60324d7e8754709f7155e13ca95220b48c (diff)
Vendor import of tcsh-6.24.07vendor/tcsh/6.24.07vendor/tcsh
Diffstat (limited to 'sh.lex.c')
-rw-r--r--sh.lex.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/sh.lex.c b/sh.lex.c
index d22e4f45616d..2de265b529a9 100644
--- a/sh.lex.c
+++ b/sh.lex.c
@@ -153,8 +153,7 @@ lex(struct wordent *hp)
if (!postcmd_active)
btell(&lineloc);
- hp->next = hp->prev = hp;
- hp->word = STRNULL;
+ initlex(hp);
hadhist = 0;
do
c = readc(0);
@@ -227,7 +226,7 @@ prlex(struct wordent *sp0)
struct wordent *sp = sp0->next;
for (;;) {
- xprintf("%S", sp->word);
+ xprintf("%" TCSH_S, sp->word);
sp = sp->next;
if (sp == sp0)
break;
@@ -512,6 +511,24 @@ getdol(void)
}
cleanup_push(&name, Strbuf_cleanup);
Strbuf_append1(&name, '$');
+ if (c == '\'') {
+ for (;;) {
+ Strbuf_append1(&name, c);
+ c = getC(DOEXCL);
+ if (c == '\'') break;
+ if (c == '\\') {
+ Strbuf_append1(&name, c);
+ c = getC(DOEXCL);
+ }
+ if (c == '\n') {
+ ungetD(c);
+ seterror(ERR_MISSING, '\'');
+ goto end;
+ }
+ }
+ Strbuf_append1(&name, c);
+ goto end;
+ }
if (c == '{')
Strbuf_append1(&name, c), c = getC(DOEXCL);
if (c == '#' || c == '?' || c == '%')
@@ -618,6 +635,7 @@ getdol(void)
/* scan s// [eichin:19910926.0512EST] */
if (c == 's') {
int delimcnt = 2;
+ int esc = 0;
eChar delim = getC(0);
Strbuf_append1(&name, delim);
@@ -627,9 +645,15 @@ getdol(void)
break;
}
while ((c = getC(0)) != CHAR_ERR) {
+ if (esc == 0 && c == '\\') {
+ esc = 1;
+ Strbuf_append1(&name, c);
+ continue;
+ }
Strbuf_append1(&name, c);
- if (c == delim) delimcnt--;
+ if (!esc && c == delim) delimcnt--;
if (!delimcnt) break;
+ esc = 0;
}
if (delimcnt) {
seterror(ERR_BADSUBST);
@@ -704,7 +728,7 @@ getexcl(Char sc)
lastev = eventno;
hp = gethent(sc);
- if (hp == 0)
+ if (hp == NULL)
return;
hadhist = 1;
dol = 0;
@@ -894,7 +918,6 @@ getsub(struct wordent *en)
* We raise the limit to 50000000
*/
-#define HIST_PURGE -50000000
static struct wordent *
dosub(Char sc, struct wordent *en, int global)
{