trc: fix local variables in functions - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 362264eb516483d6e2f45ba1e0ab6bcaf2d4f0ee
 (DIR) parent 0e430b25b21cb9e08ccb46c7c5202cd10c13e1dd
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Thu, 14 Aug 2008 10:29:29 -0400
       
       rc: fix local variables in functions
       
       reported by micah stetson:
       
       fn foo { echo $bar }
       bar=baz foo
       
       Diffstat:
         M src/cmd/rc/code.c                   |       6 +++---
         M src/cmd/rc/simple.c                 |       2 +-
       
       2 files changed, 4 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/rc/code.c b/src/cmd/rc/code.c
       t@@ -339,9 +339,9 @@ outcode(tree *t, int eflag)
                                        outcode(c0, eflag);
                                        emitf(Xlocal);
                                }
       -                        t = tt;
       -                        outcode(c2, eflag);
       -                        for(;t->type=='=';t = c2) emitf(Xunlocal);
       +                        outcode(t, eflag);
       +                        for(t = tt; t->type=='='; t = c2)
       +                                emitf(Xunlocal);
                        }
                        else{
                                for(t = tt;t;t = c2){
 (DIR) diff --git a/src/cmd/rc/simple.c b/src/cmd/rc/simple.c
       t@@ -130,7 +130,7 @@ execfunc(var *func)
                starval = runq->argv->words;
                runq->argv->words = 0;
                poplist();
       -        start(func->fn, func->pc, (struct var *)0);
       +        start(func->fn, func->pc, runq->local);
                runq->local = newvar(strdup("*"), runq->local);
                runq->local->val = starval;
                runq->local->changed = 1;