Style and indentation fixes.

cast to quiet new gcc-4 warnings.
Initialize variables to quiet new gcc-4 warnings.
Use unsigned char* as expected by freetype, libpng, Xlib, and zlib.
Propagate unsigned char* down from cairo_text_extents.
This commit is contained in:
Carl Worth 2005-04-02 05:18:11 +00:00
parent 7636e90184
commit 9e405876e8
13 changed files with 109 additions and 76 deletions

View file

@ -1,3 +1,32 @@
2005-04-02 Carl Worth <cworth@cworth.org>
* src/cairo.h:
* src/cairo.c: (cairo_set_target_image), (cairo_text_extents),
(cairo_show_text), (cairo_text_path):
* src/cairo-image-surface.c: (cairo_image_surface_create_for_data):
* src/cairo-gstate.c: (_cairo_gstate_text_to_glyphs):
* src/cairo-font.c: (_cairo_font_create): Style and indentation
fixes.
* src/cairo-ft-font.c: (_cairo_ft_font_create): Add (unsigned
char*) cast to quiet new gcc-4 warnings.
* src/cairo-ft-font.c: (_cairo_ft_font_glyph_extents): Initialize
variables to quiet new gcc-4 warnings.
* src/cairo-pdf-surface.c: (cairo_pdf_ft_font_write_generic_table),
(cairo_pdf_ft_font_write_glyf_table):
* src/cairo-png.c: (cairo_surface_write_png),
(cairo_image_surface_create_for_png):
* src/cairo-xlib-surface.c: (_get_image_surface):
* src/cairo-ps-surface.c: (_cairo_ps_surface_copy_page):
Use unsigned char* as expected by freetype, libpng, Xlib, and zlib.
* src/cairoint.h:
* src/cairo-unicode.c: (_utf8_get_char), (_utf8_get_char_extended),
(_cairo_utf8_to_ucs4), (_cairo_utf8_to_utf16): Propagate unsigned
char* down from cairo_text_extents.
2005-04-01 Carl Worth <cworth@cworth.org>
* TODO: Update API shakeup chart.

View file

