Fix expanding of quoted positional parameters in case patterns.

Obtained from:	NetBSD (expand.c 1.58 and 1.59)
Submitted by:	Paul Jarc
PR:		56147
This commit is contained in:
Stefan Farfeleder 2006-11-07 22:46:13 +00:00
parent 676b1fbdbf
commit bb4f73cac6

View File

@ -98,7 +98,7 @@ STATIC void expbackq(union node *, int, int);
STATIC int subevalvar(char *, char *, int, int, int, int); STATIC int subevalvar(char *, char *, int, int, int, int);
STATIC char *evalvar(char *, int); STATIC char *evalvar(char *, int);
STATIC int varisset(char *, int); STATIC int varisset(char *, int);
STATIC void varvalue(char *, int, int); STATIC void varvalue(char *, int, int, int);
STATIC void recordregion(int, int, int); STATIC void recordregion(int, int, int);
STATIC void removerecordregions(int); STATIC void removerecordregions(int);
STATIC void ifsbreakup(char *, struct arglist *); STATIC void ifsbreakup(char *, struct arglist *);
@ -633,7 +633,7 @@ evalvar(char *p, int flag)
int easy; int easy;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR); int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR);
varflags = *p++; varflags = (unsigned char)*p++;
subtype = varflags & VSTYPE; subtype = varflags & VSTYPE;
var = p; var = p;
special = 0; special = 0;
@ -669,7 +669,7 @@ evalvar(char *p, int flag)
if (set && subtype != VSPLUS) { if (set && subtype != VSPLUS) {
/* insert the value of the variable */ /* insert the value of the variable */
if (special) { if (special) {
varvalue(var, varflags & VSQUOTE, flag & EXP_FULL); varvalue(var, varflags & VSQUOTE, subtype, flag);
if (subtype == VSLENGTH) { if (subtype == VSLENGTH) {
varlen = expdest - stackblock() - startloc; varlen = expdest - stackblock() - startloc;
STADJUST(-varlen, expdest); STADJUST(-varlen, expdest);
@ -841,7 +841,7 @@ varisset(char *name, int nulok)
*/ */
STATIC void STATIC void
varvalue(char *name, int quoted, int allow_split) varvalue(char *name, int quoted, int subtype, int flag)
{ {
int num; int num;
char *p; char *p;
@ -853,7 +853,7 @@ varvalue(char *name, int quoted, int allow_split)
#define STRTODEST(p) \ #define STRTODEST(p) \
do {\ do {\
if (allow_split) { \ if (flag & (EXP_FULL | EXP_CASE) && subtype != VSLENGTH) { \
syntax = quoted? DQSYNTAX : BASESYNTAX; \ syntax = quoted? DQSYNTAX : BASESYNTAX; \
while (*p) { \ while (*p) { \
if (syntax[(int)*p] == CCTL) \ if (syntax[(int)*p] == CCTL) \
@ -888,7 +888,7 @@ varvalue(char *name, int quoted, int allow_split)
} }
break; break;
case '@': case '@':
if (allow_split && quoted) { if (flag & EXP_FULL && quoted) {
for (ap = shellparam.p ; (p = *ap++) != NULL ; ) { for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
STRTODEST(p); STRTODEST(p);
if (*ap) if (*ap)