PR/4851: Benjamin Lorenz: In the "for <var> in <args>" construct <args>

was not marked as a region to be handled by ifsbreakup. Add EXP_RECORD
to indicate that the argument string needs to be recorded.
This commit is contained in:
christos 1998-01-31 12:45:06 +00:00
parent 2b259b0600
commit 5a36c00160
3 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.39 1997/08/26 20:09:59 thorpej Exp $ */
/* $NetBSD: eval.c,v 1.40 1998/01/31 12:45:06 christos Exp $ */
/*-
* Copyright (c) 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else
__RCSID("$NetBSD: eval.c,v 1.39 1997/08/26 20:09:59 thorpej Exp $");
__RCSID("$NetBSD: eval.c,v 1.40 1998/01/31 12:45:06 christos Exp $");
#endif
#endif /* not lint */
@ -333,7 +333,7 @@ evalfor(n)
arglist.lastp = &arglist.list;
for (argp = n->nfor.args ; argp ; argp = argp->narg.next) {
oexitstatus = exitstatus;
expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
expandarg(argp, &arglist, EXP_FULL | EXP_TILDE | EXP_RECORD);
if (evalskip)
goto out;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.c,v 1.33 1997/12/01 14:43:20 christos Exp $ */
/* $NetBSD: expand.c,v 1.34 1998/01/31 12:45:07 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#else
__RCSID("$NetBSD: expand.c,v 1.33 1997/12/01 14:43:20 christos Exp $");
__RCSID("$NetBSD: expand.c,v 1.34 1998/01/31 12:45:07 christos Exp $");
#endif
#endif /* not lint */
@ -143,12 +143,13 @@ expandarg(arg, arglist, flag)
{
struct strlist *sp;
char *p;
int recorded;
argbackq = arg->narg.backquote;
STARTSTACKSTR(expdest);
ifsfirst.next = NULL;
ifslastp = NULL;
(void)argstr(arg->narg.text, flag);
recorded = argstr(arg->narg.text, flag);
if (arglist == NULL) {
return; /* here document expanded */
}
@ -159,6 +160,8 @@ expandarg(arg, arglist, flag)
* TODO - EXP_REDIR
*/
if (flag & EXP_FULL) {
if (!recorded && (flag & EXP_RECORD))
recordregion(0, expdest - p - 1, 0);
ifsbreakup(p, &exparg);
*exparg.lastp = NULL;
exparg.lastp = &exparg.list;

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.h,v 1.8 1995/05/11 21:29:08 christos Exp $ */
/* $NetBSD: expand.h,v 1.9 1998/01/31 12:45:07 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -57,6 +57,7 @@ struct arglist {
#define EXP_VARTILDE 0x4 /* expand tildes in an assignment */
#define EXP_REDIR 0x8 /* file glob for a redirection (1 match only) */
#define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */
#define EXP_RECORD 0x20 /* need to record arguments for ifs breakup */
union node;