@ -42,11 +42,11 @@
/* Now the internal "unscaled + scale" font API */
cairo_private cairo_status_t
_cairo_font_create (const char *family,
_cairo_font_create (const char *family,
cairo_font_slant_t slant,
cairo_font_weight_t weight,
cairo_font_scale_t *sc,
cairo_font_t **font)
cairo_font_scale_t *sc,
cairo_font_t **font)
{
const cairo_font_backend_t *backend = CAIRO_FONT_BACKEND_DEFAULT;

View file

@ -581,7 +581,7 @@ _ft_font_create (FcPattern *pattern,
}
static cairo_status_t
_cairo_ft_font_create (const char *family,
_cairo_ft_font_create (const char *family,
cairo_font_slant_t slant,
cairo_font_weight_t weight,
cairo_font_scale_t *scale,
@ -623,7 +623,7 @@ _cairo_ft_font_create (const char *family,
break;
}
if (!FcPatternAddString (pattern, FC_FAMILY, family))
if (!FcPatternAddString (pattern, FC_FAMILY, (unsigned char *) family))
goto FREE_PATTERN;
if (!FcPatternAddInteger (pattern, FC_SLANT, fcslant))
goto FREE_PATTERN;
@ -833,7 +833,8 @@ _cairo_ft_font_glyph_extents (void *abstract_font,
cairo_ft_font_t *font = abstract_font;
cairo_point_double_t origin;
cairo_point_double_t glyph_min, glyph_max;
cairo_point_double_t total_min, total_max;
/* Initialize just to squelch anti-helpful compiler warning. */
cairo_point_double_t total_min = { 0, 0}, total_max = {0,0};
cairo_image_glyph_cache_entry_t *img = NULL;
cairo_cache_t *cache;

View file

@ -2366,10 +2366,10 @@ _cairo_gstate_get_font_extents (cairo_gstate_t *gstate,
}
cairo_status_t
_cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
_cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
const unsigned char *utf8,
cairo_glyph_t **glyphs,
int *nglyphs)
cairo_glyph_t **glyphs,
int *num_glyphs)
{
cairo_status_t status;
@ -2393,16 +2393,16 @@ _cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
}
status = _cairo_font_text_to_glyphs (gstate->font,
utf8, glyphs, nglyphs);
utf8, glyphs, num_glyphs);
if (status || !glyphs || !nglyphs || !(*glyphs) || !(nglyphs))
if (status || !glyphs || !num_glyphs || !(*glyphs) || !(num_glyphs))
return status;
/* The font responded in glyph space, starting from (0,0). Convert to
user space by applying the font transform, then add any current point
offset. */
for (i = 0; i < *nglyphs; ++i) {
for (i = 0; i < *num_glyphs; ++i) {
cairo_matrix_transform_point (&gstate->font_matrix,
&((*glyphs)[i].x),
&((*glyphs)[i].y));

View file

@ -195,7 +195,7 @@ cairo_image_surface_create (cairo_format_t format,
* be created because of lack of memory
**/
cairo_surface_t *
cairo_image_surface_create_for_data (char *data,
cairo_image_surface_create_for_data (char *data,
cairo_format_t format,
int width,
int height,

View file

@ -462,7 +462,7 @@ static int
cairo_pdf_ft_font_write_generic_table (cairo_pdf_ft_font_t *font,
unsigned long tag)
{
char *buffer;
unsigned char *buffer;
unsigned long size;
size = 0;
@ -480,7 +480,7 @@ cairo_pdf_ft_font_write_glyf_table (cairo_pdf_ft_font_t *font,
unsigned long start_offset, index, size;
TT_Header *header;
unsigned long begin, end;
char *buffer;
unsigned char *buffer;
int i;
union {
unsigned char *bytes;

View file

@ -106,7 +106,7 @@ cairo_surface_write_png (cairo_surface_t *surface, FILE *file)
}
for (i = 0; i < image->height; i++)
rows[i] = image->data + i * image->stride;
rows[i] = (png_byte *) image->data + i * image->stride;
png = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png == NULL) {
@ -322,7 +322,7 @@ cairo_image_surface_create_for_png (FILE *file, int *width, int *height)
if (height != NULL)
*height = png_height;
return cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32,
return cairo_image_surface_create_for_data ((char *)data, CAIRO_FORMAT_ARGB32,
png_width, png_height, stride);
BAIL3:

View file

@ -278,8 +278,8 @@ _cairo_ps_surface_copy_page (void *abstract_surface)
int i, x, y;
cairo_solid_pattern_t white_pattern;
char *rgb, *compressed;
long rgb_size, compressed_size;
unsigned char *rgb, *compressed;
unsigned long rgb_size, compressed_size;
rgb_size = 3 * width * height;
rgb = malloc (rgb_size);

View file

@ -117,14 +117,14 @@ static const char utf8_skip_data[256] = {
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
};
#define UTF8_NEXT_CHAR(p) (char *)((p) + utf8_skip_data[*(unsigned char *)(p)])
#define UTF8_NEXT_CHAR(p) ((p) + utf8_skip_data[*(unsigned char *)(p)])
/* Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
* If @p does not point to a valid UTF-8 encoded character, results are
* undefined.
**/
static uint32_t
_utf8_get_char (const char *p)
_utf8_get_char (const unsigned char *p)
{
int i, mask = 0, len;
uint32_t result;
@ -142,8 +142,8 @@ _utf8_get_char (const char *p)
* and return (uint32_t)-2 on incomplete trailing character
*/
static uint32_t
_utf8_get_char_extended (const char *p,
long max_len)
_utf8_get_char_extended (const unsigned char *p,
long max_len)
{
int i, len;
uint32_t wc = (unsigned char) *p;
@ -220,14 +220,14 @@ _utf8_get_char_extended (const char *p,
* an invalid sequence was found.
**/
cairo_status_t
_cairo_utf8_to_ucs4 (const char *str,
int len,
uint32_t **result,
int *items_written)
_cairo_utf8_to_ucs4 (const unsigned char *str,
int len,
uint32_t **result,
int *items_written)
{
uint32_t *str32 = NULL;
int n_chars, i;
const char *in;
const unsigned char *in;
in = str;
n_chars = 0;
@ -284,14 +284,14 @@ _cairo_utf8_to_ucs4 (const char *str,
* an invalid sequence was found.
**/
cairo_status_t
_cairo_utf8_to_utf16 (const char *str,
int len,
uint16_t **result,
int *items_written)
_cairo_utf8_to_utf16 (const unsigned char *str,
int len,
uint16_t **result,
int *items_written)
{
uint16_t *str16 = NULL;
int n16, i;
const char *in;
const unsigned char *in;
in = str;
n16 = 0;

View file

@ -183,9 +183,10 @@ _get_image_surface (cairo_xlib_surface_t *surface,
x2 = surface->width;
y2 = surface->height;
} else {
int width, height;
unsigned int width, height;
Window root_ignore;
int x_ignore, y_ignore, bwidth_ignore, depth_ignore;
int x_ignore, y_ignore;
unsigned int bwidth_ignore, depth_ignore;
XGetGeometry (surface->dpy,
surface->drawable,

View file

@ -331,10 +331,10 @@ slim_hidden_def(cairo_set_target_surface);
void
cairo_set_target_image (cairo_t *cr,
char *data,
cairo_format_t format,
int width,
int height,
int stride)
cairo_format_t format,
int width,
int height,
int stride)
{
cairo_surface_t *surface;
@ -1691,12 +1691,12 @@ cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix)
* affect the x_advance and y_advance values.
**/
void
cairo_text_extents (cairo_t *cr,
const unsigned char *utf8,
cairo_text_extents_t *extents)
cairo_text_extents (cairo_t *cr,
const unsigned char *utf8,
cairo_text_extents_t *extents)
{
cairo_glyph_t *glyphs = NULL;
int nglyphs;
int num_glyphs;
CAIRO_CHECK_SANITY (cr);
if (cr->status)
@ -1712,7 +1712,7 @@ cairo_text_extents (cairo_t *cr,
return;
}
cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &nglyphs);
cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &num_glyphs);
CAIRO_CHECK_SANITY (cr);
if (cr->status) {
@ -1721,7 +1721,7 @@ cairo_text_extents (cairo_t *cr,
return;
}
cr->status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, nglyphs, extents);
cr->status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs, extents);
CAIRO_CHECK_SANITY (cr);
if (glyphs)
@ -1765,7 +1765,7 @@ void
cairo_show_text (cairo_t *cr, const unsigned char *utf8)
{
cairo_glyph_t *glyphs = NULL;
int nglyphs;
int num_glyphs;
CAIRO_CHECK_SANITY (cr);
if (cr->status)
@ -1774,7 +1774,8 @@ cairo_show_text (cairo_t *cr, const unsigned char *utf8)
if (utf8 == NULL)
return;
cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &nglyphs);
cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
&glyphs, &num_glyphs);
CAIRO_CHECK_SANITY (cr);
if (cr->status) {
@ -1783,7 +1784,7 @@ cairo_show_text (cairo_t *cr, const unsigned char *utf8)
return;
}
cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, nglyphs);
cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs);
CAIRO_CHECK_SANITY (cr);
if (glyphs)
@ -1805,13 +1806,14 @@ void
cairo_text_path (cairo_t *cr, const unsigned char *utf8)
{
cairo_glyph_t *glyphs = NULL;
int nglyphs;
int num_glyphs;
CAIRO_CHECK_SANITY (cr);
if (cr->status)
return;
cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &nglyphs);
cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8,
&glyphs, &num_glyphs);
CAIRO_CHECK_SANITY (cr);
if (cr->status) {
@ -1820,7 +1822,7 @@ cairo_text_path (cairo_t *cr, const unsigned char *utf8)
return;
}
cr->status = _cairo_gstate_glyph_path (cr->gstate, glyphs, nglyphs);
cr->status = _cairo_gstate_glyph_path (cr->gstate, glyphs, num_glyphs);
CAIRO_CHECK_SANITY (cr);
if (glyphs)

View file

@ -178,8 +178,8 @@ typedef enum cairo_format {
* we eliminate all the cairo_set_target functions.
*/
void
cairo_set_target_image (cairo_t *cr,
char *data,
cairo_set_target_image (cairo_t *cr,
char *data,
cairo_format_t format,
int width,
int height,
@ -919,7 +919,7 @@ cairo_image_surface_create (cairo_format_t format,
int height);
cairo_surface_t *
cairo_image_surface_create_for_data (char *data,
cairo_image_surface_create_for_data (char *data,
cairo_format_t format,
int width,
int height,
@ -991,14 +991,14 @@ cairo_matrix_set_identity (cairo_matrix_t *matrix);
cairo_status_t
cairo_matrix_set_affine (cairo_matrix_t *matrix,
double a, double b,
double c, double d,
double a, double b,
double c, double d,
double tx, double ty);
cairo_status_t
cairo_matrix_get_affine (cairo_matrix_t *matrix,
double *a, double *b,
double *c, double *d,
double *a, double *b,
double *c, double *d,
double *tx, double *ty);
cairo_status_t

View file

@ -1144,10 +1144,10 @@ _cairo_gstate_set_font (cairo_gstate_t *gstate,
cairo_font_t *font);
cairo_private cairo_status_t
_cairo_gstate_text_to_glyphs (cairo_gstate_t *font,
_cairo_gstate_text_to_glyphs (cairo_gstate_t *font,
const unsigned char *utf8,
cairo_glyph_t **glyphs,
int *num_glyphs);
cairo_glyph_t **glyphs,
int *num_glyphs);
cairo_private cairo_status_t
_cairo_gstate_glyph_extents (cairo_gstate_t *gstate,
@ -1186,11 +1186,11 @@ _cairo_color_set_alpha (cairo_color_t *color, double alpha);
/* cairo_font.c */
cairo_private cairo_status_t
_cairo_font_create (const char *family,
_cairo_font_create (const char *family,
cairo_font_slant_t slant,
cairo_font_weight_t weight,
cairo_font_scale_t *sc,
cairo_font_t **font);
cairo_font_scale_t *sc,
cairo_font_t **font);
cairo_private void
_cairo_font_init (cairo_font_t *font,
@ -1212,10 +1212,10 @@ _cairo_font_font_extents (cairo_font_t *font,
cairo_font_extents_t *extents);
cairo_private cairo_status_t
_cairo_font_text_to_glyphs (cairo_font_t *font,
const unsigned char *utf8,
cairo_glyph_t **glyphs,
int *num_glyphs);
_cairo_font_text_to_glyphs (cairo_font_t *font,
const unsigned char *utf8,
cairo_glyph_t **glyphs,
int *num_glyphs);
cairo_private cairo_status_t
_cairo_font_glyph_extents (cairo_font_t *font,
@ -1721,16 +1721,16 @@ _cairo_pattern_acquire_surfaces (cairo_pattern_t *src,
/* cairo_unicode.c */
cairo_private cairo_status_t
_cairo_utf8_to_ucs4 (const char *str,
int len,
uint32_t **result,
int *items_written);
_cairo_utf8_to_ucs4 (const unsigned char *str,
int len,
uint32_t **result,
int *items_written);
cairo_private cairo_status_t
_cairo_utf8_to_utf16 (const char *str,
int len,
uint16_t **result,
int *items_written);
_cairo_utf8_to_utf16 (const unsigned char *str,
int len,
uint16_t **result,
int *items_written);
/* cairo_output_stream.c */