|
From: <ai...@us...> - 2009-09-08 03:08:16
|
Revision: 10383
http://plplot.svn.sourceforge.net/plplot/?rev=10383&view=rev
Author: airwin
Date: 2009-09-08 03:08:07 +0000 (Tue, 08 Sep 2009)
Log Message:
-----------
Protect all device driver calls using the (now) reentrant plsave_set_locale
and plrestore_locale. The former saves the fundamental PLplot LC_NUMERIC
locale and then sets the LC_NUMERIC locale to "C" for everything done by all
device drivers. Of course, any library called by a device driver can also
change the locale, but we guard against such changes affecting the rest of
PLplot by using plrestore_locale to restore the fundamental PLplot
LC_NUMERIC locale saved by plsave_set_locale.
N.B. this logic allows the fundamental PLplot LC_NUMERIC locale (except for
the parts like the device drivers and palette file reading that are
protected by the combination of plsave_set_locale and plrestore_locale) to
be any valid locale set by any application or library that calls the PLplot
library. If that locale specifies comma decimal separators rather than
period decimal separators, for example, then the PLplot core will
automatically use those for for specifying axis labels. Those commas for
axis labels are drawn by the PLplot core for the Hershey font device drivers
or just propagate to the unicode device drivers as UCS4 arrays. Thus, in
both cases, we get a comma decimal separator for axis labels (if that is
what the fundamental PLplot LC_NUMERIC locale calls for) independently of
the logic of the present commit that sets the LC_NUMERIC locale to "C" for
all device driver code that is executed.
Modified Paths:
--------------
trunk/src/plcore.c
Modified: trunk/src/plcore.c
===================================================================
--- trunk/src/plcore.c 2009-09-08 02:45:49 UTC (rev 10382)
+++ trunk/src/plcore.c 2009-09-08 03:08:07 UTC (rev 10383)
@@ -131,9 +131,12 @@
void
plP_init(void)
{
+ char * save_locale;
plsc->page_status = AT_EOP;
+ save_locale = plsave_set_locale();
(*plsc->dispatch_table->pl_init) ((struct PLStream_struct *) plsc);
+ plrestore_locale(save_locale);
if (plsc->plbuf_write)
plbuf_init(plsc);
@@ -161,8 +164,11 @@
if (plsc->eop_handler != NULL)
(*plsc->eop_handler) (plsc->eop_data, &skip_driver_eop);
- if (!skip_driver_eop)
- (*plsc->dispatch_table->pl_eop) ((struct PLStream_struct *) plsc);
+ if (!skip_driver_eop) {
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_eop) ((struct PLStream_struct *) plsc);
+ plrestore_locale(save_locale);
+ }
}
/* Set up new page. */
@@ -187,8 +193,11 @@
if (plsc->bop_handler != NULL)
(*plsc->bop_handler) (plsc->bop_data, &skip_driver_bop);
- if (!skip_driver_bop)
- (*plsc->dispatch_table->pl_bop) ((struct PLStream_struct *) plsc);
+ if (!skip_driver_bop) {
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_bop) ((struct PLStream_struct *) plsc);
+ plrestore_locale(save_locale);
+ }
if (plsc->plbuf_write)
plbuf_bop(plsc);
@@ -199,13 +208,16 @@
void
plP_tidy(void)
{
+ char * save_locale;
if (plsc->tidy) {
(*plsc->tidy) (plsc->tidy_data);
plsc->tidy = NULL;
plsc->tidy_data = NULL;
}
+ save_locale = plsave_set_locale();
(*plsc->dispatch_table->pl_tidy) ((struct PLStream_struct *) plsc);
+ plrestore_locale(save_locale);
if (plsc->plbuf_write) {
plbuf_tidy(plsc);
@@ -220,9 +232,12 @@
void
plP_state(PLINT op)
{
+ char * save_locale;
if (plsc->plbuf_write) plbuf_state(plsc, op);
+ save_locale = plsave_set_locale();
(*plsc->dispatch_table->pl_state) ((struct PLStream_struct *) plsc, op);
+ plrestore_locale(save_locale);
}
/* Escape function, for driver-specific commands. */
@@ -230,6 +245,7 @@
void
plP_esc(PLINT op, void *ptr)
{
+ char * save_locale;
PLINT clpxmi, clpxma, clpymi, clpyma;
EscText* args;
@@ -247,7 +263,9 @@
}
}
+ save_locale = plsave_set_locale();
(*plsc->dispatch_table->pl_esc) ((struct PLStream_struct *) plsc, op, ptr);
+ plrestore_locale(save_locale);
}
/* Set up plot window parameters. */
@@ -295,8 +313,10 @@
/* It must use the filtered data, which it can get from *plsc */
if (plsc->dev_swin) {
- (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
- PLESC_SWIN, NULL );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
+ PLESC_SWIN, NULL );
+ plrestore_locale(save_locale);
}
}
@@ -971,26 +991,33 @@
static void
grline(short *x, short *y, PLINT npts)
{
- (*plsc->dispatch_table->pl_line) ( (struct PLStream_struct *) plsc,
- x[0], y[0], x[1], y[1] );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_line) ( (struct PLStream_struct *) plsc,
+ x[0], y[0], x[1], y[1] );
+ plrestore_locale(save_locale);
}
static void
grpolyline(short *x, short *y, PLINT npts)
{
- (*plsc->dispatch_table->pl_polyline) ( (struct PLStream_struct *) plsc,
- x, y, npts );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_polyline) ( (struct PLStream_struct *) plsc,
+ x, y, npts );
+ plrestore_locale(save_locale);
}
static void
grfill(short *x, short *y, PLINT npts)
{
+ char * save_locale;
plsc->dev_npts = npts;
plsc->dev_x = x;
plsc->dev_y = y;
+ save_locale = plsave_set_locale();
(*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
PLESC_FILL, NULL );
+ plrestore_locale(save_locale);
}
/*--------------------------------------------------------------------------*\
@@ -1362,8 +1389,10 @@
PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
if (plsc->dev_di) {
- (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
- PLESC_DI, NULL );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
+ PLESC_DI, NULL );
+ plrestore_locale(save_locale);
}
if ( ! (plsc->difilt & PLDI_PLT))
@@ -1444,8 +1473,10 @@
PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
if (plsc->dev_di) {
- (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
- PLESC_DI, NULL );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
+ PLESC_DI, NULL );
+ plrestore_locale(save_locale);
}
if ( ! (plsc->difilt & PLDI_DEV))
@@ -1562,8 +1593,10 @@
PLFLT x0, y0, lx, ly, aspect;
if (plsc->dev_di) {
- (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
- PLESC_DI, NULL );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
+ PLESC_DI, NULL );
+ plrestore_locale(save_locale);
}
if ( ! (plsc->difilt & PLDI_ORI))
@@ -1711,8 +1744,10 @@
c_plflush(void)
{
if (plsc->dev_flush) {
- (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
- PLESC_FLUSH, NULL );
+ char *save_locale = plsave_set_locale();
+ (*plsc->dispatch_table->pl_esc) ( (struct PLStream_struct *) plsc,
+ PLESC_FLUSH, NULL );
+ plrestore_locale(save_locale);
}
else {
if (plsc->OutFile != NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|