--- rpl/src/formateur.c 2010/02/08 19:26:32 1.4 +++ rpl/src/formateur.c 2010/02/10 08:09:29 1.5 @@ -67,6 +67,8 @@ formateur(struct_processus *s_etat_proce unsigned char *format_majuscule; unsigned char *ptre; unsigned char *ptrl; + unsigned char *ptr_ecriture; + unsigned char *ptr_lecture; unsigned char *registre; unsigned char tampon[1024 + 1]; @@ -1750,16 +1752,82 @@ formateur(struct_processus *s_etat_proce -------------------------------------------------------------------------------- */ - chaine = (unsigned char *) malloc((strlen((unsigned char *) - ((*s_objet).objet)) + 1) * sizeof(unsigned char)); - - if (chaine == NULL) + if ((chaine = malloc((strlen((unsigned char *) + ((*s_objet).objet)) + 1) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; 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) {