[cairo-commit] src/cairo-cff-subset.c src/cairoint.h src/cairo-misc.c src/cairo-output-stream.c src/cairo-type1-subset.c

Bryce Harrington bryce at kemper.freedesktop.org
Tue Sep 23 12:04:42 PDT 2014


 src/cairo-cff-subset.c    |    4 +---
 src/cairo-misc.c          |   18 ++++++++++++++++++
 src/cairo-output-stream.c |    5 +----
 src/cairo-type1-subset.c  |    5 +----
 src/cairoint.h            |    3 +++
 5 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 9a19ef185884da1e7d5344b301f48aa2ba0f88b6
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Mon Mar 24 19:08:10 2014 +1030

    Fix compilation with bionic libc
    
    Refactor out a cairo_get_locale_decimal_point() routine to handle a case
    where localeconv() is not available.
    
    Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=70492
    Reviewed-by: Bryce Harrington <b.harrington at samsung.com>
    
    [edit:  Condensed cairo_get_locale_decimal_point and conditionalized
    locale.h inclusion.  -- bryce]

diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 1bb9461..4660d6e 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -295,7 +295,6 @@ decode_nibble (int n, char *buf)
 static unsigned char *
 decode_real (unsigned char *p, double *real)
 {
-    struct lconv *locale_data;
     const char *decimal_point;
     int decimal_point_len;
     int n;
@@ -305,8 +304,7 @@ decode_real (unsigned char *p, double *real)
     char *buf = buffer;
     char *buf_end = buffer + sizeof (buffer);
 
-    locale_data = localeconv ();
-    decimal_point = locale_data->decimal_point;
+    decimal_point = cairo_get_locale_decimal_point ();
     decimal_point_len = strlen (decimal_point);
 
     assert (decimal_point_len != 0);
diff --git a/src/cairo-misc.c b/src/cairo-misc.c
index 7575d42..df8a4ef 100644
--- a/src/cairo-misc.c
+++ b/src/cairo-misc.c
@@ -759,6 +759,24 @@ _cairo_half_from_float (float f)
     }
 }
 
+#ifndef __BIONIC__
+# include <locale.h>
+
+const char *
+cairo_get_locale_decimal_point (void)
+{
+    struct lconv *locale_data = localeconv ();
+    return locale_data->decimal_point;
+}
+
+#else
+/* Android's Bionic libc doesn't provide decimal_point */
+const char *
+cairo_get_locale_decimal_point (void)
+{
+    return '.';
+}
+#endif
 
 #ifdef _WIN32
 
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 6d6c180..369a59b 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -43,7 +43,6 @@
 #include "cairo-compiler-private.h"
 
 #include <stdio.h>
-#include <locale.h>
 #include <errno.h>
 
 /* Numbers printed with %f are printed with this number of significant
@@ -303,7 +302,6 @@ _cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
 static void
 _cairo_dtostr (char *buffer, size_t size, double d, cairo_bool_t limited_precision)
 {
-    struct lconv *locale_data;
     const char *decimal_point;
     int decimal_point_len;
     char *p;
@@ -314,8 +312,7 @@ _cairo_dtostr (char *buffer, size_t size, double d, cairo_bool_t limited_precisi
     if (d == 0.0)
 	d = 0.0;
 
-    locale_data = localeconv ();
-    decimal_point = locale_data->decimal_point;
+    decimal_point = cairo_get_locale_decimal_point ();
     decimal_point_len = strlen (decimal_point);
 
     assert (decimal_point_len != 0);
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 47d85b2..b156635 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -53,7 +53,6 @@
 #include "cairo-output-stream-private.h"
 
 #include <ctype.h>
-#include <locale.h>
 
 #define TYPE1_STACKSIZE 24 /* Defined in Type 1 Font Format */
 
@@ -309,12 +308,10 @@ cairo_type1_font_subset_get_matrix (cairo_type1_font_subset_t *font,
     const char *start, *end, *segment_end;
     int ret, s_max, i, j;
     char *s;
-    struct lconv *locale_data;
     const char *decimal_point;
     int decimal_point_len;
 
-    locale_data = localeconv ();
-    decimal_point = locale_data->decimal_point;
+    decimal_point = cairo_get_locale_decimal_point ();
     decimal_point_len = strlen (decimal_point);
 
     assert (decimal_point_len != 0);
diff --git a/src/cairoint.h b/src/cairoint.h
index 080bb5d..75b34d0 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -871,6 +871,9 @@ _cairo_intern_string (const char **str_inout, int len);
 cairo_private void
 _cairo_intern_string_reset_static_data (void);
 
+cairo_private const char *
+cairo_get_locale_decimal_point (void);
+
 /* cairo-path-fixed.c */
 cairo_private cairo_path_fixed_t *
 _cairo_path_fixed_create (void);


More information about the cairo-commit mailing list