From ec32dd3c2506d341fe7106418f0e538f9407fbce Mon Sep 17 00:00:00 2001 From: biouman Date: Tue, 1 May 2001 22:50:42 +0000 Subject: *** empty log message *** --- include/pile.h | 7 +++++++ lib/pile.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/pile.h b/include/pile.h index d2e3176..031424f 100644 --- a/include/pile.h +++ b/include/pile.h @@ -36,4 +36,11 @@ int is_mute(char *st); void act_pile(int func); void affichage_pile(void); + +void move_to_resultat_pile(void); + +char * pop_resultat(void); + + + #endif diff --git a/lib/pile.c b/lib/pile.c index 10991fc..48bce46 100644 --- a/lib/pile.c +++ b/lib/pile.c @@ -18,8 +18,9 @@ pile_elem pile[PILE_MAX]; +pile_elem result_pile[PILE_MAX]; unsigned int pile_ptr = 0; - +unsigned int result_pile_ptr = 0; void push_pile(char *st) { int valid1, valid2, valid3; @@ -138,7 +139,33 @@ void flush_pile(void) pile_ptr=0; } +void move_to_resultat_pile(void) +{ pile_elem temp; + + temp=pop_pile(1); + if (result_pile_ptr!=PILE_MAX) { + if (temp.type==T_POLY) { + result_pile[result_pile_ptr]=temp; + result_pile_ptr++; + } else { + exception(2, _("move_to_resultat_pile: invalid argument type")); + } + } else { + exception(2, _("move_to_resultat_pile: Stack Overflow")); + } +} + +char * pop_resultat(void) +{ static char result[BUFSIZ]; + if (result_pile_ptr) { + result_pile_ptr--; + sprintf(result,"%s",ply_affichage(result_pile[result_pile_ptr].poly)); + } else { + exception(2, _("move_to_resultat_pile: empty stack")); + } + return result; +} -- cgit v1.2.3