From owner-svn-src-head@FreeBSD.ORG Sat Nov 26 23:28:32 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1AFA31065675; Sat, 26 Nov 2011 23:28:32 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E51578FC08; Sat, 26 Nov 2011 23:28:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAQNSVWL013119; Sat, 26 Nov 2011 23:28:31 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAQNSVt5013117; Sat, 26 Nov 2011 23:28:31 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201111262328.pAQNSVt5013117@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 26 Nov 2011 23:28:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228013 - head/bin/sh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Nov 2011 23:28:32 -0000 Author: jilles Date: Sat Nov 26 23:28:31 2011 New Revision: 228013 URL: http://svn.freebsd.org/changeset/base/228013 Log: sh: Reduce one level of evaltree() recursion when executing 'case'. Free expanded case text before executing commands. Remove impossible evalskip checks (expanding an argument cannot set evalskip anymore since $(break) and the like are properly executed in a subshell environment). Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Sat Nov 26 23:27:41 2011 (r228012) +++ head/bin/sh/eval.c Sat Nov 26 23:28:31 2011 (r228013) @@ -89,7 +89,7 @@ int oexitstatus; /* saved exit status * static void evalloop(union node *, int); static void evalfor(union node *, int); -static void evalcase(union node *, int); +static union node *evalcase(union node *, int); static void evalsubshell(union node *, int); static void evalredir(union node *, int); static void expredir(union node *); @@ -256,7 +256,7 @@ evaltree(union node *n, int flags) evalfor(n, flags & ~EV_EXIT); break; case NCASE: - evalcase(n, flags); + next = evalcase(n, flags); break; case NDEFUN: defun(n->narg.text, n->narg.next); @@ -370,7 +370,7 @@ out: -static void +static union node * evalcase(union node *n, int flags) { union node *cp; @@ -383,26 +383,24 @@ evalcase(union node *n, int flags) oexitstatus = exitstatus; exitstatus = 0; expandarg(n->ncase.expr, &arglist, EXP_TILDE); - for (cp = n->ncase.cases ; cp && evalskip == 0 ; cp = cp->nclist.next) { + for (cp = n->ncase.cases ; cp ; cp = cp->nclist.next) { for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) { if (casematch(patp, arglist.list->text)) { + popstackmark(&smark); while (cp->nclist.next && cp->type == NCLISTFALLTHRU) { - if (evalskip != 0) - break; evaltree(cp->nclist.body, flags & ~EV_EXIT); + if (evalskip != 0) + return (NULL); cp = cp->nclist.next; } - if (evalskip == 0) { - evaltree(cp->nclist.body, flags); - } - goto out; + return (cp->nclist.body); } } } -out: popstackmark(&smark); + return (NULL); }