diff options
author | Robert Staudinger <robsta@gnome.org> | 2009-09-02 11:31:50 +0200 |
---|---|---|
committer | Robert Staudinger <robsta@gnome.org> | 2009-09-02 11:31:50 +0200 |
commit | b5610632b7e9930667df5b42d6eb5c19b503f47f (patch) | |
tree | c4e73ca2b618b8cd22166d82946696ddb108559d | |
parent | 14ae603095af01a2ffd3fd9443018f62880b4507 (diff) |
[color] Ensure 'C' locale while sscanf'ing floats.
-rw-r--r-- | ccss/Makefile.am | 1 | ||||
-rw-r--r-- | ccss/ccss-color-parser.c | 15 | ||||
-rw-r--r-- | ccss/ccss-macros-priv.h | 35 |
3 files changed, 45 insertions, 6 deletions
diff --git a/ccss/Makefile.am b/ccss/Makefile.am index bc955d6..8d4f6cb 100644 --- a/ccss/Makefile.am +++ b/ccss/Makefile.am @@ -44,6 +44,7 @@ libccss_1_la_SOURCES = \ ccss-grammar-function.c \ ccss-grammar-parse.c \ ccss-grammar-priv.h \ + ccss-macros-priv.h \ ccss-node.c \ ccss-node-priv.h \ ccss-padding.c \ diff --git a/ccss/ccss-color-parser.c b/ccss/ccss-color-parser.c index 4828705..0a434f5 100644 --- a/ccss/ccss-color-parser.c +++ b/ccss/ccss-color-parser.c @@ -26,6 +26,7 @@ #include <glib.h> #include "ccss-color-impl.h" #include "ccss-function-impl.h" +#include "ccss-macros-priv.h" #include "ccss-property-impl.h" #include "config.h" @@ -556,12 +557,14 @@ ccss_color_parse (ccss_color_t *self, user_data); g_return_val_if_fail (rgba, false); - matches = sscanf (rgba, - "rgba(%f,%f,%f,%f)", - &self->red, - &self->green, - &self->blue, - &self->alpha); + CCSS_LOCALE_TRANSACTION ("C", + matches = sscanf (rgba, + "rgba(%f,%f,%f,%f)", + &self->red, + &self->green, + &self->blue, + &self->alpha); + ); g_free (rgba); if (matches == 4) { self->base.state = CCSS_PROPERTY_STATE_SET; diff --git a/ccss/ccss-macros-priv.h b/ccss/ccss-macros-priv.h new file mode 100644 index 0000000..c6d399b --- /dev/null +++ b/ccss/ccss-macros-priv.h @@ -0,0 +1,35 @@ +/* vim: set ts=8 sw=8 noexpandtab: */ + +/* The `C' CSS Library. + * Copyright (C) 2008 Robert Staudinger + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef CCSS_MACROS_PRIV_H +#define CCSS_MACROS_PRIV_H + +#include <locale.h> + +#define CCSS_LOCALE_TRANSACTION(locale, statements) \ + { \ + char const *saved_locale = setlocale (LC_ALL, locale); \ + statements \ + setlocale (LC_ALL, saved_locale); \ + } + +#endif /* CCSS_MACROS_PRIV_H */ + |