From owner-svn-src-head@FreeBSD.ORG Tue Mar 4 22:30:38 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EA8886A6; Tue, 4 Mar 2014 22:30:38 +0000 (UTC) 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 BD1273F7; Tue, 4 Mar 2014 22:30:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s24MUc06044900; Tue, 4 Mar 2014 22:30:38 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s24MUckS044898; Tue, 4 Mar 2014 22:30:38 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201403042230.s24MUckS044898@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 4 Mar 2014 22:30:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262755 - 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-head@freebsd.org X-Mailman-Version: 2.1.17 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: Tue, 04 Mar 2014 22:30:39 -0000 Author: jilles Date: Tue Mar 4 22:30:38 2014 New Revision: 262755 URL: http://svnweb.freebsd.org/changeset/base/262755 Log: sh: Make argstr() return where it stopped and simplify expari() using this. Modified: head/bin/sh/expand.c Modified: head/bin/sh/expand.c ============================================================================== --- head/bin/sh/expand.c Tue Mar 4 21:51:11 2014 (r262754) +++ head/bin/sh/expand.c Tue Mar 4 22:30:38 2014 (r262755) @@ -98,7 +98,7 @@ static struct ifsregion ifsfirst; /* fir static struct ifsregion *ifslastp; /* last struct in list */ static struct arglist exparg; /* holds expanded arg list */ -static void argstr(char *, int); +static char *argstr(char *, int); static char *exptilde(char *, int); static char *expari(char *); static void expbackq(union node *, int, int); @@ -213,7 +213,7 @@ expandarg(union node *arg, struct arglis * characters to allow for further processing. * If EXP_FULL is set, also preserve CTLQUOTEMARK characters. */ -static void +static char * argstr(char *p, int flag) { char c; @@ -231,9 +231,10 @@ argstr(char *p, int flag) CHECKSTRSPACE(2, expdest); switch (c = *p++) { case '\0': + return (p - 1); case CTLENDVAR: case CTLENDARI: - goto breakloop; + return (p); case CTLQUOTEMARK: lit_quoted = 1; /* "$@" syntax adherence hack */ @@ -290,7 +291,6 @@ argstr(char *p, int flag) expdest - stackblock(), 0); } } -breakloop:; } /* @@ -399,13 +399,11 @@ expari(char *p) arith_t result; int begoff; int quoted; - int c; - int nesting; int adj; quoted = *p++ == '"'; begoff = expdest - stackblock(); - argstr(p, 0); + p = argstr(p, 0); removerecordregions(begoff); STPUTC('\0', expdest); start = stackblock() + begoff; @@ -424,20 +422,6 @@ expari(char *p) STADJUST(adj, expdest); if (!quoted) recordregion(begoff, expdest - stackblock(), 0); - nesting = 1; - while (nesting > 0) { - c = *p++; - if (c == CTLESC) - p++; - else if (c == CTLARI) - nesting++; - else if (c == CTLENDARI) - nesting--; - else if (c == CTLVAR) - p++; /* ignore variable substitution byte */ - else if (c == '\0') - return p - 1; - } return p; }