--- stack/stack.c 2002/01/08 14:17:33 1.8 +++ stack/stack.c 2002/01/08 18:06:19 1.11 @@ -128,10 +128,10 @@ new_item->content.ptr= *hash(in_hash, in_string); new_item->type= ref; - if(handle==NULL) - handle= dlopen(NULL, RTLD_LAZY); - if(new_item->content.ptr==NULL) { + if(handle==NULL) + handle= dlopen(NULL, RTLD_LAZY); + symbol= dlsym(handle, in_string); if(dlerror()==NULL) def_func(in_hash, symbol, in_string); @@ -165,7 +165,7 @@ printf("\n"); } -void prin(stackitem** stack_head) +void print_(stackitem** stack_head) { if((*stack_head)==NULL) return; @@ -189,7 +189,7 @@ extern void print(stackitem** stack_head) { - prin(stack_head); + print_(stack_head); toss(stack_head); } @@ -200,7 +200,7 @@ print_st(stack_head->next, counter+1); printf("%ld: ", counter); - prin(&stack_head); + print_(&stack_head); nl(); } @@ -308,6 +308,52 @@ *stack_head= new_head; } +extern void swap(stackitem** stack_head) +{ + stackitem* temp= (*stack_head); + + if((*stack_head)==NULL || (*stack_head)->next==NULL) + return; + + *stack_head= (*stack_head)->next; + temp->next= (*stack_head)->next; + (*stack_head)->next= temp; +} + +extern void eq(stackitem** stack_head) +{ + void *left, *right; + int result; + + if((*stack_head)==NULL || (*stack_head)->next==NULL) + return; + + left= (*stack_head)->content.ptr; + right= (*stack_head)->next->content.ptr; + result= (left==right); + + toss(stack_head); toss(stack_head); + push_val(stack_head, (left==right)); +} + +extern void not(stackitem** stack_head) +{ + int value; + + if((*stack_head)==NULL) + return; + + value= (*stack_head)->content.val; + toss(stack_head); + push_val(stack_head, !value); +} + +extern void neq(stackitem** stack_head) +{ + eq(stack_head); + not(stack_head); +} + extern void quit() { exit(EXIT_SUCCESS); @@ -328,8 +374,7 @@ printf("okidok\n "); } - - return EXIT_SUCCESS; + exit(EXIT_SUCCESS); } /* Local Variables: */