--- rpl/src/transliteration.c 2010/04/07 13:45:11 1.8 +++ rpl/src/transliteration.c 2010/09/10 13:41:44 1.23 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.0.14 + RPL/2 (R) version 4.0.19 Copyright (C) 1989-2010 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,8 +20,8 @@ */ -#include "rpl.conv.h" -#include "tex.conv.h" +#include "rpl-conv.h" +#include "tex-conv.h" #include @@ -158,8 +158,8 @@ reencodage(struct_processus *s_etat_proc ================================================================================ Entrées : -------------------------------------------------------------------------------- - Sorties : -------------------------------------------------------------------------------- + iorties : Effets de bord : néant ================================================================================ */ @@ -407,8 +407,11 @@ localisation_courante(struct_processus * * Récupération de la valeur de retour du processus détaché */ - if (sem_post(&((*s_etat_processus).semaphore_fork)) - != 0) +# ifndef SEMAPHORES_NOMMES + if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) +# else + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -416,7 +419,11 @@ localisation_courante(struct_processus * if (waitpid(pid, &status, 0) == -1) { +# ifndef SEMAPHORES_NOMMES if (sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) +# else + if (sem_wait((*s_etat_processus).semaphore_fork) == -1) +# endif { if (errno != EINTR) { @@ -429,7 +436,11 @@ localisation_courante(struct_processus * return; } +# ifndef SEMAPHORES_NOMMES if (sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) +# else + if (sem_wait((*s_etat_processus).semaphore_fork) == -1) +# endif { if (errno != EINTR) { @@ -450,7 +461,13 @@ localisation_courante(struct_processus * return; } + tampon[0] = d_code_fin_chaine; + +# ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) +# else + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -460,7 +477,11 @@ localisation_courante(struct_processus * pipes_sortie[0], &(tampon[pointeur]), longueur_lecture)) > 0) { +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) +# else + while(sem_wait((*s_etat_processus).semaphore_fork) == -1) +# endif { if (errno != EINTR) { @@ -482,14 +503,22 @@ localisation_courante(struct_processus * return; } +# ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) +# else + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; } } +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) +# else + while(sem_wait((*s_etat_processus).semaphore_fork) == -1) +# endif { if (errno != EINTR) { @@ -518,7 +547,23 @@ localisation_courante(struct_processus * 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) { @@ -539,7 +584,11 @@ localisation_courante(struct_processus * free(arguments); +# ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) +# else + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -549,20 +598,23 @@ localisation_courante(struct_processus * { // 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; - return; + strcpy((*s_etat_processus).localisation, d_locale); } +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) +# else + while(sem_wait((*s_etat_processus).semaphore_fork) == -1) +# endif { if (errno != EINTR) { @@ -595,6 +647,14 @@ transliterated_fprintf(struct_processus 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) { va_end(arguments); @@ -625,6 +685,56 @@ transliterated_fprintf(struct_processus 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 while((ios = fprintf(flux, "%s", tampon2)) < 0) { @@ -696,6 +806,20 @@ tex_fprintf(struct_processus *s_etat_pro 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 printf NULL