From 064a422245f2ef4e881f50350dbbf686283ae310 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 2 May 2001 00:18:08 +0000 Subject: Pouet --- lib/pile.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'lib/pile.c') diff --git a/lib/pile.c b/lib/pile.c index 48bce46..5073127 100644 --- a/lib/pile.c +++ b/lib/pile.c @@ -10,17 +10,14 @@ #include "main.h" #include "parser.h" #include "scalaires.h" -#ifdef HAVE_CONFIG_H #include "config.h" -#else -#define _(x) x -#endif 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; @@ -54,6 +51,10 @@ void push_pile(char *st) popcontext(); } else { /* il s agit d un nom */ pushcontext(_("it's a name")); + if (*st == '\'') { + st++; + st[strlen(st) + 1] = 0; + } push_pile_string(Estrdup(st)); popcontext(); } @@ -142,34 +143,40 @@ void flush_pile(void) 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")); + pushcontext(_("move_to_resultat_pile()")); + if (pile_ptr) { + 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(1, _("move_to_resultat_pile: invalid argument type")); + } + } else { + exception(2, _("move_to_resultat_pile: Stack Overflow")); + } } + popcontext(); } char * pop_resultat(void) { static char result[BUFSIZ]; + pushcontext(_("pop_resultat()")); if (result_pile_ptr) { result_pile_ptr--; - sprintf(result,"%s",ply_affichage(result_pile[result_pile_ptr].poly)); + sprintf(result,"%s", ply_affichage(result_pile[result_pile_ptr].poly)); } else { exception(2, _("move_to_resultat_pile: empty stack")); } + popcontext(); return result; } - - - +int has_resultat(void) { + return (result_pile_ptr ? 1 : 0); +} char *affichage_level_1(void) { @@ -328,6 +335,7 @@ void act_pile(int func) if (valid) SupprimerDansTab(&variables,operande2.label); InsererVarDansTab(&variables, CreerElement(operande2.label, (void *) operande1.poly)); + push_pile(operande2.label); free(operande2.label); } else { exception(1, _("act_pile: OP_ASSIGN empty string")); -- cgit v1.2.3