Diff for /rpl/src/formateur.c between versions 1.3 and 1.18

version 1.3, 2010/01/29 16:49:23 version 1.18, 2010/08/26 19:07:35
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.0.10    RPL/2 (R) version 4.0.19
   Copyright (C) 1989-2010 Dr. BERTRAND Joël    Copyright (C) 1989-2010 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
Line 20 Line 20
 */  */
   
   
 #include "rpl.conv.h"  #include "rpl-conv.h"
   
   
 /*  /*
Line 67  formateur(struct_processus *s_etat_proce Line 67  formateur(struct_processus *s_etat_proce
     unsigned char               *format_majuscule;      unsigned char               *format_majuscule;
     unsigned char               *ptre;      unsigned char               *ptre;
     unsigned char               *ptrl;      unsigned char               *ptrl;
       unsigned char               *ptr_ecriture;
       unsigned char               *ptr_lecture;
     unsigned char               *registre;      unsigned char               *registre;
     unsigned char               tampon[1024 + 1];      unsigned char               tampon[1024 + 1];
   
Line 188  formateur(struct_processus *s_etat_proce Line 190  formateur(struct_processus *s_etat_proce
 #           ifdef POSTGRESQL_SUPPORT  #           ifdef POSTGRESQL_SUPPORT
             if (alsprintf(&chaine, "Sql $ %016lX (%s)",              if (alsprintf(&chaine, "Sql $ %016lX (%s)",
                     (long unsigned int) (*((struct_connecteur_sql *)                      (long unsigned int) (*((struct_connecteur_sql *)
                     (*s_objet).objet)).descripteur.mysql,                      (*s_objet).objet)).descripteur.postgresql,
                     (*((struct_connecteur_sql *) (*s_objet).objet)).type) < 0)                      (*((struct_connecteur_sql *) (*s_objet).objet)).type) < 0)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;                  (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
Line 1750  formateur(struct_processus *s_etat_proce Line 1752  formateur(struct_processus *s_etat_proce
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 */  */
   
         chaine = (unsigned char *) malloc((strlen((unsigned char *)          if ((chaine = malloc((strlen((unsigned char *)
                 ((*s_objet).objet)) + 1) * sizeof(unsigned char));                  ((*s_objet).objet)) + 1) * sizeof(unsigned char))) == NULL)
   
         if (chaine == NULL)  
         {          {
             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;              (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
             return(NULL);              return(NULL);
         }          }
   
         strcpy(chaine, (unsigned char *) ((*s_objet).objet));          if ((*s_etat_processus).autorisation_conversion_chaine == 'Y')
           {
               ptr_lecture = (unsigned char *) (*s_objet).objet;
               ptr_ecriture = chaine;
   
               while((*ptr_lecture) != d_code_fin_chaine)
               {
                   (*ptr_ecriture) = (*ptr_lecture);
   
                   // Début de la séquence d'échappement
   
                   if ((*ptr_lecture) == '\\')
                   {
                       if ((*(ptr_lecture + 1)) == '"')
                       {
                           ptr_lecture++;
                           (*ptr_ecriture) = '\"';
                       }
                       else if ((*(ptr_lecture + 1)) == 'b')
                       {
                           ptr_lecture++;
                           (*ptr_ecriture) = '\b';
                       }
                       else if ((*(ptr_lecture + 1)) == 'n')
                       {
                           ptr_lecture++;
                           (*ptr_ecriture) = '\n';
                       }
                       else if ((*(ptr_lecture + 1)) == 't')
                       {
                           ptr_lecture++;
                           (*ptr_ecriture) = '\t';
                       }
                       else if ((*(ptr_lecture + 1)) == '\\')
                       {
                           ptr_lecture++;
                       }
                       else
                       {
                           if ((*s_etat_processus).langue == 'F')
                           {
                               printf("+++Information : Séquence d'échappement "
                                       "inconnue [%d]\n", (int) getpid());
                           }
                           else
                           {
                               printf("+++Warning : Unknown escape code "
                                       "[%d]\n", (int) getpid());
                           }
                       }
                   }
   
                   ptr_ecriture++;
                   ptr_lecture++;
               }
   
               (*ptr_ecriture) = d_code_fin_chaine;
   
               if ((chaine = realloc(chaine, (strlen(chaine) + 1) *
                       sizeof(unsigned char))) == NULL)
               {
                   (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                   return(NULL);
               }
           }
           else
           {
               strcpy(chaine, (unsigned char *) ((*s_objet).objet));
           }
     }      }
     else if ((*s_objet).type == CPL)      else if ((*s_objet).type == CPL)
     {      {
Line 3435  formateur_reel(struct_processus *s_etat_ Line 3503  formateur_reel(struct_processus *s_etat_
     logical1                i50;      logical1                i50;
   
     long                    correction;      long                    correction;
       long                    dernier_chiffre_significatif;
     long                    exposant;      long                    exposant;
     long                    longueur_utile;      long                    longueur_utile;
     long                    longueur_utile_limite;      long                    longueur_utile_limite;
Line 3567  formateur_reel(struct_processus *s_etat_ Line 3636  formateur_reel(struct_processus *s_etat_
         }          }
     }      }
   
       // Test portant sur le nombre de chiffres significatifs dans
       // le cas du format STD pour que 1.2E-15 apparaisse en notation
       // SCI car il y a une perte de précision dans l'affichage.
   
       if ((strcmp(mode, "STD") == 0) && (type == 'R'))
       {
           if (abs(*((real8 *) valeur_numerique)) < 1)
           {
               dernier_chiffre_significatif = -exposant;
               sprintf(tampon, ".%f", mantisse);
   
               ptr = &(tampon[strlen(tampon) - 1]);
   
               while((*ptr) != '.')
               {
                   if ((*ptr) != '0')
                   {
                       dernier_chiffre_significatif++;
                   }
   
                   ptr--;
               }
           }
           else
           {
               dernier_chiffre_significatif = 0;
           }
       }
       else
       {
           dernier_chiffre_significatif = 0;
       }
   
     if ((strcmp(mode, "SCI") == 0) ||      if ((strcmp(mode, "SCI") == 0) ||
             ((strcmp(mode, "STD") == 0) && ((exposant >              ((strcmp(mode, "STD") == 0) && ((exposant >
             longueur_utile_limite) ||              longueur_utile_limite) || (dernier_chiffre_significatif > 15) ||
             (exposant < -longueur_utile_limite))) ||              (exposant < -longueur_utile_limite))) ||
             ((strcmp(mode, "FIX") == 0) &&              ((strcmp(mode, "FIX") == 0) &&
             ((exposant >= longueur_utile_limite) ||              ((exposant >= longueur_utile_limite) ||
Line 3682  formateur_reel(struct_processus *s_etat_ Line 3784  formateur_reel(struct_processus *s_etat_
                 }                  }
             }              }
         }          }
   
         strcpy(chaine, tampon);          strcpy(chaine, tampon);
     }      }
   

Removed from v.1.3  
changed lines
  Added in v.1.18


CVSweb interface <joel.bertrand@systella.fr>