diff options
author | jilles <jilles@FreeBSD.org> | 2014-03-04 22:30:38 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2014-03-04 22:30:38 +0000 |
commit | c2f01aba00bf80f973e7d1f333673e769a25f464 (patch) | |
tree | a8109f308034f0162fff1ad11068e8b314ce0b74 /bin | |
parent | f5b5735c745aa7c33412c089be333a2b60a48761 (diff) | |
download | FreeBSD-src-c2f01aba00bf80f973e7d1f333673e769a25f464.zip FreeBSD-src-c2f01aba00bf80f973e7d1f333673e769a25f464.tar.gz |
sh: Make argstr() return where it stopped and simplify expari() using this.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/expand.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c index cad0116..6ef9b0e 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -98,7 +98,7 @@ static struct ifsregion ifsfirst; /* first struct in list of ifs regions */ 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 arglist *arglist, int flag) * 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; } |