summaryrefslogtreecommitdiff
path: root/lib/pile.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pile.c')
-rw-r--r--lib/pile.c29
1 files changed, 28 insertions, 1 deletions
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;
+}