diff options
| author | Martin Cracauer <cracauer@FreeBSD.org> | 2000-09-06 08:38:45 +0000 |
|---|---|---|
| committer | Martin Cracauer <cracauer@FreeBSD.org> | 2000-09-06 08:38:45 +0000 |
| commit | 2a91167cce76f37ec47b2bea84ae0b6695f26441 (patch) | |
| tree | 7028ff90b6dcf1bbb772b26e3dab2f5fe2f1602a /bin | |
| parent | 77b43afb80377797c69ddb44acf54bdcc037d9ae (diff) | |
Notes
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/sh/exec.c | 25 | ||||
| -rw-r--r-- | bin/sh/main.c | 3 | ||||
| -rw-r--r-- | bin/sh/memalloc.c | 19 | ||||
| -rw-r--r-- | bin/sh/memalloc.h | 1 | ||||
| -rw-r--r-- | bin/sh/parser.c | 5 |
5 files changed, 39 insertions, 14 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 67a858b184da..714ac36f073d 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -891,14 +891,21 @@ typecmd(argc, argv) switch (entry.cmdtype) { case CMDNORMAL: { - int j = entry.u.index; - char *path = pathval(), *name; - do { - name = padvance(&path, argv[i]); - stunalloc(name); - } while (--j >= 0); - out1fmt(" is%s %s\n", - cmdp ? " a tracked alias for" : "", name); + if (strchr(argv[i], '/') == NULL) { + char *path = pathval(), *name; + int j = entry.u.index; + do { + name = padvance(&path, argv[i]); + stunalloc(name); + } while (--j >= 0); + out1fmt(" is%s %s\n", + cmdp ? " a tracked alias for" : "", name); + } else { + if (access(argv[i], X_OK) == 0) + out1fmt(" is %s\n", argv[i]); + else + out1fmt(": %s\n", strerror(errno)); + } break; } case CMDFUNCTION: @@ -910,7 +917,7 @@ typecmd(argc, argv) break; default: - out1str(" not found\n"); + out1str(": not found\n"); error |= 127; break; } diff --git a/bin/sh/main.c b/bin/sh/main.c index 32eb82aabf00..7d005868758f 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -253,12 +253,13 @@ cmdloop(top) evaltree(n, 0); } popstackmark(&smark); + setstackmark(&smark); if (evalskip == SKIPFILE) { evalskip = 0; break; } } - popstackmark(&smark); /* unnecessary */ + popstackmark(&smark); } diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index b2155ffaa1d9..c106775254fe 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -118,6 +118,7 @@ struct stack_block { struct stack_block stackbase; struct stack_block *stackp = &stackbase; +struct stackmark *markp; char *stacknxt = stackbase.space; int stacknleft = MINSIZE; int sstrnleft; @@ -176,6 +177,8 @@ setstackmark(mark) mark->stackp = stackp; mark->stacknxt = stacknxt; mark->stacknleft = stacknleft; + mark->marknext = markp; + markp = mark; } @@ -186,6 +189,7 @@ popstackmark(mark) struct stack_block *sp; INTOFF; + markp = mark->marknext; while (stackp != mark->stackp) { sp = stackp; stackp = sp->prev; @@ -215,6 +219,7 @@ growstackblock() char *oldspace; int oldlen; struct stack_block *sp; + struct stack_block *oldstackp; newlen = ALIGN(stacknleft * 2 + 100); oldspace = stacknxt; @@ -222,6 +227,7 @@ growstackblock() if (stacknxt == stackp->space && stackp != &stackbase) { INTOFF; + oldstackp = stackp; sp = stackp; stackp = sp->prev; sp = ckrealloc((pointer)sp, sizeof(struct stack_block) - @@ -230,6 +236,19 @@ growstackblock() stackp = sp; stacknxt = sp->space; stacknleft = newlen; + { + /* Stack marks pointing to the start of the old block + * must be relocated to point to the new block + */ + struct stackmark *xmark; + xmark = markp; + while (xmark != NULL && xmark->stackp == oldstackp) { + xmark->stackp = stackp; + xmark->stacknxt = stacknxt; + xmark->stacknleft = stacknleft; + xmark = xmark->marknext; + } + } INTON; } else { p = stalloc(newlen); diff --git a/bin/sh/memalloc.h b/bin/sh/memalloc.h index ab53a833e41a..e3ca8be83da1 100644 --- a/bin/sh/memalloc.h +++ b/bin/sh/memalloc.h @@ -41,6 +41,7 @@ struct stackmark { struct stack_block *stackp; char *stacknxt; int stacknleft; + struct stackmark *marknext; }; diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 8603fe16c818..a65dfb3b4253 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -909,10 +909,7 @@ readtoken1(firstc, syntax, eofmark, striptabs) for (;;) { /* until end of line or end of word */ CHECKSTRSPACE(3, out); /* permit 3 calls to USTPUTC */ - if (c < 0 && c != PEOF) - synentry = CWORD; - else - synentry = syntax[c]; + synentry = syntax[c]; switch(synentry) { case CNL: /* '\n' */ |
