--- stack/stack.c 2002/02/02 18:11:54 1.22 +++ stack/stack.c 2002/02/02 18:36:19 1.23 @@ -160,7 +160,9 @@ else def_sym(in_hash, in_string); /* Make symbol */ - new_item->content.ptr= *hash(in_hash, in_string); /* XXX */ + new_item->content.ptr= *hash(in_hash, in_string); /* The new reference + shouldn't point at + NULL */ new_item->type= ref; } @@ -196,26 +198,30 @@ } /* Prints the top element of the stack. */ -void print_(stackitem** stack_head) +extern void print_(stackitem** stack_head) { - if((*stack_head)==NULL) { + stackitem* temp= *stack_head; + + if(temp==NULL) { printerr("Stack empty"); return; } - switch((*stack_head)->type) { + while(temp->type==ref) + temp= temp->content.ptr; + + switch(temp->type) { case value: - printf("%d", (*stack_head)->content.val); + printf("%d", temp->content.val); break; case string: - printf("\"%s\"", (char*)(*stack_head)->content.ptr); - break; - case ref: - printf("%s", ((stackitem*)(*stack_head)->content.ptr)->id); + printf("\"%s\"", (char*)temp->content.ptr); break; case symbol: + printf("%s", temp->id); + break; default: - printf("%p", (*stack_head)->content.ptr); + printf("%p", temp->content.ptr); break; } }