M eval.c => eval.c +1 -1
@@ 202,7 202,7 @@ popcall(CallStack *s, Symtab *t, ByteCode **c, uvlong *o)
static void
pushlocal(CallStack *c, Symtab *s, uvlong id)
{
- CallFrame f = c->frames[s->count-1];
+ CallFrame f = c->frames[c->count-1];
f.locals->count++;
f.locals->list = allocextra(f.locals, sizeof(Local) * f.locals->count);
M fns.h => fns.h +1 -1
@@ 45,7 45,7 @@ void *symval(Symtab *, uvlong);
void symset(Symtab *, uvlong, void *);
Symbol *symptr(Symtab *, uvlong);
-Enumeration *enumsymbols(Symtab *);
+Enumeration *enumsymbols(Symtab *, int);
/* systemcmd.c */
void systemcmd(Session *, char *, int);
M fs.c => fs.c +2 -2
@@ 373,7 373,7 @@ fswalk1(Fid *fid, char *name, Qid *qid)
*qid = m->qsession;
else{
int found = 0;
- e = enumsymbols(m->symtab);
+ e = enumsymbols(m->symtab, 1);
for(uvlong i = 0; i < e->count && !found; i++){
Symbol *symb = e->items[i];
if(strcmp(name, symb->name) == 0){
@@ 510,7 510,7 @@ fsread(Req *r)
dirread9p(r, modulesgen, e);
break;
case Qmodule:
- e = enumsymbols(aux->module->symtab);
+ e = enumsymbols(aux->module->symtab, 0);
dirread9p(r, symbolsgen, e);
break;
case Qnew:
M symtab.c => symtab.c +18 -4
@@ 82,12 82,26 @@ symset(Symtab *s, uvlong id, void *newval)
}
Enumeration *
-enumsymbols(Symtab *symtab)
+enumsymbols(Symtab *symtab, int all)
{
rlock(&symtab->lock);
- Enumeration *e = allocenum(symtab->count);
- for(uvlong i = 0; i < symtab->count; i++)
- e->items[i] = symtab->symbols[i];
+ uvlong count;
+ if(all)
+ count = symtab->count;
+ else{
+ count = 0;
+ for(uvlong i = 0; i < symtab->count; i++)
+ count += symtab->symbols[i]->value != nil;
+ }
+
+ Enumeration *e = allocenum(count);
+ uvlong j = 0;
+ for(uvlong i = 0; i < symtab->count; i++){
+ if(all || symtab->symbols[i]->value){
+ e->items[j] = symtab->symbols[i];
+ j++;
+ }
+ }
runlock(&symtab->lock);
return e;
}=
\ No newline at end of file