64 |
out_hash= out_hash%HASHTBLSIZE; |
out_hash= out_hash%HASHTBLSIZE; |
65 |
position= &(in_hashtbl[out_hash]); |
position= &(in_hashtbl[out_hash]); |
66 |
|
|
67 |
while(position != NULL){ |
while(1){ |
68 |
if(*position==NULL) /* If empty */ |
if(*position==NULL) /* If empty */ |
69 |
return position; |
return position; |
70 |
|
|
73 |
|
|
74 |
position= &((*position)->next); /* Try next */ |
position= &((*position)->next); /* Try next */ |
75 |
} |
} |
|
return NULL; /* end of list reached without finding |
|
|
an empty position */ |
|
76 |
} |
} |
77 |
|
|
78 |
/* Generic push function. */ |
/* Generic push function. */ |
216 |
printf("\"%s\"", (char*)temp->content.ptr); |
printf("\"%s\"", (char*)temp->content.ptr); |
217 |
break; |
break; |
218 |
case symbol: |
case symbol: |
219 |
|
case func: |
220 |
printf("%s", temp->id); |
printf("%s", temp->id); |
221 |
break; |
break; |
222 |
default: |
default: |
285 |
void* delimiter; |
void* delimiter; |
286 |
stackitem *iterator, *temp, *pack; |
stackitem *iterator, *temp, *pack; |
287 |
|
|
|
if((*stack_head)==NULL) { |
|
|
printerr("Stack empty"); |
|
|
return; |
|
|
} |
|
|
|
|
288 |
delimiter= (*stack_head)->content.ptr; /* Get delimiter */ |
delimiter= (*stack_head)->content.ptr; /* Get delimiter */ |
289 |
toss(stack_head); |
toss(stack_head); |
290 |
|
|
291 |
iterator= *stack_head; |
iterator= *stack_head; |
292 |
|
|
293 |
/* Search for first delimiter */ |
if(iterator==NULL || iterator->content.ptr==delimiter) { |
294 |
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) |
|
295 |
toss(stack_head); |
toss(stack_head); |
296 |
|
} else { |
297 |
|
/* Search for first delimiter */ |
298 |
|
while(iterator->next!=NULL && iterator->next->content.ptr!=delimiter) |
299 |
|
iterator= iterator->next; |
300 |
|
|
301 |
|
/* Extract list */ |
302 |
|
temp= *stack_head; |
303 |
|
*stack_head= iterator->next; |
304 |
|
iterator->next= NULL; |
305 |
|
|
306 |
|
if(*stack_head!=NULL && (*stack_head)->content.ptr==delimiter) |
307 |
|
toss(stack_head); |
308 |
|
} |
309 |
|
|
310 |
/* Push list */ |
/* Push list */ |
311 |
pack= malloc(sizeof(stackitem)); |
pack= malloc(sizeof(stackitem)); |
406 |
new_head= temp= (*stack_head)->content.ptr; |
new_head= temp= (*stack_head)->content.ptr; |
407 |
toss(stack_head); |
toss(stack_head); |
408 |
|
|
409 |
|
if(temp==NULL) |
410 |
|
return; |
411 |
|
|
412 |
/* Search the end of the list */ |
/* Search the end of the list */ |
413 |
while(temp->next!=NULL) |
while(temp->next!=NULL) |
414 |
temp= temp->next; |
temp= temp->next; |
505 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
506 |
} |
} |
507 |
|
|
508 |
|
/* Clear stack */ |
509 |
|
extern void clear(stackitem** stack_head) |
510 |
|
{ |
511 |
|
while(*stack_head!=NULL) |
512 |
|
toss(stack_head); |
513 |
|
} |
514 |
|
|
515 |
int main() |
int main() |
516 |
{ |
{ |
517 |
stackitem* s= NULL; |
stackitem* s= NULL; |