Changeset 2520 in Sophya for trunk/SophyaLib/SysTools


Ignore:
Timestamp:
Mar 19, 2004, 9:07:28 AM (22 years ago)
Author:
ansari
Message:

Correction bug traitement signe +/- en debut de nombre - Reza 19/03/2004

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/cexpre.cc

    r2518 r2520  
    311311  size_t p=0, q=0;
    312312  char lastopc=0, opc=0; // Last/current operation sign (+,-,*,/,...)
     313  int osn = 0;
    313314  bool finok = false;
    314315  bool fgcont = true;
     
    344345              }
    345346              else rx = cx;
    346               p = stop+1; lastopc = opc;
     347              p = stop+1; osn = 0; lastopc = opc;
    347348            }
    348349          }
     
    363364            errmsg = "CExpressionEvaluator::ParseString()/ Syntax Error - rx&&cx (B)";
    364365          }
    365           if (q > p) cx = new CE_NumberExp(sex.substr(p,q-p));
     366          if (q > p) cx = new CE_NumberExp(sex.substr(p-osn,q-p+osn));
    366367          else cx = rx;
    367368         
     
    378379            if (opc == ')') { // Signe de fin de traitement d'une portion d'expression
    379380              if (extype == 2) { rx = fx; fx = NULL; }
    380               stop = q;  lastopc = opc;
     381              stop = q;  osn = 0; lastopc = opc;
    381382              fgcont = false;
    382383              finok = true;
     
    384385            else {
    385386              if (q == (len-1)) finok = true;
    386               p = q+1; lastopc = opc;
     387              p = q+1; osn = 0; lastopc = opc;
    387388            }
    388389          }
     
    393394        case '*' :
    394395        case '/' :
    395           // Traitement des signes +/- qui pourrait faire partie d'une constante numerique
    396           if (!( ((opc=='+')||(opc=='-')) && ( (q==off) || ( (q==p) && (rx == NULL) ) ) ) ) {
    397             //            ((lastopc=='+')||(lastopc=='-')||(lastopc=='*')||(lastopc=='/')) ) ) ) ) {
     396          if (!( ((opc=='+')||(opc=='-')) && ( (q==off) || ( (q==p) && lastopc != '(') ) ) ) {
    398397            CE_BinExp* nbx;
    399398            if (opc == '+')  nbx = new CE_AddExp; 
     
    402401            else  nbx =  new CE_DivExp; 
    403402            if ((p == q) && (rx == NULL)) {
    404               checkok = false; p = q;  fgcont = false;
     403              checkok = false; p = q;  osn = 0; fgcont = false;
    405404              delete nbx;
    406405              errmsg = "CExpressionEvaluator::ParseString() Syntax Error - rx==NULL (C)";
     
    408407            else {
    409408              if (p == q)  cx = rx;
    410               else cx = new CE_NumberExp(sex.substr(p,q-p));
     409              else cx = new CE_NumberExp(sex.substr(p-osn,q-p+osn));
    411410              rx = Arrange_CE_BinExpStack(sbx, cx, nbx);
    412               p = q+1;  lastopc = opc;
    413             }
     411              p = q+1;  osn = 0; lastopc = opc;
     412            }
     413          }
     414          else {
     415          // Traitement des signes +/- qui pourrait faire partie d'une constante numerique
     416            p = q+1;  osn++;
     417            continue;
    414418          }
    415419          break;
     
    425429      }
    426430      else {
    427         if (p<len)  cx = new CE_NumberExp(sex.substr(p));
     431        if (p<len)  cx = new CE_NumberExp(sex.substr(p-osn));
    428432        else cx = rx;
    429433        rx = Arrange_CE_BinExpStack(sbx, cx);
Note: See TracChangeset for help on using the changeset viewer.