From 9b16b528dcfffc896cecbda87249ff09a7987eb7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 28 May 2008 16:48:13 -0400 Subject: [PATCH] [cairo-unicode] Make unicode conversion funcs take const char *utf8 Instead of the previous const unsigned char *utf8. This is in line with our public API now. --- src/cairo-scaled-font.c | 2 +- src/cairo-unicode.c | 34 ++++++++++++++++++---------------- src/cairoint.h | 16 ++++++++-------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 0378f9bde..e401f8f30 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -1284,7 +1284,7 @@ _cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, goto DONE; } - status = _cairo_utf8_to_ucs4 ((unsigned char*)utf8, -1, &ucs4, num_glyphs); + status = _cairo_utf8_to_ucs4 (utf8, -1, &ucs4, num_glyphs); if (status) goto DONE; diff --git a/src/cairo-unicode.c b/src/cairo-unicode.c index 5f91de338..4ae5556e3 100644 --- a/src/cairo-unicode.c +++ b/src/cairo-unicode.c @@ -215,20 +215,21 @@ _utf8_get_char_extended (const unsigned char *p, * an invalid sequence was found. **/ cairo_status_t -_cairo_utf8_to_ucs4 (const unsigned char *str, - int len, - uint32_t **result, - int *items_written) +_cairo_utf8_to_ucs4 (const char *str, + int len, + uint32_t **result, + int *items_written) { uint32_t *str32 = NULL; int n_chars, i; const unsigned char *in; + const unsigned char * const ustr = (const unsigned char *) str; - in = str; + in = ustr; n_chars = 0; - while ((len < 0 || str + len - in > 0) && *in) + while ((len < 0 || ustr + len - in > 0) && *in) { - uint32_t wc = _utf8_get_char_extended (in, str + len - in); + uint32_t wc = _utf8_get_char_extended (in, ustr + len - in); if (wc & 0x80000000 || !UNICODE_VALID (wc)) return _cairo_error (CAIRO_STATUS_INVALID_STRING); @@ -243,7 +244,7 @@ _cairo_utf8_to_ucs4 (const unsigned char *str, if (!str32) return _cairo_error (CAIRO_STATUS_NO_MEMORY); - in = str; + in = ustr; for (i=0; i < n_chars; i++) { str32[i] = _utf8_get_char (in); in = UTF8_NEXT_CHAR (in); @@ -280,19 +281,20 @@ _cairo_utf8_to_ucs4 (const unsigned char *str, * an invalid sequence was found. **/ cairo_status_t -_cairo_utf8_to_utf16 (const unsigned char *str, - int len, - uint16_t **result, - int *items_written) +_cairo_utf8_to_utf16 (const char *str, + int len, + uint16_t **result, + int *items_written) { uint16_t *str16 = NULL; int n16, i; const unsigned char *in; + const unsigned char * const ustr = (const unsigned char *) str; - in = str; + in = ustr; n16 = 0; - while ((len < 0 || str + len - in > 0) && *in) { - uint32_t wc = _utf8_get_char_extended (in, str + len - in); + while ((len < 0 || ustr + len - in > 0) && *in) { + uint32_t wc = _utf8_get_char_extended (in, ustr + len - in); if (wc & 0x80000000 || !UNICODE_VALID (wc)) return _cairo_error (CAIRO_STATUS_INVALID_STRING); @@ -311,7 +313,7 @@ _cairo_utf8_to_utf16 (const unsigned char *str, if (!str16) return _cairo_error (CAIRO_STATUS_NO_MEMORY); - in = str; + in = ustr; for (i = 0; i < n16;) { uint32_t wc = _utf8_get_char (in); diff --git a/src/cairoint.h b/src/cairoint.h index f1bee255a..24e818b6c 100755 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -2276,20 +2276,20 @@ _cairo_gstate_get_antialias (cairo_gstate_t *gstate); /* cairo_unicode.c */ cairo_private cairo_status_t -_cairo_utf8_to_ucs4 (const unsigned char *str, - int len, - uint32_t **result, - int *items_written); +_cairo_utf8_to_ucs4 (const char *str, + int len, + uint32_t **result, + int *items_written); #if CAIRO_HAS_WIN32_FONT+0 || CAIRO_HAS_QUARTZ_FONT+0 # define CAIRO_HAS_UTF8_TO_UTF16 1 #endif #if CAIRO_HAS_UTF8_TO_UTF16 cairo_private cairo_status_t -_cairo_utf8_to_utf16 (const unsigned char *str, - int len, - uint16_t **result, - int *items_written); +_cairo_utf8_to_utf16 (const char *str, + int len, + uint16_t **result, + int *items_written); #endif cairo_private cairo_status_t