From 51a7864b4b789583ea445af47324a9b613336162 Mon Sep 17 00:00:00 2001 From: biouman Date: Mon, 30 Apr 2001 01:21:20 +0000 Subject: *** empty log message *** --- lib/pile.c | 79 +++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 34 deletions(-) (limited to 'lib/pile.c') diff --git a/lib/pile.c b/lib/pile.c index c3f6644..4e510b3 100644 --- a/lib/pile.c +++ b/lib/pile.c @@ -26,41 +26,44 @@ void push_pile(char *st) int valid1, valid2, valid3; char valid4=0; int i_number; - double d_number; + rationnel r_number; polynome poly; char buf[128]; - sprintf(buf,"appel à push_pile(%s)",st); + sprintf(buf,_("Calling push_pile(%s)"),st); pushcontext(buf); i_number = char_to_number(st, &valid1); - d_number = char_to_double(st, &valid2); + r_number = char_to_rat(st, &valid2); valid3 = is_mute(st); poly = (polynome) NomVarToVar(st, variables, &valid4); if (valid1) { /* il s agit d un entier */ - pushcontext("c est un entier"); + pushcontext(_("it's an integer")); push_pile_poly(ply_constr(rat_constr(i_number, 1), 0)); popcontext(); } else if (valid2) { /* il s agit d un flottant */ - pushcontext("c est un flottant"); - push_pile_poly(ply_constr(rat_constr_from_double(d_number), 0)); + pushcontext(_("it's a float")); + push_pile_poly(ply_constr(r_number, 0)); popcontext(); } else if (valid3) { /* il s agit de x */ - pushcontext("c est X"); + pushcontext(_("it's X")); push_pile_poly(ply_constr(rat_constr(1, 1), 1)); popcontext(); } else if (valid4) { /* il s agit d une variable */ - pushcontext("c est une variable"); + pushcontext(_("it's a variable")); push_pile_poly(ply_copy(poly)); popcontext(); } else { /* il s agit d un nom */ - pushcontext("c est un nom"); + pushcontext(_("it's a name")); push_pile_string(Estrdup(st)); popcontext(); } popcontext(); - affichage_pile(); - fprintf(stderr, "sortie de push_pile\n"); + +#ifdef DEBUG + + fprintf(stderr, "exiting push_pile\n"); +#endif } @@ -78,7 +81,6 @@ void push_pile_poly(polynome poly) void push_pile_int(int val) { - fprintf(stderr,"%d",val); if (pile_ptr != PILE_MAX) { pile[pile_ptr].type = T_INT; pile[pile_ptr].val = val; @@ -137,7 +139,7 @@ char *affichage_level_1(void) } int is_mute(char *st) -{ /* FIXME: test lowercase / uppercase */ +{ return !(strcmp(st, mute)); } @@ -148,12 +150,16 @@ void act_pile(int func) pile_elem operande1, operande2; char buf[50]; - sprintf(buf, _("Calling act_pile(%i)\n"), func); + sprintf(buf, _("Calling act_pile(%i)"), func); pushcontext(buf); +#ifdef DEBUG affichage_pile(); +#endif switch (func) { case OP_PLUS: +#ifdef DEBUG printf("----- OP_PLUS\n"); +#endif operande1 = pop_pile(1); operande2 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { @@ -167,9 +173,11 @@ void act_pile(int func) } break; case OP_MOINS: +#ifdef DEBUG printf("----- OP_MOINS\n"); - operande1 = pop_pile(1); +#endif operande2 = pop_pile(1); + operande1 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { push_pile_poly(ply_soustraction(operande1.poly, operande2.poly)); if (operande1.poly) @@ -181,7 +189,9 @@ void act_pile(int func) } break; case OP_MUL: +#ifdef DEBUG printf("----- OP_MUL\n"); +#endif operande1 = pop_pile(1); operande2 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { @@ -195,9 +205,11 @@ void act_pile(int func) } break; case OP_DIV: +#ifdef DEBUG printf("----- OP_DIV\n"); - operande1 = pop_pile(1); +#endif operande2 = pop_pile(1); + operande1 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { push_pile_poly(ply_division(operande1.poly, operande2.poly)); if (operande1.poly) @@ -209,9 +221,11 @@ void act_pile(int func) } break; case OP_MOD: +#ifdef DEBUG printf("----- OP_MOD\n"); - operande1 = pop_pile(1); +#endif operande2 = pop_pile(1); + operande1 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { push_pile_poly(ply_modulo(operande1.poly, operande2.poly)); if (operande1.poly) @@ -223,7 +237,9 @@ void act_pile(int func) } break; case OP_EXP: +#ifdef DEBUG printf("----- OP_EXP\n"); +#endif operande1 = pop_pile(1); operande2 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { @@ -246,7 +262,9 @@ void act_pile(int func) } break; case OP_ASSIGN: +#ifdef DEBUG printf("----- OP_ASSIGN\n"); +#endif operande1 = pop_pile(1); operande2 = pop_pile(1); if ((operande1.type == T_POLY) && (operande2.type == T_STRING)) { @@ -263,12 +281,14 @@ void act_pile(int func) } break; case OP_PLUS_UNARY: +#ifdef DEBUG printf("----- OP_PLUS_UNARY\n"); - +#endif break; case OP_MOINS_UNARY: +#ifdef DEBUG printf("----- OP_MOINS_UNARY\n"); - +#endif operande1 = pop_pile(1); if (operande1.type == T_POLY) { push_pile_poly(ply_soustraction @@ -280,8 +300,9 @@ void act_pile(int func) } break; case OP_FUNC_CALL: +#ifdef DEBUG printf("----- OP_FUNC_CALL\n"); - +#endif operande1 = pop_pile(1); if ((operande1.type == T_INT) && (operande1.val == 1)) { operande1 = pop_pile(1); @@ -289,19 +310,9 @@ void act_pile(int func) if ((operande1.type == T_POLY) && (operande2.type == T_POLY)) { if (operande2.poly) { if (operande1.poly->degre == 0) { - /*double soja, soja2; - rationnel rat; - polynome pl; - fprintf(stderr,"soja"); - soja=rat_to_double(operande1.poly->coef); - fprintf(stderr,"%f",soja); - soja2=ply_valuation(operande2.poly,soja); - fprintf(stderr,"%f", soja2); - rat=rat_constr_from_double(soja2); - fprintf(stderr,"pl"); - pl=ply_constr(rat, 1);*/ + -push_pile_poly(ply_constr(rat_constr_from_double(ply_valuation(operande2.poly,rat_to_double(operande1.poly->coef))), 0)); + push_pile_poly(ply_constr(rat_constr_from_double(ply_valuation(operande2.poly,rat_to_double(operande1.poly->coef))), 0)); if (operande1.poly) ply_destruct(operande1.poly); @@ -330,7 +341,7 @@ push_pile_poly(ply_constr(rat_constr_from_double(ply_valuation(operande2.poly,ra void affichage_pile(void) { int i; - printf("\t-- affichage de la pile\n"); + printf(_("\t-- Printing Stack\n")); if (pile_ptr) { for (i=0;i<=pile_ptr-1;i++) { switch (pile[i].type) { @@ -346,6 +357,6 @@ void affichage_pile(void) { } } } - printf("\t-- fin d affichage de pile\n"); + printf(_("\t-- End Printing Stack\n")); } -- cgit v1.2.3