X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flibcroco%2Fcr-style.c;h=e0abba83a42463db0e08a839169b63181785d7b4;hb=5f838cdcee37934790b8e7e62ea34f188bf20fe1;hp=789d68f42c34ea00bd9f6a65a3a1dc50160a90f8;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/libcroco/cr-style.c b/src/libcroco/cr-style.c index 789d68f42..e0abba83a 100644 --- a/src/libcroco/cr-style.c +++ b/src/libcroco/cr-style.c @@ -92,7 +92,7 @@ enum CRPropertyID { typedef struct _CRPropertyDesc CRPropertyDesc; struct _CRPropertyDesc { - const guchar *name; + const gchar *name; enum CRPropertyID prop_id; }; @@ -140,9 +140,9 @@ static CRPropertyDesc gv_prop_table[] = { {"font-size", PROP_ID_FONT_SIZE}, {"font-style", PROP_ID_FONT_STYLE}, {"font-weight", PROP_ID_FONT_WEIGHT}, - {"white-space", PROP_ID_WHITE_SPACE}, + {"white-space", PROP_ID_WHITE_SPACE}, /*must be the last one */ - {NULL, 0} + {NULL, (enum CRPropertyID)0} }; /** @@ -185,7 +185,7 @@ static struct CRNumPropEnumDumpInfo gv_num_props_dump_infos[] = { {NUM_PROP_MARGIN_BOTTOM, "margin-bottom"}, {NUM_PROP_MARGIN_LEFT, "margin-left"}, {NUM_PROP_WIDTH, "width"}, - {0, NULL} + {(enum CRNumProp)0, NULL} }; struct CRRgbPropEnumDumpInfo { @@ -200,7 +200,7 @@ static struct CRRgbPropEnumDumpInfo gv_rgb_props_dump_infos[] = { {RGB_PROP_BORDER_LEFT_COLOR, "left-color"}, {RGB_PROP_COLOR, "color"}, {RGB_PROP_BACKGROUND_COLOR, "background-color"}, - {0, NULL} + {(enum CRRgbProp)0, NULL} }; struct CRBorderStylePropEnumDumpInfo { @@ -215,7 +215,7 @@ static struct CRBorderStylePropEnumDumpInfo gv_border_style_props_dump_infos[] {BORDER_STYLE_PROP_RIGHT, "border-style-right"}, {BORDER_STYLE_PROP_BOTTOM, "boder-style-bottom"}, {BORDER_STYLE_PROP_LEFT, "border-style-left"}, - {0, NULL} + {(enum CRBorderStyleProp)0, NULL} }; static enum CRStatus @@ -319,9 +319,9 @@ set_prop_font_weight_from_value (CRStyle * a_style, CRTerm * a_value); static const gchar * num_prop_code_to_string (enum CRNumProp a_code) { - unsigned const len = sizeof (gv_num_props_dump_infos) / + int len = sizeof (gv_num_props_dump_infos) / sizeof (struct CRNumPropEnumDumpInfo); - if (a_code >= len) { + if ((int)a_code >= len) { cr_utils_trace_info ("A field has been added " "to 'enum CRNumProp' and no matching" " entry has been " @@ -342,10 +342,10 @@ num_prop_code_to_string (enum CRNumProp a_code) static const gchar * rgb_prop_code_to_string (enum CRRgbProp a_code) { - unsigned const len = sizeof (gv_rgb_props_dump_infos) / + int len = sizeof (gv_rgb_props_dump_infos) / sizeof (struct CRRgbPropEnumDumpInfo); - if (a_code >= len) { + if ((int)a_code >= len) { cr_utils_trace_info ("A field has been added " "to 'enum CRRgbProp' and no matching" " entry has been " @@ -366,10 +366,10 @@ rgb_prop_code_to_string (enum CRRgbProp a_code) static const gchar * border_style_prop_code_to_string (enum CRBorderStyleProp a_code) { - unsigned const len = sizeof (gv_border_style_props_dump_infos) / + int len = sizeof (gv_border_style_props_dump_infos) / sizeof (struct CRBorderStylePropEnumDumpInfo); - if (a_code >= len) { + if ((int)a_code >= len) { cr_utils_trace_info ("A field has been added " "to 'enum CRBorderStyleProp' and no matching" " entry has been " @@ -421,11 +421,11 @@ cr_style_get_prop_id (const guchar * a_prop) cr_style_init_properties (); } - raw_id = g_hash_table_lookup (gv_prop_hash, a_prop); + raw_id = (gpointer *)g_hash_table_lookup (gv_prop_hash, a_prop); if (!raw_id) { return PROP_ID_NOT_KNOWN; } - return GPOINTER_TO_INT (raw_id); + return (enum CRPropertyID)GPOINTER_TO_INT (raw_id); } static enum CRStatus @@ -465,7 +465,7 @@ set_prop_padding_x_from_value (CRStyle * a_style, if (a_value->content.str && a_value->content.str->stryng && a_value->content.str->stryng->str - && !strncmp ((guchar *) "inherit", + && !strncmp ("inherit", a_value->content.str->stryng->str, sizeof ("inherit")-1)) { status = cr_num_set (num_val, 0.0, NUM_INHERIT); @@ -569,19 +569,17 @@ static enum CRStatus set_prop_border_width_from_value (CRStyle *a_style, CRTerm *a_value) { - CRTerm *cur_term = NULL ; - enum CRDirection direction = DIR_TOP ; - g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR) ; - cur_term = a_value ; + CRTerm *cur_term = a_value ; if (!cur_term) return CR_ERROR ; - for (direction = DIR_TOP ; - direction < NB_DIRS ; direction ++) { - set_prop_border_x_width_from_value (a_style, + int dir; + for (dir = (int) DIR_TOP ; dir < (int)NB_DIRS ; dir++) { + enum CRDirection direction = (enum CRDirection)dir; + set_prop_border_x_width_from_value (a_style, cur_term, direction) ; } @@ -698,20 +696,17 @@ static enum CRStatus set_prop_border_style_from_value (CRStyle *a_style, CRTerm *a_value) { - CRTerm *cur_term = NULL ; - enum CRDirection direction = DIR_TOP ; - g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR) ; - cur_term = a_value ; + CRTerm *cur_term = a_value ; if (!cur_term || cur_term->type != TERM_IDENT) { return CR_ERROR ; } - for (direction = DIR_TOP ; - direction < NB_DIRS ; - direction ++) { + int dir; + for (dir = (int)DIR_TOP ; dir < (int)NB_DIRS ; dir++) { + enum CRDirection direction = (enum CRDirection)dir; set_prop_border_x_style_from_value (a_style, cur_term, direction) ; @@ -804,7 +799,7 @@ set_prop_margin_x_from_value (CRStyle * a_style, CRTerm * a_value, } struct CRPropDisplayValPair { - const guchar *prop_name; + const gchar *prop_name; enum CRDisplayType type; }; @@ -865,7 +860,7 @@ set_prop_display_from_value (CRStyle * a_style, CRTerm * a_value) } struct CRPropPositionValPair { - const guchar *name; + const gchar *name; enum CRPositionType type; }; @@ -1120,11 +1115,11 @@ set_prop_border_x_color_from_value (CRStyle * a_style, CRTerm * a_value, && a_value->content.str->stryng->str) { status = cr_rgb_set_from_name (rgb_color, - a_value->content.str->stryng->str); + (guchar *)a_value->content.str->stryng->str); } if (status != CR_OK) { - cr_rgb_set_from_name (rgb_color, "black"); + cr_rgb_set_from_name (rgb_color, (guchar *)"black"); } } else if (a_value->type == TERM_RGB) { if (a_value->content.rgb) { @@ -1166,14 +1161,13 @@ set_prop_border_x_from_value (CRStyle * a_style, CRTerm * a_value, static enum CRStatus set_prop_border_from_value (CRStyle * a_style, CRTerm * a_value) { - enum CRDirection direction = 0; - g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR); - for (direction = 0; direction < NB_DIRS; direction++) { + int dir; + for (dir = 0; dir < (int)NB_DIRS; dir++) { set_prop_border_x_from_value (a_style, a_value, - direction); + (enum CRDirection)dir); } return CR_OK; @@ -1183,7 +1177,6 @@ static enum CRStatus set_prop_padding_from_value (CRStyle * a_style, CRTerm * a_value) { CRTerm *cur_term = NULL; - enum CRDirection direction = 0; enum CRStatus status = CR_OK; g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR); @@ -1197,8 +1190,10 @@ set_prop_padding_from_value (CRStyle * a_style, CRTerm * a_value) if (!cur_term) return CR_ERROR ; - for (direction = 0; direction < NB_DIRS; direction++) { - set_prop_padding_x_from_value (a_style, cur_term, direction); + int dir; + for (dir = 0; dir < (int)NB_DIRS; dir++) { + set_prop_padding_x_from_value (a_style, + cur_term, (enum CRDirection)dir); } cur_term = cur_term->next; @@ -1234,7 +1229,6 @@ static enum CRStatus set_prop_margin_from_value (CRStyle * a_style, CRTerm * a_value) { CRTerm *cur_term = NULL; - enum CRDirection direction = 0; enum CRStatus status = CR_OK; g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR); @@ -1248,8 +1242,10 @@ set_prop_margin_from_value (CRStyle * a_style, CRTerm * a_value) if (!cur_term) return CR_OK; - for (direction = 0; direction < NB_DIRS; direction++) { - set_prop_margin_x_from_value (a_style, cur_term, direction); + int dir; + for (dir = 0; dir < (int)NB_DIRS; dir++) { + set_prop_margin_x_from_value(a_style, + cur_term, (enum CRDirection)dir); } cur_term = cur_term->next; @@ -1358,7 +1354,7 @@ set_prop_font_family_from_value (CRStyle * a_style, CRTerm * a_value) && cur_term->content.str->stryng->str) { cur_ff = cr_font_family_new (FONT_FAMILY_NON_GENERIC, - cur_term->content.str->stryng->str); + (guchar *)cur_term->content.str->stryng->str); } } break; @@ -1676,7 +1672,7 @@ set_prop_white_space_from_value (CRStyle * a_style, CRTerm * a_value) a_style->white_space = WHITE_SPACE_NORMAL; } else if (!strcmp (a_value->content.str->stryng->str, "pre")) { - a_style->font_weight = WHITE_SPACE_PRE; + a_style->white_space = WHITE_SPACE_PRE; } else if (!strcmp (a_value->content.str->stryng->str, "nowrap")) { a_style->white_space = WHITE_SPACE_NOWRAP; @@ -1711,9 +1707,7 @@ set_prop_white_space_from_value (CRStyle * a_style, CRTerm * a_value) CRStyle * cr_style_new (gboolean a_set_props_to_initial_values) { - CRStyle *result = NULL; - - result = g_try_malloc (sizeof (CRStyle)); + CRStyle *result = (CRStyle *)g_try_malloc (sizeof (CRStyle)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -2024,7 +2018,7 @@ cr_style_set_style_from_decl (CRStyle * a_this, CRDeclaration * a_decl) CR_BAD_PARAM_ERROR); prop_id = cr_style_get_prop_id - (a_decl->property->stryng->str); + ((guchar *)a_decl->property->stryng->str); value = a_decl->value; switch (prop_id) { @@ -2682,7 +2676,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent) *before outputing it value */ cr_utils_dump_n_chars2 (' ', str, indent); - tmp_str = (gchar *) num_prop_code_to_string (i); + tmp_str = (gchar *) num_prop_code_to_string ((enum CRNumProp)i); if (tmp_str) { g_string_append_printf (str, "%s: ", tmp_str); } else { @@ -2696,7 +2690,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent) } /*loop over the rgb_props and to_string() them all */ for (i = RGB_PROP_BORDER_TOP_COLOR; i < NB_RGB_PROPS; i++) { - tmp_str = (gchar *) rgb_prop_code_to_string (i); + tmp_str = (gchar *) rgb_prop_code_to_string ((enum CRRgbProp)i); cr_utils_dump_n_chars2 (' ', str, indent); if (tmp_str) { g_string_append_printf (str, "%s: ", tmp_str); @@ -2711,7 +2705,8 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent) } /*loop over the border_style_props and to_string() them */ for (i = BORDER_STYLE_PROP_TOP; i < NB_BORDER_STYLE_PROPS; i++) { - tmp_str = (gchar *) border_style_prop_code_to_string (i); + tmp_str = (gchar *) + border_style_prop_code_to_string ((enum CRBorderStyleProp)i); cr_utils_dump_n_chars2 (' ', str, indent); if (tmp_str) { g_string_append_printf (str, "%s: ", tmp_str); @@ -2746,7 +2741,7 @@ cr_style_to_string (CRStyle * a_this, GString ** a_str, guint a_nb_indent) cr_utils_dump_n_chars2 (' ', str, indent); g_string_append (str, "font-family: "); - tmp_str = cr_font_family_to_string (a_this->font_family, TRUE); + tmp_str = (gchar *)cr_font_family_to_string (a_this->font_family, TRUE); if (tmp_str) { g_string_append (str, tmp_str); g_free (tmp_str);