From owner-svn-src-all@FreeBSD.ORG Fri Aug 30 20:50:28 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BC343DA2; Fri, 30 Aug 2013 20:50:28 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A9A392E98; Fri, 30 Aug 2013 20:50:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7UKoSvt003868; Fri, 30 Aug 2013 20:50:28 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7UKoSG7003867; Fri, 30 Aug 2013 20:50:28 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201308302050.r7UKoSG7003867@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 30 Aug 2013 20:50:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255087 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Aug 2013 20:50:28 -0000 Author: jilles Date: Fri Aug 30 20:50:28 2013 New Revision: 255087 URL: http://svnweb.freebsd.org/changeset/base/255087 Log: sh: Simplify list() in the parser. The erflag argument was only used by old-style (``) command substitutions. We can remove it and handle the special case in the command substitution code. Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Fri Aug 30 20:46:01 2013 (r255086) +++ head/bin/sh/parser.c Fri Aug 30 20:50:28 2013 (r255087) @@ -108,7 +108,7 @@ static int funclinno; /* line # where t static struct parser_temp *parser_temp; -static union node *list(int, int); +static union node *list(int); static union node *andor(void); static union node *pipeline(void); static union node *command(void); @@ -225,18 +225,18 @@ parsecmd(int interact) if (t == TNL) return NULL; tokpushback++; - return list(1, 1); + return list(1); } static union node * -list(int nlflag, int erflag) +list(int nlflag) { union node *ntop, *n1, *n2, *n3; int tok; checkkwd = CHKNL | CHKKWD | CHKALIAS; - if (!nlflag && !erflag && tokendlist[peektoken()]) + if (!nlflag && tokendlist[peektoken()]) return NULL; ntop = n1 = NULL; for (;;) { @@ -283,8 +283,7 @@ list(int nlflag, int erflag) tokpushback++; } checkkwd = CHKNL | CHKKWD | CHKALIAS; - if (!nlflag && (erflag ? peektoken() == TEOF : - tokendlist[peektoken()])) + if (!nlflag && tokendlist[peektoken()]) return ntop; break; case TEOF: @@ -294,7 +293,7 @@ list(int nlflag, int erflag) pungetc(); /* push back EOF on input */ return ntop; default: - if (nlflag || erflag) + if (nlflag) synexpect(-1); tokpushback++; return ntop; @@ -402,22 +401,22 @@ command(void) case TIF: n1 = (union node *)stalloc(sizeof (struct nif)); n1->type = NIF; - if ((n1->nif.test = list(0, 0)) == NULL) + if ((n1->nif.test = list(0)) == NULL) synexpect(-1); consumetoken(TTHEN); - n1->nif.ifpart = list(0, 0); + n1->nif.ifpart = list(0); n2 = n1; while (readtoken() == TELIF) { n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif)); n2 = n2->nif.elsepart; n2->type = NIF; - if ((n2->nif.test = list(0, 0)) == NULL) + if ((n2->nif.test = list(0)) == NULL) synexpect(-1); consumetoken(TTHEN); - n2->nif.ifpart = list(0, 0); + n2->nif.ifpart = list(0); } if (lasttoken == TELSE) - n2->nif.elsepart = list(0, 0); + n2->nif.elsepart = list(0); else { n2->nif.elsepart = NULL; tokpushback++; @@ -428,10 +427,10 @@ command(void) case TWHILE: case TUNTIL: t = lasttoken; - if ((n1 = list(0, 0)) == NULL) + if ((n1 = list(0)) == NULL) synexpect(-1); consumetoken(TDO); - n1 = makebinary((t == TWHILE)? NWHILE : NUNTIL, n1, list(0, 0)); + n1 = makebinary((t == TWHILE)? NWHILE : NUNTIL, n1, list(0)); consumetoken(TDONE); checkkwd = CHKKWD | CHKALIAS; break; @@ -478,7 +477,7 @@ command(void) t = TEND; else synexpect(-1); - n1->nfor.body = list(0, 0); + n1->nfor.body = list(0); consumetoken(t); checkkwd = CHKKWD | CHKALIAS; break; @@ -509,7 +508,7 @@ command(void) ap->narg.next = NULL; if (lasttoken != TRP) synexpect(TRP); - cp->nclist.body = list(0, 0); + cp->nclist.body = list(0); checkkwd = CHKNL | CHKKWD | CHKALIAS; if ((t = readtoken()) != TESAC) { @@ -529,14 +528,14 @@ command(void) case TLP: n1 = (union node *)stalloc(sizeof (struct nredir)); n1->type = NSUBSHELL; - n1->nredir.n = list(0, 0); + n1->nredir.n = list(0); n1->nredir.redirect = NULL; consumetoken(TRP); checkkwd = CHKKWD | CHKALIAS; is_subshell = 1; break; case TBEGIN: - n1 = list(0, 0); + n1 = list(0); consumetoken(TEND); checkkwd = CHKKWD | CHKALIAS; break; @@ -1060,11 +1059,13 @@ done: doprompt = 0; } - n = list(0, oldstyle); + n = list(0); - if (oldstyle) + if (oldstyle) { + if (peektoken() != TEOF) + synexpect(-1); doprompt = saveprompt; - else + } else consumetoken(TRP); (*nlpp)->n = n;