--- rpl/src/transliteration.c 2010/02/10 10:14:26 1.4 +++ rpl/src/transliteration.c 2010/02/28 14:47:14 1.5 @@ -21,7 +21,10 @@ #include "rpl.conv.h" +#include "tex.conv.h" + #include + #undef fprintf #undef printf @@ -578,43 +581,21 @@ localisation_courante(struct_processus * return; } -static int -vtransliterated_sprintf(char **strp, const char *fmt, va_list ap) -{ - size_t bs, s; - char *b = NULL; - va_list cap; - - va_copy(cap, ap); - - for(bs = 256;; bs *= 2) - { - va_copy(ap, cap); - if (b != NULL) free(b); - if ((b = malloc(sizeof(*b) * bs)) == NULL) return -1; - if (((int) (s = vsnprintf(b, bs, fmt, ap))) < 0) - { va_end(ap); free(b); return -1; } - va_end(ap); - if (s < bs) break; - } - - if (((*strp) = realloc(b, ((s = strlen(b)) + 1) * sizeof(*b))) - == NULL) { free(b); return -1; } - return s; -} int transliterated_fprintf(struct_processus *s_etat_processus, file *flux, const char *format, ...) { int ios; - char *tampon; + + unsigned char *tampon; unsigned char *tampon2; + va_list arguments; va_start(arguments, format); - if (vtransliterated_sprintf(&tampon, format, arguments) < 0) + if (valsprintf(&tampon, format, arguments) < 0) { va_end(arguments); @@ -646,6 +627,60 @@ transliterated_fprintf(struct_processus # ifdef SunOS while((ios = fprintf(flux, "%s", tampon2)) < 0) + { + if ((errno != EINTR) && (errno != 0)) + { + break; + } + } +# else + ios = fprintf(flux, "%s", tampon2); +# endif + + free(tampon2); + + return(ios); +} + + +int +tex_fprintf(struct_processus *s_etat_processus, + file *flux, const char *format, ...) +{ + int ios; + + unsigned char *tampon; + unsigned char *tampon2; + + va_list arguments; + + va_start(arguments, format); + + if (valsprintf(&tampon, format, arguments) < 0) + { + va_end(arguments); + + if (s_etat_processus != NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + } + + return(-1); + } + + va_end(arguments); + + if ((tampon2 = transliteration(s_etat_processus, tampon, + d_locale, ds_tex_encodage_3)) == NULL) + { + free(tampon); + return(-1); + } + + free(tampon); + +# ifdef SunOS + while((ios = fprintf(flux, "%s", tampon2)) < 0) { if ((errno != EINTR) && (errno != 0)) {