Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Apr 2017 13:43:45 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316417 - head/bin/sh
Message-ID:  <201704021343.v32Dhjht012121@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Apr  2 13:43:45 2017
New Revision: 316417
URL: https://svnweb.freebsd.org/changeset/base/316417

Log:
  sh: Don't scan word twice in ${param=word}.

Modified:
  head/bin/sh/expand.c

Modified: head/bin/sh/expand.c
==============================================================================
--- head/bin/sh/expand.c	Sun Apr  2 13:29:27 2017	(r316416)
+++ head/bin/sh/expand.c	Sun Apr  2 13:43:45 2017	(r316417)
@@ -98,8 +98,8 @@ static const char *expari(const char *, 
 static void expbackq(union node *, int, int, struct worddest *);
 static const char *subevalvar_trim(const char *, struct nodelist **restrict,
     int, int, int);
-static void subevalvar_misc(const char *, struct nodelist *, const char *, int,
-    int, int);
+static const char *subevalvar_misc(const char *, struct nodelist **restrict,
+    const char *, int, int, int);
 static const char *evalvar(const char *, struct nodelist **restrict, int,
     struct worddest *);
 static int varisset(const char *, int);
@@ -615,15 +615,14 @@ subevalvar_trim(const char *p, struct no
 }
 
 
-static void
-subevalvar_misc(const char *p, struct nodelist *argbackq, const char *var, int subtype, int startloc,
-  int varflags)
+static const char *
+subevalvar_misc(const char *p, struct nodelist **restrict argbackq,
+    const char *var, int subtype, int startloc, int varflags)
 {
 	char *startp;
-	struct nodelist *argbackqcopy = argbackq;
 	int amount;
 
-	argstr(p, &argbackqcopy, EXP_TILDE, NULL);
+	p = argstr(p, argbackq, EXP_TILDE, NULL);
 	STACKSTRNUL(expdest);
 	startp = stackblock() + startloc;
 
@@ -632,7 +631,7 @@ subevalvar_misc(const char *p, struct no
 		setvar(var, startp, 0);
 		amount = startp - expdest;
 		STADJUST(amount, expdest);
-		return;
+		return p;
 
 	case VSQUESTION:
 		if (*p != CTLENDVAR) {
@@ -677,7 +676,6 @@ evalvar(const char *p, struct nodelist *
 	if (! is_name(*p))
 		special = 1;
 	p = strchr(p, '=') + 1;
-again: /* jump here after setting a variable with ${var=text} */
 	if (varflags & VSLINENO) {
 		set = 1;
 		special = 1;
@@ -786,11 +784,12 @@ again: /* jump here after setting a vari
 	case VSASSIGN:
 	case VSQUESTION:
 		if (!set) {
-			subevalvar_misc(p, *argbackq, var, subtype,
+			p = subevalvar_misc(p, argbackq, var, subtype,
 			    startloc, varflags);
 			/* assert(subtype == VSASSIGN); */
-			varflags &= ~VSNUL;
-			goto again;
+			val = lookupvar(var);
+			strtodest(val, flag, subtype, varflags & VSQUOTE, dst);
+			return p;
 		}
 		break;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704021343.v32Dhjht012121>