locale.h and gnuplot

Jakson Aquino jaksonaquino at yahoo.com.br
Tue Feb 22 15:33:57 CET 2005


Hi Andreas,

Thank you for completing the code. Next time I send a
patch, I can make the changes. I think that the code
below now is correct, right?

#ifndef NO_GETTEXT
char * SX_saved_locale, * SX_old_locale;
#define SX_SET_LOCALE	\
	SX_old_locale = setlocale (LC_NUMERIC, NULL); \
        SX_saved_locale =
mymalloc(strlen(SX_old_locale)+1); \
	strcpy(SX_saved_locale, SX_old_locale); \
	setlocale  (LC_NUMERIC, "C"); 

#define SX_RESET_LOCALE \
	setlocale (LC_NUMERIC, SX_saved_locale); \
	free(SX_saved_locale); SX_saved_locale = NULL;
#endif


I think that we can put the above lines in statist.h.

Best regards,

Jakson

 --- Andreas Beyer <beyer at imb-jena.de> escreveu: 
> When you store the current locale information, the
> program could 
> potentially run out of memory. You have to check
> that, which StatistX 
> does by testing the condition
>    SX_saved_locale == NULL
> If this condition is true, the program has no memory
> left (or something 
> else went wrong). statist should perform the same
> test at the same place 
> and handle the problem in some way. E.g. the
> following is a possible way 
> to deal with it:
> 
> if (saved_locale == NULL) {
>     /* Run out of memory. Fatal, stop the program.
> */
>     out_err(FAT, ERR_FILE, ERR_LINE,
>           _("set locale: Not enough memory."));
> }
> 
> 
> Look at "statist.h" for details about out_err(). If
> possible, one could 
> also use mymalloc() from memory_handling.h.
> 
> 	Andreas



	
	
		
_______________________________________________________ 
Yahoo! Acesso Grátis - Instale o discador do Yahoo! agora. http://br.acesso.yahoo.com/ - Internet rápida e grátis




More information about the Statist-list mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)