summaryrefslogtreecommitdiff
path: root/lib/pile.c
diff options
context:
space:
mode:
authorPixel <Pixel>2001-05-02 00:18:08 +0000
committerPixel <Pixel>2001-05-02 00:18:08 +0000
commit064a422245f2ef4e881f50350dbbf686283ae310 (patch)
treed6043c3fd05a3f0842ac67cf6f72fa82ddb3e347 /lib/pile.c
parent7dd4d0c7b11f8341fc4f7c357273c4d14f6bb237 (diff)
Pouet
Diffstat (limited to 'lib/pile.c')
-rw-r--r--lib/pile.c44
1 files changed, 26 insertions, 18 deletions
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"));