/[cvs]/stack/stack.c
ViewVC logotype

Diff of /stack/stack.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by masse, Sat Feb 2 18:11:54 2002 UTC revision 1.23 by masse, Sat Feb 2 18:36:19 2002 UTC
# Line 160  int push_ref(stackitem** stack_head, has Line 160  int push_ref(stackitem** stack_head, has
160      else      else
161        def_sym(in_hash, in_string); /* Make symbol */        def_sym(in_hash, in_string); /* Make symbol */
162                
163      new_item->content.ptr= *hash(in_hash, in_string); /* XXX */      new_item->content.ptr= *hash(in_hash, in_string); /* The new reference
164                                                             shouldn't point at
165                                                             NULL */
166      new_item->type= ref;      new_item->type= ref;
167    }    }
168    
# Line 196  extern void nl() Line 198  extern void nl()
198  }  }
199    
200  /* Prints the top element of the stack. */  /* Prints the top element of the stack. */
201  void print_(stackitem** stack_head)  extern void print_(stackitem** stack_head)
202  {  {
203    if((*stack_head)==NULL) {    stackitem* temp= *stack_head;
204    
205      if(temp==NULL) {
206      printerr("Stack empty");      printerr("Stack empty");
207      return;      return;
208    }    }
209    
210    switch((*stack_head)->type) {    while(temp->type==ref)
211        temp= temp->content.ptr;
212    
213      switch(temp->type) {
214    case value:    case value:
215      printf("%d", (*stack_head)->content.val);      printf("%d", temp->content.val);
216      break;      break;
217    case string:    case string:
218      printf("\"%s\"", (char*)(*stack_head)->content.ptr);      printf("\"%s\"", (char*)temp->content.ptr);
     break;  
   case ref:  
     printf("%s", ((stackitem*)(*stack_head)->content.ptr)->id);  
219      break;      break;
220    case symbol:    case symbol:
221        printf("%s", temp->id);
222        break;
223    default:    default:
224      printf("%p", (*stack_head)->content.ptr);      printf("%p", temp->content.ptr);
225      break;      break;
226    }    }
227  }  }

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26