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

Diff of /stack/stack.c

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

revision 1.23 by masse, Sat Feb 2 18:36:19 2002 UTC revision 1.24 by masse, Sat Feb 2 19:30:07 2002 UTC
# Line 286  extern void pack(stackitem** stack_head) Line 286  extern void pack(stackitem** stack_head)
286    void* delimiter;    void* delimiter;
287    stackitem *iterator, *temp, *pack;    stackitem *iterator, *temp, *pack;
288    
   if((*stack_head)==NULL) {  
     printerr("Stack empty");  
     return;  
   }  
   
289    delimiter= (*stack_head)->content.ptr; /* Get delimiter */    delimiter= (*stack_head)->content.ptr; /* Get delimiter */
290    toss(stack_head);    toss(stack_head);
291    
292    iterator= *stack_head;    iterator= *stack_head;
293    
294    /* Search for first delimiter */    if(iterator==NULL || iterator->content.ptr==delimiter) {
295    while(iterator->next!=NULL && iterator->next->content.ptr!=delimiter)      temp= NULL;
     iterator= iterator->next;  
   
   /* Extract list */  
   temp= *stack_head;  
   *stack_head= iterator->next;  
   iterator->next= NULL;  
     
   if(*stack_head!=NULL && (*stack_head)->content.ptr==delimiter)  
296      toss(stack_head);      toss(stack_head);
297      } else {
298        /* Search for first delimiter */
299        while(iterator->next!=NULL && iterator->next->content.ptr!=delimiter)
300          iterator= iterator->next;
301        
302        /* Extract list */
303        temp= *stack_head;
304        *stack_head= iterator->next;
305        iterator->next= NULL;
306        
307        if(*stack_head!=NULL && (*stack_head)->content.ptr==delimiter)
308          toss(stack_head);
309      }
310    
311    /* Push list */    /* Push list */
312    pack= malloc(sizeof(stackitem));    pack= malloc(sizeof(stackitem));
# Line 407  extern void expand(stackitem** stack_hea Line 407  extern void expand(stackitem** stack_hea
407    new_head= temp= (*stack_head)->content.ptr;    new_head= temp= (*stack_head)->content.ptr;
408    toss(stack_head);    toss(stack_head);
409    
410      if(temp==NULL)
411        return;
412    
413    /* Search the end of the list */    /* Search the end of the list */
414    while(temp->next!=NULL)    while(temp->next!=NULL)
415      temp= temp->next;      temp= temp->next;
# Line 503  extern void quit() Line 506  extern void quit()
506    exit(EXIT_SUCCESS);    exit(EXIT_SUCCESS);
507  }  }
508    
509    /* Clear stack */
510    extern void clear(stackitem** stack_head)
511    {
512      while(*stack_head!=NULL)
513        toss(stack_head);
514    }
515    
516  int main()  int main()
517  {  {
518    stackitem* s= NULL;    stackitem* s= NULL;

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

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26