On 2009-09-06 18:36-0700 Alan W. Irwin wrote: > BTW, plsave_set_locale and plrestore_locale are the antithesis of functional > programming because they have no arguments and return nothing. That is, > they cause nothing but side effects. However, that is the name of the game > when dealing with POSIX locale issues. plsave_set_locale simply saves the > original locale string (set by external code such as x01c.c) in a global way > and sets locale to "C". plrestore_locale restores the original locale, and > frees the memory where the original global locale string was stored. > > I think this is the best way to implement this pair of functions because I > think we will always need them to communicate with each other between > different routines. (Note, the file open and close are in different routines > in ps.c if we want to block all locale changes when writing the output > PostScript file from ps.c as above.) However, my C skills are not as good as > I would like them to be so I would be interested in discussing changes in > the implementation of these two functions if someone has some better ideas.
Well, practical experience with plsave_set_locale and plrestore_locale today showed me that these are always called from the same routine so I didn't need the global variable approach. Dropping that allowed me to change these to reentrant routines (which was required for some situations [i.e., the -debug option which recursively called these routines] in any case). I have now protected all PLplot core device driver calls with these routines (revision 10383), and the result is all devices appear to work fine for the -locale option for example 1. That is, LC_NUMERIC=nl_NL.utf8 examples/c/x01c -locale appears to give a comma decimal separator for axis labels for every device I have tried with no obvious valgrind or other issues. So this looks quite promising, and I plan to follow up by expanding the testing of this new PLplot feature to all devices and all examples to see if there are any limitations for this new feature. The test of locale for all examples will be made possible by replacing the limited example 1 -locale option by a general -locale option that executes setlocale(LC_NUMERIC, ""); to establish the basic PLplot locale and thus make PLplot generally portable to all LC_NUMERIC locales depending on how users set the LC_NUMERIC or LC_ALL environment variables. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel