Diff for /rpl/src/transliteration.c between versions 1.8 and 1.42

version 1.8, 2010/04/07 13:45:11 version 1.42, 2011/09/20 08:56:24
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.0.14    RPL/2 (R) version 4.1.3
   Copyright (C) 1989-2010 Dr. BERTRAND Joël    Copyright (C) 1989-2011 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"
 #include "tex.conv.h"  #include "tex-conv.h"
   
 #include <stdarg.h>  #include <stdarg.h>
   
Line 105  reencodage(struct_processus *s_etat_proc Line 105  reencodage(struct_processus *s_etat_proc
   
     chaine_sortie[0] = d_code_fin_chaine;      chaine_sortie[0] = d_code_fin_chaine;
   
     if ((buffer_sortie = malloc((d_LONGUEUR + 1) * sizeof(char))) == NULL)      if ((buffer_sortie = malloc((d_LONGUEUR + 1) * sizeof(unsigned char)))
               == NULL)
     {      {
         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;          (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
         return(NULL);          return(NULL);
Line 131  reencodage(struct_processus *s_etat_proc Line 132  reencodage(struct_processus *s_etat_proc
             }              }
         }          }
   
         tampon = (unsigned char *) chaine_sortie;          tampon = chaine_sortie;
         (*pointeur) = d_code_fin_chaine;          (*pointeur) = d_code_fin_chaine;
   
         if ((chaine_sortie = malloc((strlen(tampon) + strlen(buffer_sortie) + 1)          if ((chaine_sortie = malloc((strlen(tampon) + strlen(buffer_sortie) + 1)
Line 175  localisation_courante(struct_processus * Line 176  localisation_courante(struct_processus *
     int                         pipes_sortie[2];      int                         pipes_sortie[2];
     int                         status;      int                         status;
   
     logical1                    drapeau_fin;  
   
     long                        i;      long                        i;
     long                        nombre_arguments;      long                        nombre_arguments;
   
     pid_t                       pid;      pid_t                       pid;
   
     sigset_t                    oldset;  
     sigset_t                    set;  
   
     struct sigaction            action_passee;      struct sigaction            action_passee;
   
     unsigned char               *tampon;      unsigned char               *tampon;
Line 216  localisation_courante(struct_processus * Line 212  localisation_courante(struct_processus *
     arguments[2] = NULL;      arguments[2] = NULL;
   
     nombre_arguments = 2;      nombre_arguments = 2;
     drapeau_fin = d_faux;  
   
     if (pipe(pipes_entree) != 0)      if (pipe(pipes_entree) != 0)
     {      {
Line 236  localisation_courante(struct_processus * Line 231  localisation_courante(struct_processus *
         return;          return;
     }      }
   
     sigfillset(&set);  
     pthread_sigmask(SIG_BLOCK, &set, &oldset);  
   
     verrouillage_threads_concurrents(s_etat_processus);      verrouillage_threads_concurrents(s_etat_processus);
     pid = fork();      pid = fork();
     deverrouillage_threads_concurrents(s_etat_processus);      deverrouillage_threads_concurrents(s_etat_processus);
   
     pthread_sigmask(SIG_SETMASK, &oldset, NULL);  
     sigpending(&set);  
   
     if (pid < 0)      if (pid < 0)
     {      {
         if (close(pipes_entree[0]) != 0)          if (close(pipes_entree[0]) != 0)
Line 407  localisation_courante(struct_processus * Line 396  localisation_courante(struct_processus *
              * Récupération de la valeur de retour du processus détaché               * Récupération de la valeur de retour du processus détaché
              */               */
   
             if (sem_post(&((*s_etat_processus).semaphore_fork))              if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
                     != 0)  
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_processus;                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 return;                  return;
Line 416  localisation_courante(struct_processus * Line 404  localisation_courante(struct_processus *
   
             if (waitpid(pid, &status, 0) == -1)              if (waitpid(pid, &status, 0) == -1)
             {              {
                 if (sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)                  if (sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
                 {                  {
                     if (errno != EINTR)                      (*s_etat_processus).erreur_systeme = d_es_processus;
                     {                      return;
                         (*s_etat_processus).erreur_systeme = d_es_processus;  
                         return;  
                     }  
                 }                  }
   
                 (*s_etat_processus).erreur_systeme = d_es_processus;                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 return;                  return;
             }              }
   
             if (sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)              if (sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
             {              {
                 if (errno != EINTR)                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 {                  return;
                     (*s_etat_processus).erreur_systeme = d_es_processus;  
                     return;  
                 }  
             }              }
         } while((!WIFEXITED(status)) && (!WIFSIGNALED(status)));          } while((!WIFEXITED(status)) && (!WIFSIGNALED(status)));
   
Line 450  localisation_courante(struct_processus * Line 432  localisation_courante(struct_processus *
             return;              return;
         }          }
   
           tampon[0] = d_code_fin_chaine;
   
         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)          if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_processus;              (*s_etat_processus).erreur_systeme = d_es_processus;
Line 460  localisation_courante(struct_processus * Line 444  localisation_courante(struct_processus *
                 pipes_sortie[0], &(tampon[pointeur]),                  pipes_sortie[0], &(tampon[pointeur]),
                 longueur_lecture)) > 0)                  longueur_lecture)) > 0)
         {          {
             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)              if (sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
             {              {
                 if (errno != EINTR)                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 {                  return;
                     (*s_etat_processus).erreur_systeme = d_es_processus;  
                     return;  
                 }  
             }              }
   
             tampon[pointeur + ios] = d_code_fin_chaine;              tampon[pointeur + ios] = d_code_fin_chaine;
Line 489  localisation_courante(struct_processus * Line 470  localisation_courante(struct_processus *
             }              }
         }          }
   
         while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)          if (sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
         {          {
             if (errno != EINTR)              (*s_etat_processus).erreur_systeme = d_es_processus;
             {              return;
                 (*s_etat_processus).erreur_systeme = d_es_processus;  
                 return;  
             }  
         }          }
   
         if (strlen(tampon) == 0)          if (strlen(tampon) == 0)
Line 518  localisation_courante(struct_processus * Line 496  localisation_courante(struct_processus *
             return;              return;
         }          }
   
         (*s_etat_processus).localisation = tampon;          if (strlen(tampon) > 0)
           {
               (*s_etat_processus).localisation = tampon;
           }
           else
           {
               free(tampon);
   
               if (((*s_etat_processus).localisation = malloc((strlen(d_locale)
                       + 1) * sizeof(unsigned char))) == NULL)
               {
                   (*s_etat_processus).erreur_systeme = d_es_processus;
                   return;
               }
   
               strcpy((*s_etat_processus).localisation, d_locale);
           }
   
         if (sigaction(SIGINT, &action_passee, NULL) != 0)          if (sigaction(SIGINT, &action_passee, NULL) != 0)
         {          {
Line 549  localisation_courante(struct_processus * Line 543  localisation_courante(struct_processus *
         {          {
             // Le processus fils renvoie une erreur.              // Le processus fils renvoie une erreur.
   
             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)              free(tampon);
   
               if (((*s_etat_processus).localisation = malloc((strlen(d_locale)
                       + 1) * sizeof(unsigned char))) == NULL)
             {              {
                 if (errno != EINTR)                  (*s_etat_processus).erreur_systeme = d_es_processus;
                 {                  return;
                     (*s_etat_processus).erreur_systeme = d_es_processus;  
                     return;  
                 }  
             }              }
   
             (*s_etat_processus).erreur_execution = d_ex_erreur_processus;              strcpy((*s_etat_processus).localisation, d_locale);
             return;  
         }          }
   
         while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)          if (sem_wait(&((*s_etat_processus).semaphore_fork)) != 0)
         {          {
             if (errno != EINTR)              (*s_etat_processus).erreur_systeme = d_es_processus;
             {              return;
                 (*s_etat_processus).erreur_systeme = d_es_processus;  
                 return;  
             }  
         }          }
   
         if (close(pipes_erreur[0]) != 0)          if (close(pipes_erreur[0]) != 0)
Line 595  transliterated_fprintf(struct_processus Line 585  transliterated_fprintf(struct_processus
   
     va_start(arguments, format);      va_start(arguments, format);
   
   #   ifdef OS2
       unsigned char       *ptr_e;;
       unsigned char       *ptr_l;;
       unsigned char       *tampon3;
   
       unsigned long       i;
   #   endif
   
     if (valsprintf(&tampon, format, arguments) < 0)      if (valsprintf(&tampon, format, arguments) < 0)
     {      {
         va_end(arguments);          va_end(arguments);
Line 625  transliterated_fprintf(struct_processus Line 623  transliterated_fprintf(struct_processus
         tampon2 = tampon;          tampon2 = tampon;
     }      }
   
   #   ifdef OS2
       if ((flux == stdin) || (flux == stdout))
       {
           i = 0;
           ptr_l = tampon2;
   
           while((*ptr_l) != d_code_fin_chaine)
           {
               if ((*ptr_l) == '\n')
               {
                   i++;
               }
   
               ptr_l++;
           }
   
           if ((tampon3 = malloc((strlen(tampon2) + i + 1) *
                   sizeof(unsigned char))) == NULL)
           {
               (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
               return(NULL);
           }
   
           ptr_e = tampon3;
           ptr_l = tampon2;
   
           while((*ptr_l) != d_code_fin_chaine)
           {
               (*ptr_e) = (*ptr_l);
   
               if ((*ptr_l) == '\n')
               {
                   (*(++ptr_e)) = '\r';
                   ptr_e++;
                   ptr_l++;
               }
               else
               {
                   ptr_e++;
                   ptr_l++;
               }
           }
   
           (*ptr_e) = d_code_fin_chaine;
   
           free(tampon2);
           tampon2 = tampon3;
       }
   #   endif
   
 #   ifdef SunOS  #   ifdef SunOS
     while((ios = fprintf(flux, "%s", tampon2)) < 0)      while((ios = fprintf(flux, "%s", tampon2)) < 0)
     {      {
Line 696  tex_fprintf(struct_processus *s_etat_pro Line 744  tex_fprintf(struct_processus *s_etat_pro
     return(ios);      return(ios);
 }  }
   
   #undef readline
   
   unsigned char *
   readline_wrapper(unsigned char *invite)
   {
       unsigned char       *chaine;
   
       chaine = readline(invite);
       printf("\r");
   
       return(chaine);
   }
   
   
 #define fprintf NULL  #define fprintf NULL
 #define printf NULL  #define printf NULL
   

Removed from v.1.8  
changed lines
  Added in v.1.42


CVSweb interface <joel.bertrand@systella.fr>