From b4d15a07e08b1e7fbdc1834f7e85323a7450de19 Mon Sep 17 00:00:00 2001 From: ishmal Date: Wed, 15 Nov 2006 09:36:19 +0000 Subject: [PATCH] Make C++ - compilable. Mostly remove pointer casting problems. Fix a few places where C++ is stricter than C. --- src/libcroco/cr-additional-sel.c | 14 ++-- src/libcroco/cr-attr-sel.c | 14 ++-- src/libcroco/cr-cascade.c | 6 +- src/libcroco/cr-declaration.c | 29 ++++---- src/libcroco/cr-doc-handler.c | 8 +-- src/libcroco/cr-enc-handler.c | 9 ++- src/libcroco/cr-fonts.c | 43 ++++++------ src/libcroco/cr-input.c | 10 ++- src/libcroco/cr-libxml-node-iface.c | 4 +- src/libcroco/cr-libxml-node-iface.h | 2 +- src/libcroco/cr-num.c | 13 ++-- src/libcroco/cr-om-parser.c | 10 ++- src/libcroco/cr-parser.c | 55 +++++++-------- src/libcroco/cr-parsing-location.c | 11 ++- src/libcroco/cr-prop-list.c | 6 +- src/libcroco/cr-pseudo.c | 20 ++---- src/libcroco/cr-rgb.c | 28 ++++---- src/libcroco/cr-rgb.h | 4 +- src/libcroco/cr-selector.c | 14 ++-- src/libcroco/cr-simple-sel.c | 18 ++--- src/libcroco/cr-statement.c | 100 ++++++++++++---------------- src/libcroco/cr-string.c | 15 ++--- src/libcroco/cr-style.c | 98 +++++++++++++-------------- src/libcroco/cr-stylesheet.c | 4 +- src/libcroco/cr-term.c | 38 +++++------ src/libcroco/cr-tknzr.c | 22 +++--- src/libcroco/cr-token.c | 4 +- 27 files changed, 259 insertions(+), 340 deletions(-) diff --git a/src/libcroco/cr-additional-sel.c b/src/libcroco/cr-additional-sel.c index 9f511af06..80a4767e0 100644 --- a/src/libcroco/cr-additional-sel.c +++ b/src/libcroco/cr-additional-sel.c @@ -34,7 +34,7 @@ cr_additional_sel_new (void) { CRAdditionalSel *result = NULL; - result = g_try_malloc (sizeof (CRAdditionalSel)); + result = (CRAdditionalSel *)g_try_malloc (sizeof (CRAdditionalSel)); if (result == NULL) { cr_utils_trace_debug ("Out of memory"); @@ -219,7 +219,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this) guchar *name = NULL; if (cur->content.class_name) { - name = g_strndup + name = (guchar *)g_strndup (cur->content.class_name->stryng->str, cur->content.class_name->stryng->len); @@ -239,7 +239,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this) guchar *name = NULL; if (cur->content.class_name) { - name = g_strndup + name = (guchar *)g_strndup (cur->content.id_name->stryng->str, cur->content.id_name->stryng->len); @@ -295,7 +295,7 @@ cr_additional_sel_to_string (CRAdditionalSel * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } @@ -319,7 +319,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this) guchar *name = NULL; if (a_this->content.class_name) { - name = g_strndup + name = (guchar *)g_strndup (a_this->content.class_name->stryng->str, a_this->content.class_name->stryng->len); @@ -339,7 +339,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this) guchar *name = NULL; if (a_this->content.class_name) { - name = g_strndup + name = (guchar *)g_strndup (a_this->content.id_name->stryng->str, a_this->content.id_name->stryng->len); @@ -394,7 +394,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel *a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } diff --git a/src/libcroco/cr-attr-sel.c b/src/libcroco/cr-attr-sel.c index cf048d102..3c4800e66 100644 --- a/src/libcroco/cr-attr-sel.c +++ b/src/libcroco/cr-attr-sel.c @@ -39,9 +39,7 @@ CRAttrSel * cr_attr_sel_new (void) { - CRAttrSel *result = NULL; - - result = g_malloc0 (sizeof (CRAttrSel)); + CRAttrSel *result = (CRAttrSel *)g_malloc0 (sizeof (CRAttrSel)); return result; } @@ -112,9 +110,7 @@ cr_attr_sel_to_string (CRAttrSel * a_this) } if (cur->name) { - guchar *name = NULL; - - name = g_strndup (cur->name->stryng->str, + gchar *name = g_strndup (cur->name->stryng->str, cur->name->stryng->len); if (name) { g_string_append (str_buf, name); @@ -124,9 +120,7 @@ cr_attr_sel_to_string (CRAttrSel * a_this) } if (cur->value) { - guchar *value = NULL; - - value = g_strndup (cur->value->stryng->str, + gchar *value = g_strndup (cur->value->stryng->str, cur->value->stryng->len); if (value) { switch (cur->match_way) { @@ -159,7 +153,7 @@ cr_attr_sel_to_string (CRAttrSel * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); } diff --git a/src/libcroco/cr-cascade.c b/src/libcroco/cr-cascade.c index 51c6df5ac..f389fc746 100644 --- a/src/libcroco/cr-cascade.c +++ b/src/libcroco/cr-cascade.c @@ -61,16 +61,14 @@ CRCascade * cr_cascade_new (CRStyleSheet * a_author_sheet, CRStyleSheet * a_user_sheet, CRStyleSheet * a_ua_sheet) { - CRCascade *result = NULL; - - result = g_try_malloc (sizeof (CRCascade)); + CRCascade *result = (CRCascade *)g_try_malloc (sizeof (CRCascade)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; } memset (result, 0, sizeof (CRCascade)); - PRIVATE (result) = g_try_malloc (sizeof (CRCascadePriv)); + PRIVATE (result) = (CRCascadePriv *)g_try_malloc (sizeof (CRCascadePriv)); if (!PRIVATE (result)) { cr_utils_trace_info ("Out of memory"); return NULL; diff --git a/src/libcroco/cr-declaration.c b/src/libcroco/cr-declaration.c index a1ff0d292..ba8e0c95f 100644 --- a/src/libcroco/cr-declaration.c +++ b/src/libcroco/cr-declaration.c @@ -41,11 +41,9 @@ static void dump (CRDeclaration * a_this, FILE * a_fp, glong a_indent) { - guchar *str = NULL; - g_return_if_fail (a_this); - str = cr_declaration_to_string (a_this, a_indent); + gchar *str = cr_declaration_to_string (a_this, a_indent); if (str) { fprintf (a_fp, "%s", str); g_free (str); @@ -64,8 +62,6 @@ CRDeclaration * cr_declaration_new (CRStatement * a_statement, CRString * a_property, CRTerm * a_value) { - CRDeclaration *result = NULL; - g_return_val_if_fail (a_property, NULL); if (a_statement) @@ -76,7 +72,7 @@ cr_declaration_new (CRStatement * a_statement, || (a_statement->type == AT_PAGE_RULE_STMT)), NULL); - result = g_try_malloc (sizeof (CRDeclaration)); + CRDeclaration * result = (CRDeclaration *)g_try_malloc (sizeof (CRDeclaration)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -111,7 +107,6 @@ cr_declaration_parse_from_buf (CRStatement * a_statement, CRTerm *value = NULL; CRString *property = NULL; CRDeclaration *result = NULL; - CRParser *parser = NULL; gboolean important = FALSE; g_return_val_if_fail (a_str, NULL); @@ -119,7 +114,9 @@ cr_declaration_parse_from_buf (CRStatement * a_statement, g_return_val_if_fail (a_statement->type == RULESET_STMT, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str), a_enc, FALSE); + CRParser *parser = (CRParser *) + cr_parser_new_from_buf ((guchar*)a_str, + strlen ((char *)a_str), a_enc, FALSE); g_return_val_if_fail (parser, NULL); status = cr_parser_try_to_skip_spaces_and_comments (parser); @@ -175,13 +172,13 @@ cr_declaration_parse_list_from_buf (const guchar * a_str, CRString *property = NULL; CRDeclaration *result = NULL, *cur_decl = NULL; - CRParser *parser = NULL; CRTknzr *tokenizer = NULL; gboolean important = FALSE; g_return_val_if_fail (a_str, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str), a_enc, FALSE); + CRParser *parser = (CRParser *)cr_parser_new_from_buf + ((guchar*)a_str, strlen ((char *)a_str), a_enc, FALSE); g_return_val_if_fail (parser, NULL); status = cr_parser_get_tknzr (parser, &tokenizer); if (status != CR_OK || !tokenizer) { @@ -468,7 +465,7 @@ cr_declaration_to_string (CRDeclaration * a_this, gulong a_indent) { GString *stringue = NULL; - guchar *str = NULL, + gchar *str = NULL, *result = NULL; g_return_val_if_fail (a_this, NULL); @@ -535,7 +532,7 @@ cr_declaration_list_to_string (CRDeclaration * a_this, gulong a_indent) { CRDeclaration *cur = NULL; GString *stringue = NULL; - guchar *str = NULL, + gchar *str = NULL, *result = NULL; g_return_val_if_fail (a_this, NULL); @@ -555,7 +552,7 @@ cr_declaration_list_to_string (CRDeclaration * a_this, gulong a_indent) g_string_free (stringue, FALSE); } - return result; + return (guchar *)result; } /** @@ -570,7 +567,7 @@ cr_declaration_list_to_string2 (CRDeclaration * a_this, { CRDeclaration *cur = NULL; GString *stringue = NULL; - guchar *str = NULL, + gchar *str = NULL, *result = NULL; g_return_val_if_fail (a_this, NULL); @@ -604,7 +601,7 @@ cr_declaration_list_to_string2 (CRDeclaration * a_this, g_string_free (stringue, FALSE); } - return result; + return (guchar *)result; } /** @@ -666,7 +663,7 @@ cr_declaration_get_by_prop_name (CRDeclaration * a_this, && cur->property->stryng && cur->property->stryng->str) { if (!strcmp (cur->property->stryng->str, - a_prop)) { + (char *)a_prop)) { return cur; } } diff --git a/src/libcroco/cr-doc-handler.c b/src/libcroco/cr-doc-handler.c index 2780b6a20..00357c0f0 100644 --- a/src/libcroco/cr-doc-handler.c +++ b/src/libcroco/cr-doc-handler.c @@ -65,15 +65,13 @@ struct _CRDocHandlerPriv { CRDocHandler * cr_doc_handler_new (void) { - CRDocHandler *result = NULL; - - result = g_try_malloc (sizeof (CRDocHandler)); + CRDocHandler *result = ( CRDocHandler *)g_try_malloc (sizeof (CRDocHandler)); g_return_val_if_fail (result, NULL); memset (result, 0, sizeof (CRDocHandler)); - result->priv = g_try_malloc (sizeof (CRDocHandlerPriv)); + result->priv = (CRDocHandlerPriv *)g_try_malloc (sizeof (CRDocHandlerPriv)); if (!result->priv) { cr_utils_trace_info ("Out of memory exception"); g_free (result); @@ -248,5 +246,5 @@ cr_doc_handler_associate_a_parser (CRDocHandler *a_this, g_return_if_fail (a_this && PRIVATE (a_this) && a_parser) ; - PRIVATE (a_this)->parser = a_parser ; + PRIVATE (a_this)->parser = (CRParser *)a_parser ; } diff --git a/src/libcroco/cr-enc-handler.c b/src/libcroco/cr-enc-handler.c index 509793ab7..456ac51fa 100644 --- a/src/libcroco/cr-enc-handler.c +++ b/src/libcroco/cr-enc-handler.c @@ -57,7 +57,7 @@ static struct CREncAlias gv_default_aliases[] = { {"UCS-4", CR_UCS_4}, {"UCS_4", CR_UCS_4}, {"ASCII", CR_ASCII}, - {0, 0} + {(char *)0, (CREncoding)0} }; static CREncHandler gv_default_enc_handlers[] = { @@ -70,7 +70,7 @@ static CREncHandler gv_default_enc_handlers[] = { {CR_ASCII, cr_utils_ucs1_to_utf8, cr_utils_utf8_to_ucs1, cr_utils_ucs1_str_len_as_utf8, cr_utils_utf8_str_len_as_ucs1}, - {0, NULL, NULL, NULL, NULL} + {(CREncoding)0, NULL, NULL, NULL, NULL} }; /** @@ -107,12 +107,11 @@ cr_enc_handler_resolve_enc_alias (const guchar * a_alias_name, enum CREncoding *a_enc) { gulong i = 0; - guchar *alias_name_up = NULL; enum CRStatus status = CR_ENCODING_NOT_FOUND_ERROR; g_return_val_if_fail (a_alias_name != NULL, CR_BAD_PARAM_ERROR); - alias_name_up = g_strdup (a_alias_name); + gchar *alias_name_up = g_strdup ((gchar *)a_alias_name); g_ascii_strup (alias_name_up, -1); for (i = 0; gv_default_aliases[i].name; i++) { @@ -162,7 +161,7 @@ cr_enc_handler_convert_input (CREncHandler * a_this, *a_out_len = *a_in_len; } - *a_out = g_malloc0 (*a_out_len); + *a_out = (guchar *)g_malloc0 (*a_out_len); status = a_this->decode_input (a_in, a_in_len, *a_out, a_out_len); diff --git a/src/libcroco/cr-fonts.c b/src/libcroco/cr-fonts.c index 8c87aa229..63d8412f2 100644 --- a/src/libcroco/cr-fonts.c +++ b/src/libcroco/cr-fonts.c @@ -30,7 +30,7 @@ static enum CRStatus cr_font_family_to_string_real (CRFontFamily * a_this, gboolean a_walk_list, GString ** a_string) { - guchar *name = NULL; + gchar *name = NULL; enum CRStatus result = CR_OK; if (!*a_string) { @@ -46,31 +46,31 @@ cr_font_family_to_string_real (CRFontFamily * a_this, switch (a_this->type) { case FONT_FAMILY_SANS_SERIF: - name = (guchar *) "sans-serif"; + name = (gchar *) "sans-serif"; break; case FONT_FAMILY_SERIF: - name = (guchar *) "sans-serif"; + name = (gchar *) "sans-serif"; break; case FONT_FAMILY_CURSIVE: - name = (guchar *) "cursive"; + name = (gchar *) "cursive"; break; case FONT_FAMILY_FANTASY: - name = (guchar *) "fantasy"; + name = (gchar *) "fantasy"; break; case FONT_FAMILY_MONOSPACE: - name = (guchar *) "monospace"; + name = (gchar *) "monospace"; break; case FONT_FAMILY_NON_GENERIC: - name = (guchar *) a_this->name; + name = (gchar *) a_this->name; break; default: - name = (guchar *) NULL; + name = (gchar *) NULL; break; } @@ -144,9 +144,7 @@ cr_relative_font_size_to_string (enum CRRelativeFontSize a_code) CRFontFamily * cr_font_family_new (enum CRFontFamilyType a_type, guchar * a_name) { - CRFontFamily *result = NULL; - - result = g_try_malloc (sizeof (CRFontFamily)); + CRFontFamily *result = (CRFontFamily *)g_try_malloc (sizeof (CRFontFamily)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -166,13 +164,13 @@ cr_font_family_to_string (CRFontFamily * a_this, gboolean a_walk_font_family_list) { enum CRStatus status = CR_OK; - guchar *result = NULL; + gchar *result = NULL; GString *stringue = NULL; if (!a_this) { result = g_strdup ("NULL"); g_return_val_if_fail (result, NULL); - return result; + return (guchar *)result; } status = cr_font_family_to_string_real (a_this, a_walk_font_family_list, @@ -190,7 +188,7 @@ cr_font_family_to_string (CRFontFamily * a_this, } } - return result; + return (guchar *)result; } enum CRStatus cr_font_family_set_name (CRFontFamily * a_this, guchar * a_name) @@ -246,7 +244,7 @@ cr_font_family_prepend (CRFontFamily * a_this, a_family_to_prepend->next = a_this; a_this->prev = a_family_to_prepend; - return CR_OK; + return a_family_to_prepend; } enum CRStatus @@ -284,9 +282,7 @@ cr_font_family_destroy (CRFontFamily * a_this) CRFontSize * cr_font_size_new (void) { - CRFontSize *result = NULL; - - result = g_try_malloc (sizeof (CRFontSize)); + CRFontSize *result = (CRFontSize *)g_try_malloc (sizeof (CRFontSize)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -422,7 +418,7 @@ cr_font_size_to_string (CRFontSize * a_this) (a_this->value.predefined)); break; case ABSOLUTE_FONT_SIZE: - str = cr_num_to_string (&a_this->value.absolute); + str = (gchar *)cr_num_to_string (&a_this->value.absolute); break; case RELATIVE_FONT_SIZE: str = g_strdup (cr_relative_font_size_to_string @@ -551,7 +547,7 @@ cr_font_size_adjust_to_string (CRFontSizeAdjust * a_this) break; case FONT_SIZE_ADJUST_NUMBER: if (a_this->num) - str = cr_num_to_string (a_this->num); + str = (gchar *)cr_num_to_string (a_this->num); else str = g_strdup ("unknow font-size-adjust property value"); // Should raise an error no? break; @@ -617,7 +613,7 @@ cr_font_weight_get_bolder (enum CRFontWeight a_weight) cr_utils_trace_info ("FONT_WEIGHT_BOLDER or FONT_WEIGHT_LIGHTER should not appear here") ; return FONT_WEIGHT_NORMAL ; } else { - return a_weight << 1 ; + return (CRFontWeight)(a_weight << 1) ; } } @@ -737,9 +733,8 @@ cr_font_size_destroy (CRFontSize * a_font_size) CRFontSizeAdjust * cr_font_size_adjust_new (void) { - CRFontSizeAdjust *result = NULL; - - result = g_try_malloc (sizeof (CRFontSizeAdjust)); + CRFontSizeAdjust *result = + (CRFontSizeAdjust *)g_try_malloc (sizeof (CRFontSizeAdjust)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; diff --git a/src/libcroco/cr-input.c b/src/libcroco/cr-input.c index 9485df3c5..861329227 100644 --- a/src/libcroco/cr-input.c +++ b/src/libcroco/cr-input.c @@ -87,16 +87,14 @@ static CRInput *cr_input_new_real (void); static CRInput * cr_input_new_real (void) { - CRInput *result = NULL; - - result = g_try_malloc (sizeof (CRInput)); + CRInput *result = (CRInput *)g_try_malloc (sizeof (CRInput)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; } memset (result, 0, sizeof (CRInput)); - PRIVATE (result) = g_try_malloc (sizeof (CRInputPriv)); + PRIVATE (result) = (CRInputPriv *)g_try_malloc (sizeof (CRInputPriv)); if (!PRIVATE (result)) { cr_utils_trace_info ("Out of memory"); g_free (result); @@ -236,7 +234,7 @@ cr_input_new_from_uri (const gchar * a_file_uri, enum CREncoding a_enc) if (status == CR_OK) { /*read went well */ - buf = g_realloc (buf, len + CR_INPUT_MEM_CHUNK_SIZE); + buf = (guchar *)g_realloc (buf, len + CR_INPUT_MEM_CHUNK_SIZE); memcpy (buf + len, tmp_buf, nb_read); len += nb_read; buf_size += CR_INPUT_MEM_CHUNK_SIZE; @@ -723,7 +721,7 @@ cr_input_peek_char (CRInput * a_this, guint32 * a_char) status = cr_utils_read_char_from_utf8_buf (PRIVATE (a_this)->in_buf + PRIVATE (a_this)->next_byte_index, - nb_bytes_left, a_char, &consumed); + nb_bytes_left, a_char, (gulong *)&consumed); return status; } diff --git a/src/libcroco/cr-libxml-node-iface.c b/src/libcroco/cr-libxml-node-iface.c index fe785491b..bc860f974 100644 --- a/src/libcroco/cr-libxml-node-iface.c +++ b/src/libcroco/cr-libxml-node-iface.c @@ -44,7 +44,7 @@ static char const * libxml_getLocalName(CRXMLNodePtr cnode) { xmlNode const *xnode = (xmlNode const *) cnode; - return local_part(xnode->name); + return local_part((char *)xnode->name); } static char * @@ -52,7 +52,7 @@ libxml_getProp(CRXMLNodePtr cnode, char const *cprop) { xmlNodePtr xnode = (xmlNodePtr) cnode; xmlChar const *xprop = (xmlChar const *) cprop; - return xmlGetProp(xnode, xprop); + return (char *)xmlGetProp(xnode, xprop); } static gboolean diff --git a/src/libcroco/cr-libxml-node-iface.h b/src/libcroco/cr-libxml-node-iface.h index cb9bf2733..5da0d9ae3 100644 --- a/src/libcroco/cr-libxml-node-iface.h +++ b/src/libcroco/cr-libxml-node-iface.h @@ -6,7 +6,7 @@ G_BEGIN_DECLS -CRNodeIface const cr_libxml_node_iface; +extern CRNodeIface const cr_libxml_node_iface; G_END_DECLS diff --git a/src/libcroco/cr-num.c b/src/libcroco/cr-num.c index 45a63281b..c714894d6 100644 --- a/src/libcroco/cr-num.c +++ b/src/libcroco/cr-num.c @@ -40,9 +40,7 @@ CRNum * cr_num_new (void) { - CRNum *result = NULL; - - result = g_try_malloc (sizeof (CRNum)); + CRNum *result = (CRNum *)g_try_malloc (sizeof (CRNum)); if (result == NULL) { cr_utils_trace_info ("Out of memory"); @@ -104,13 +102,13 @@ cr_num_to_string (CRNum * a_this) test_val = a_this->val - (glong) a_this->val; if (!test_val) { - tmp_char1 = g_strdup_printf ("%ld", (glong) a_this->val); + tmp_char1 = (guchar *)g_strdup_printf ("%ld", (glong) a_this->val); } else { /* We can't use g_ascii_dtostr, because that sometimes uses e notation (which wouldn't be a valid number in CSS). */ size_t const buflen = 35; /* fairly arbitrary. */ - tmp_char1 = g_malloc (buflen); - g_ascii_formatd (tmp_char1, buflen, "%.17f", a_this->val); + tmp_char1 = (guchar *)g_malloc (buflen); + g_ascii_formatd ((gchar *)tmp_char1, buflen, "%.17f", a_this->val); } g_return_val_if_fail (tmp_char1, NULL); @@ -194,7 +192,8 @@ cr_num_to_string (CRNum * a_this) } if (tmp_char2) { - result = g_strconcat (tmp_char1, tmp_char2, NULL); + result = (guchar *)g_strconcat ( + (gchar *)tmp_char1, (gchar *)tmp_char2, NULL); g_free (tmp_char1); } else { result = tmp_char1; diff --git a/src/libcroco/cr-om-parser.c b/src/libcroco/cr-om-parser.c index 245f2d82f..b8d70e35a 100644 --- a/src/libcroco/cr-om-parser.c +++ b/src/libcroco/cr-om-parser.c @@ -112,9 +112,8 @@ struct _ParsingContext { static ParsingContext * new_parsing_context (void) { - ParsingContext *result = NULL; - - result = g_try_malloc (sizeof (ParsingContext)); + ParsingContext *result = + (ParsingContext *)g_try_malloc (sizeof (ParsingContext)); if (!result) { cr_utils_trace_info ("Out of Memory"); return NULL; @@ -778,10 +777,9 @@ unrecoverable_error (CRDocHandler * a_this) CROMParser * cr_om_parser_new (CRInput * a_input) { - CROMParser *result = NULL; enum CRStatus status = CR_OK; - result = g_try_malloc (sizeof (CROMParser)); + CROMParser *result = (CROMParser *)g_try_malloc (sizeof (CROMParser)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -789,7 +787,7 @@ cr_om_parser_new (CRInput * a_input) } memset (result, 0, sizeof (CROMParser)); - PRIVATE (result) = g_try_malloc (sizeof (CROMParserPriv)); + PRIVATE (result) = (CROMParserPriv *)g_try_malloc (sizeof (CROMParserPriv)); if (!PRIVATE (result)) { cr_utils_trace_info ("Out of memory"); diff --git a/src/libcroco/cr-parser.c b/src/libcroco/cr-parser.c index 7e71b927d..2b411a8d4 100644 --- a/src/libcroco/cr-parser.c +++ b/src/libcroco/cr-parser.c @@ -409,9 +409,7 @@ static enum CRStatus static CRParserError * cr_parser_error_new (const guchar * a_msg, enum CRStatus a_status) { - CRParserError *result = NULL; - - result = g_try_malloc (sizeof (CRParserError)); + CRParserError *result = (CRParserError *)g_try_malloc (sizeof (CRParserError)); if (result == NULL) { cr_utils_trace_info ("Out of memory"); @@ -440,7 +438,7 @@ cr_parser_error_set_msg (CRParserError * a_this, const guchar * a_msg) g_free (a_this->msg); } - a_this->msg = g_strdup (a_msg); + a_this->msg = (guchar *)g_strdup ((gchar *)a_msg); } /** @@ -727,7 +725,7 @@ cr_parser_parse_stylesheet_core (CRParser * a_this) error: cr_parser_push_error - (a_this, "could not recognize next production", CR_ERROR); + (a_this, (guchar *)"could not recognize next production", CR_ERROR); cr_parser_dump_err_stack (a_this, TRUE); @@ -1676,12 +1674,16 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) if (token && token->type == DELIM_TK && token->u.unichar == '*') { - sel->type_mask |= UNIVERSAL_SELECTOR; + int comb = (int)sel->type_mask | (int) UNIVERSAL_SELECTOR; + sel->type_mask = (SimpleSelectorType)comb; + //sel->type_mask |= UNIVERSAL_SELECTOR; sel->name = cr_string_new_from_string ("*"); found_sel = TRUE; } else if (token && token->type == IDENT_TK) { sel->name = token->u.str; - sel->type_mask |= TYPE_SELECTOR; + int comb = (int)sel->type_mask | (int) TYPE_SELECTOR; + sel->type_mask = (SimpleSelectorType)comb; + //sel->type_mask |= TYPE_SELECTOR; token->u.str = NULL; found_sel = TRUE; } else { @@ -1936,7 +1938,7 @@ cr_parser_parse_simple_sels (CRParser * a_this, for (;;) { guint32 next_char = 0; - enum Combinator comb = 0; + int comb = 0; sel = NULL; @@ -1959,7 +1961,7 @@ cr_parser_parse_simple_sels (CRParser * a_this, break; if (comb && sel) { - sel->combinator = comb; + sel->combinator = (Combinator)comb; comb = 0; } if (sel) { @@ -2443,7 +2445,7 @@ cr_parser_parse_stylesheet (CRParser * a_this) /*free the medium list */ for (cur = media_list; cur; cur = cur->next) { if (cur->data) { - cr_string_destroy (cur->data); + cr_string_destroy ((CRString *)cur->data); } } @@ -2683,7 +2685,7 @@ cr_parser_parse_stylesheet (CRParser * a_this) } cr_parser_push_error - (a_this, "could not recognize next production", CR_ERROR); + (a_this, (guchar *)"could not recognize next production", CR_ERROR); if (PRIVATE (a_this)->sac_handler && PRIVATE (a_this)->sac_handler->unrecoverable_error) { @@ -2730,12 +2732,11 @@ cr_parser_parse_stylesheet (CRParser * a_this) CRParser * cr_parser_new (CRTknzr * a_tknzr) { - CRParser *result = NULL; enum CRStatus status = CR_OK; - result = g_malloc0 (sizeof (CRParser)); + CRParser *result = (CRParser *)g_malloc0 (sizeof (CRParser)); - PRIVATE (result) = g_malloc0 (sizeof (CRParserPriv)); + PRIVATE (result) = (CRParserPriv *)g_malloc0 (sizeof (CRParserPriv)); if (a_tknzr) { status = cr_parser_set_tknzr (result, a_tknzr); @@ -2957,7 +2958,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr) CHECK_PARSING_STATUS (status, FALSE); for (;;) { - guchar operator = 0; + guchar operatr = 0; status = cr_tknzr_peek_byte (PRIVATE (a_this)->tknzr, 1, &next_byte); @@ -2977,7 +2978,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr) } if (next_byte == '/' || next_byte == ',') { - READ_NEXT_BYTE (a_this, &operator); + READ_NEXT_BYTE (a_this, &operatr); } cr_parser_try_to_skip_spaces_and_comments (a_this); @@ -2989,7 +2990,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr) break; } - switch (operator) { + switch (operatr) { case '/': expr2->the_operator = DIVIDE; break; @@ -3002,7 +3003,7 @@ cr_parser_parse_expr (CRParser * a_this, CRTerm ** a_expr) expr = cr_term_append_term (expr, expr2); expr2 = NULL; - operator = 0; + operatr = 0; nb_terms++; } @@ -3113,7 +3114,7 @@ cr_parser_parse_declaration (CRParser * a_this, CHECK_PARSING_STATUS_ERR (a_this, status, FALSE, - "while parsing declaration: next property is malformed", + (guchar *)"while parsing declaration: next property is malformed", CR_SYNTAX_ERROR); READ_NEXT_CHAR (a_this, &cur_char); @@ -3122,7 +3123,7 @@ cr_parser_parse_declaration (CRParser * a_this, status = CR_PARSING_ERROR; cr_parser_push_error (a_this, - "while parsing declaration: this char must be ':'", + (guchar *)"while parsing declaration: this char must be ':'", CR_SYNTAX_ERROR); goto error; } @@ -3133,7 +3134,7 @@ cr_parser_parse_declaration (CRParser * a_this, CHECK_PARSING_STATUS_ERR (a_this, status, FALSE, - "while parsing declaration: next expression is malformed", + (guchar *)"while parsing declaration: next expression is malformed", CR_SYNTAX_ERROR); cr_parser_try_to_skip_spaces_and_comments (a_this); @@ -3266,7 +3267,7 @@ cr_parser_parse_ruleset (CRParser * a_this) ENSURE_PARSING_COND_ERR (a_this, cur_char == '{', - "while parsing rulset: current char should be '{'", + (guchar *)"while parsing rulset: current char should be '{'", CR_SYNTAX_ERROR); if (PRIVATE (a_this)->sac_handler @@ -3330,7 +3331,7 @@ cr_parser_parse_ruleset (CRParser * a_this) } CHECK_PARSING_STATUS_ERR (a_this, status, FALSE, - "while parsing ruleset: next construction should be a declaration", + (guchar *)"while parsing ruleset: next construction should be a declaration", CR_SYNTAX_ERROR); for (;;) { @@ -3371,7 +3372,7 @@ cr_parser_parse_ruleset (CRParser * a_this) READ_NEXT_CHAR (a_this, &cur_char); ENSURE_PARSING_COND_ERR (a_this, cur_char == '}', - "while parsing rulset: current char must be a '}'", + (guchar *)"while parsing rulset: current char must be a '}'", CR_SYNTAX_ERROR); if (PRIVATE (a_this)->sac_handler @@ -3577,7 +3578,7 @@ cr_parser_parse_import (CRParser * a_this, */ for (cur = *a_media_list; cur; cur = cur->next) { if (cur->data) { - cr_string_destroy (cur->data); + cr_string_destroy ((CRString *)cur->data); } } @@ -3728,7 +3729,7 @@ cr_parser_parse_media (CRParser * a_this) GList *cur = NULL; for (cur = media_list; cur; cur = cur->next) { - cr_string_destroy (cur->data); + cr_string_destroy ((CRString *)cur->data); } g_list_free (media_list); @@ -3756,7 +3757,7 @@ cr_parser_parse_media (CRParser * a_this) GList *cur = NULL; for (cur = media_list; cur; cur = cur->next) { - cr_string_destroy (cur->data); + cr_string_destroy ((CRString *)cur->data); } g_list_free (media_list); diff --git a/src/libcroco/cr-parsing-location.c b/src/libcroco/cr-parsing-location.c index 81b05f7c3..49e8a3ce9 100644 --- a/src/libcroco/cr-parsing-location.c +++ b/src/libcroco/cr-parsing-location.c @@ -38,9 +38,8 @@ CRParsingLocation * cr_parsing_location_new (void) { - CRParsingLocation * result = NULL ; - - result = g_try_malloc (sizeof (CRParsingLocation)) ; + CRParsingLocation *result = + (CRParsingLocation *)g_try_malloc (sizeof (CRParsingLocation)) ; if (!result) { cr_utils_trace_info ("Out of memory error") ; return NULL ; @@ -91,15 +90,15 @@ gchar * cr_parsing_location_to_string (CRParsingLocation *a_this, enum CRParsingLocationSerialisationMask a_mask) { - GString *result = NULL ; gchar *str = NULL ; g_return_val_if_fail (a_this, NULL) ; if (!a_mask) { - a_mask = DUMP_LINE | DUMP_COLUMN | DUMP_BYTE_OFFSET ; + a_mask = (CRParsingLocationSerialisationMask) + ((int)DUMP_LINE | (int)DUMP_COLUMN | (int)DUMP_BYTE_OFFSET) ; } - result =g_string_new (NULL) ; + GString *result = (GString *)g_string_new (NULL) ; if (!result) return NULL ; if (a_mask & DUMP_LINE) { diff --git a/src/libcroco/cr-prop-list.c b/src/libcroco/cr-prop-list.c index 4c56b9cd3..076837905 100644 --- a/src/libcroco/cr-prop-list.c +++ b/src/libcroco/cr-prop-list.c @@ -41,15 +41,13 @@ static CRPropList *cr_prop_list_allocate (void); static CRPropList * cr_prop_list_allocate (void) { - CRPropList *result = NULL; - - result = g_try_malloc (sizeof (CRPropList)); + CRPropList *result = (CRPropList *)g_try_malloc (sizeof (CRPropList)); if (!result) { cr_utils_trace_info ("could not allocate CRPropList"); return NULL; } memset (result, 0, sizeof (CRPropList)); - PRIVATE (result) = g_try_malloc (sizeof (CRPropListPriv)); + PRIVATE (result) = (CRPropListPriv *)g_try_malloc (sizeof (CRPropListPriv)); if (!result) { cr_utils_trace_info ("could not allocate CRPropListPriv"); g_free (result); diff --git a/src/libcroco/cr-pseudo.c b/src/libcroco/cr-pseudo.c index 8e036a30f..abb4f9bd4 100644 --- a/src/libcroco/cr-pseudo.c +++ b/src/libcroco/cr-pseudo.c @@ -35,9 +35,7 @@ CRPseudo * cr_pseudo_new (void) { - CRPseudo *result = NULL; - - result = g_malloc0 (sizeof (CRPseudo)); + CRPseudo *result = (CRPseudo *)g_malloc0 (sizeof (CRPseudo)); return result; } @@ -46,20 +44,17 @@ guchar * cr_pseudo_to_string (CRPseudo * a_this) { guchar *result = NULL; - GString *str_buf = NULL; g_return_val_if_fail (a_this, NULL); - str_buf = g_string_new (NULL); + GString *str_buf = (GString *)g_string_new (NULL); if (a_this->type == IDENT_PSEUDO) { - guchar *name = NULL; - if (a_this->name == NULL) { + if (a_this->name == NULL) goto error; - } - name = g_strndup (a_this->name->stryng->str, + gchar *name = g_strndup (a_this->name->stryng->str, a_this->name->stryng->len); if (name) { @@ -68,13 +63,12 @@ cr_pseudo_to_string (CRPseudo * a_this) name = NULL; } } else if (a_this->type == FUNCTION_PSEUDO) { - guchar *name = NULL, - *arg = NULL; + gchar *arg = NULL; if (a_this->name == NULL) goto error; - name = g_strndup (a_this->name->stryng->str, + gchar *name = g_strndup (a_this->name->stryng->str, a_this->name->stryng->len); if (a_this->extra) { @@ -98,7 +92,7 @@ cr_pseudo_to_string (CRPseudo * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } diff --git a/src/libcroco/cr-rgb.c b/src/libcroco/cr-rgb.c index 4bda1968e..893c2080b 100644 --- a/src/libcroco/cr-rgb.c +++ b/src/libcroco/cr-rgb.c @@ -186,9 +186,7 @@ static CRRgb gv_standard_colors[] = { CRRgb * cr_rgb_new (void) { - CRRgb *result = NULL; - - result = g_try_malloc (sizeof (CRRgb)); + CRRgb *result = (CRRgb *)g_try_malloc (sizeof (CRRgb)); if (result == NULL) { cr_utils_trace_info ("No more memory"); @@ -236,10 +234,8 @@ cr_rgb_new_with_vals (gulong a_red, gulong a_green, guchar * cr_rgb_to_string (CRRgb * a_this) { - guchar *result = NULL; - GString *str_buf = NULL; - - str_buf = g_string_new (NULL); + gchar *result = NULL; + GString *str_buf = (GString *)g_string_new (NULL); g_return_val_if_fail (str_buf, NULL); if (a_this->is_percentage == 1) { @@ -267,7 +263,7 @@ cr_rgb_to_string (CRRgb * a_this) g_string_free (str_buf, FALSE); } - return result; + return (guchar *)result; } /** @@ -423,7 +419,7 @@ cr_rgb_set_from_name (CRRgb * a_this, const guchar * a_color_name) g_return_val_if_fail (a_this && a_color_name, CR_BAD_PARAM_ERROR); for (i = 0; i < sizeof (gv_standard_colors); i++) { - if (!strcmp (a_color_name, gv_standard_colors[i].name)) { + if (!strcmp ((char *)a_color_name, gv_standard_colors[i].name)) { cr_rgb_set_from_rgb (a_this, &gv_standard_colors[i]); break; } @@ -446,7 +442,7 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex) g_return_val_if_fail (a_this && a_hex, CR_BAD_PARAM_ERROR); - if (strlen (a_hex) == 3) { + if (strlen ((char *)a_hex) == 3) { for (i = 0; i < 3; i++) { if (a_hex[i] >= '0' && a_hex[i] <= '9') { colors[i] = a_hex[i] - '0'; @@ -461,7 +457,7 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex) status = CR_UNKNOWN_TYPE_ERROR; } } - } else if (strlen (a_hex) == 6) { + } else if (strlen ((char *)a_hex) == 6) { for (i = 0; i < 6; i++) { if (a_hex[i] >= '0' && a_hex[i] <= '9') { colors[i / 2] <<= 4; @@ -499,8 +495,8 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex) enum CRStatus cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value) { - enum CRStatus status = CR_OK ; - g_return_val_if_fail (a_this && a_value, + enum CRStatus status = CR_OK ; + g_return_val_if_fail (a_this && a_value, CR_BAD_PARAM_ERROR) ; switch(a_value->type) { @@ -522,7 +518,7 @@ cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value) } else { status = cr_rgb_set_from_name (a_this, - a_value->content.str->stryng->str) ; + (guchar *)a_value->content.str->stryng->str) ; } } else { cr_utils_trace_info @@ -535,7 +531,7 @@ cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value) && a_value->content.str->stryng->str) { status = cr_rgb_set_from_hex_str (a_this, - a_value->content.str->stryng->str) ; + (guchar *)a_value->content.str->stryng->str) ; } else { cr_utils_trace_info ("a_value has NULL string value") ; @@ -586,7 +582,7 @@ CRRgb *cr_rgb_parse_from_buf (const guchar *a_str, g_return_val_if_fail (a_str, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str), + parser = cr_parser_new_from_buf ((guchar *)a_str, strlen ((char *)a_str), a_enc, FALSE) ; g_return_val_if_fail (parser, NULL); diff --git a/src/libcroco/cr-rgb.h b/src/libcroco/cr-rgb.h index f6b4e8aa1..50cec94ec 100644 --- a/src/libcroco/cr-rgb.h +++ b/src/libcroco/cr-rgb.h @@ -39,12 +39,12 @@ struct _CRRgb *Either NO_UNIT (integer) or *UNIT_PERCENTAGE (percentage). */ - const guchar *name ; + const gchar *name ; glong red ; glong green ; glong blue ; gboolean is_percentage ; - gboolean inherit ; + gboolean inherit ; gboolean is_transparent ; CRParsingLocation location ; } ; diff --git a/src/libcroco/cr-selector.c b/src/libcroco/cr-selector.c index 5f7316a00..d85b3effc 100644 --- a/src/libcroco/cr-selector.c +++ b/src/libcroco/cr-selector.c @@ -34,9 +34,7 @@ CRSelector * cr_selector_new (CRSimpleSel * a_simple_sel) { - CRSelector *result = NULL; - - result = g_try_malloc (sizeof (CRSelector)); + CRSelector *result = (CRSelector *)g_try_malloc (sizeof (CRSelector)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -53,7 +51,8 @@ cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc) g_return_val_if_fail (a_char_buf, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_char_buf, strlen (a_char_buf), + parser = cr_parser_new_from_buf ((guchar*)a_char_buf, + strlen ((char *)a_char_buf), a_enc, FALSE); g_return_val_if_fail (parser, NULL); @@ -125,9 +124,8 @@ guchar * cr_selector_to_string (CRSelector * a_this) { guchar *result = NULL; - GString *str_buf = NULL; - str_buf = g_string_new (NULL); + GString *str_buf = (GString *)g_string_new (NULL); g_return_val_if_fail (str_buf, NULL); if (a_this) { @@ -145,7 +143,7 @@ cr_selector_to_string (CRSelector * a_this) g_string_append (str_buf, ", "); - g_string_append (str_buf, tmp_str); + g_string_append (str_buf, (gchar *)tmp_str); g_free (tmp_str); tmp_str = NULL; @@ -155,7 +153,7 @@ cr_selector_to_string (CRSelector * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } diff --git a/src/libcroco/cr-simple-sel.c b/src/libcroco/cr-simple-sel.c index 1b941dab5..18dd340d8 100644 --- a/src/libcroco/cr-simple-sel.c +++ b/src/libcroco/cr-simple-sel.c @@ -33,9 +33,7 @@ CRSimpleSel * cr_simple_sel_new (void) { - CRSimpleSel *result = NULL; - - result = g_try_malloc (sizeof (CRSimpleSel)); + CRSimpleSel *result = (CRSimpleSel *)g_try_malloc (sizeof (CRSimpleSel)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -103,7 +101,7 @@ cr_simple_sel_to_string (CRSimpleSel * a_this) str_buf = g_string_new (NULL); for (cur = a_this; cur; cur = cur->next) { if (cur->name) { - guchar *str = g_strndup (cur->name->stryng->str, + gchar *str = g_strndup (cur->name->stryng->str, cur->name->stryng->len); if (str) { @@ -131,9 +129,8 @@ cr_simple_sel_to_string (CRSimpleSel * a_this) } if (cur->add_sel) { - guchar *tmp_str = NULL; - tmp_str = cr_additional_sel_to_string (cur->add_sel); + gchar *tmp_str = (gchar *)cr_additional_sel_to_string (cur->add_sel); if (tmp_str) { g_string_append (str_buf, tmp_str); g_free (tmp_str); @@ -143,7 +140,7 @@ cr_simple_sel_to_string (CRSimpleSel * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } @@ -162,7 +159,7 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this) str_buf = g_string_new (NULL); if (a_this->name) { - guchar *str = g_strndup (a_this->name->stryng->str, + gchar *str = g_strndup (a_this->name->stryng->str, a_this->name->stryng->len); if (str) { @@ -173,9 +170,8 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this) } if (a_this->add_sel) { - guchar *tmp_str = NULL; - tmp_str = cr_additional_sel_to_string (a_this->add_sel); + gchar *tmp_str = (gchar *)cr_additional_sel_to_string (a_this->add_sel); if (tmp_str) { g_string_append_printf (str_buf, "%s", tmp_str); @@ -185,7 +181,7 @@ cr_simple_sel_one_to_string (CRSimpleSel * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } diff --git a/src/libcroco/cr-statement.c b/src/libcroco/cr-statement.c index c00da1546..501741c37 100644 --- a/src/libcroco/cr-statement.c +++ b/src/libcroco/cr-statement.c @@ -599,19 +599,18 @@ cr_statement_clear (CRStatement * a_this) static gchar * cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent) { - GString *stringue = NULL; gchar *tmp_str = NULL, *result = NULL; g_return_val_if_fail (a_this && a_this->type == RULESET_STMT, NULL); - stringue = g_string_new (NULL); + GString *stringue = (GString *)g_string_new (NULL); if (a_this->kind.ruleset->sel_list) { if (a_indent) cr_utils_dump_n_chars2 (' ', stringue, a_indent); - tmp_str = + tmp_str = (gchar *) cr_selector_to_string (a_this->kind.ruleset-> sel_list); if (tmp_str) { @@ -622,7 +621,7 @@ cr_statement_ruleset_to_string (CRStatement * a_this, glong a_indent) } g_string_append (stringue, " {\n"); if (a_this->kind.ruleset->decl_list) { - tmp_str = cr_declaration_list_to_string2 + tmp_str = (gchar *)cr_declaration_list_to_string2 (a_this->kind.ruleset->decl_list, a_indent + DECLARATION_INDENT_NB, TRUE); if (tmp_str) { @@ -668,13 +667,13 @@ cr_statement_font_face_rule_to_string (CRStatement * a_this, NULL); if (a_this->kind.font_face_rule->decl_list) { - stringue = g_string_new (NULL) ; + stringue = (GString *)g_string_new (NULL) ; g_return_val_if_fail (stringue, NULL) ; if (a_indent) cr_utils_dump_n_chars2 (' ', stringue, a_indent); g_string_append (stringue, "@font-face {\n"); - tmp_str = cr_declaration_list_to_string2 + tmp_str = (gchar *)cr_declaration_list_to_string2 (a_this->kind.font_face_rule->decl_list, a_indent + DECLARATION_INDENT_NB, TRUE) ; if (tmp_str) { @@ -746,10 +745,9 @@ static gchar * cr_statement_at_page_rule_to_string (CRStatement *a_this, gulong a_indent) { - GString *stringue = NULL; gchar *result = NULL ; - stringue = g_string_new (NULL) ; + GString *stringue = (GString *)g_string_new (NULL) ; cr_utils_dump_n_chars2 (' ', stringue, a_indent) ; g_string_append (stringue, "@page"); @@ -770,7 +768,7 @@ cr_statement_at_page_rule_to_string (CRStatement *a_this, if (a_this->kind.page_rule->decl_list) { gchar *str = NULL ; g_string_append (stringue, " {\n"); - str = cr_declaration_list_to_string2 + str = (gchar *)cr_declaration_list_to_string2 (a_this->kind.page_rule->decl_list, a_indent + DECLARATION_INDENT_NB, TRUE) ; if (str) { @@ -806,14 +804,14 @@ cr_statement_media_rule_to_string (CRStatement *a_this, NULL); if (a_this->kind.media_rule) { - stringue = g_string_new (NULL) ; + stringue = (GString *)g_string_new (NULL) ; cr_utils_dump_n_chars2 (' ', stringue, a_indent); g_string_append (stringue, "@media"); for (cur = a_this->kind.media_rule->media_list; cur; cur = cur->next) { if (cur->data) { - guchar *str = cr_string_dup2 + gchar *str = cr_string_dup2 ((CRString *) cur->data); if (str) { @@ -854,7 +852,7 @@ cr_statement_import_rule_to_string (CRStatement *a_this, gulong a_indent) { GString *stringue = NULL ; - guchar *str = NULL; + gchar *str = NULL; g_return_val_if_fail (a_this && a_this->type == AT_IMPORT_RULE_STMT @@ -863,7 +861,7 @@ cr_statement_import_rule_to_string (CRStatement *a_this, if (a_this->kind.import_rule->url && a_this->kind.import_rule->url->stryng) { - stringue = g_string_new (NULL) ; + stringue = (GString *)g_string_new (NULL) ; g_return_val_if_fail (stringue, NULL) ; str = g_strndup (a_this->kind.import_rule->url->stryng->str, a_this->kind.import_rule->url->stryng->len); @@ -883,7 +881,7 @@ cr_statement_import_rule_to_string (CRStatement *a_this, for (cur = a_this->kind.import_rule->media_list; cur; cur = cur->next) { if (cur->data) { - CRString *crstr = cur->data; + CRString *crstr = (CRString *)cur->data; if (cur->prev) { g_string_append @@ -931,7 +929,8 @@ cr_statement_does_buf_parses_against_core (const guchar * a_buf, enum CRStatus status = CR_OK; gboolean result = FALSE; - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + parser = cr_parser_new_from_buf ((guchar*)a_buf, + strlen ((char *)a_buf), a_encoding, FALSE); g_return_val_if_fail (parser, FALSE); @@ -1043,7 +1042,8 @@ cr_statement_ruleset_parse_from_buf (const guchar * a_buf, g_return_val_if_fail (a_buf, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + parser = cr_parser_new_from_buf ((guchar*)a_buf, + strlen ((char *)a_buf), a_enc, FALSE); g_return_val_if_fail (parser, NULL); @@ -1105,8 +1105,6 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet, CRDeclaration * a_decl_list, CRStatement * a_parent_media_rule) { - CRStatement *result = NULL; - g_return_val_if_fail (a_sel_list, NULL); if (a_parent_media_rule) { @@ -1117,7 +1115,7 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet, NULL); } - result = g_try_malloc (sizeof (CRStatement)); + CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -1126,7 +1124,7 @@ cr_statement_new_ruleset (CRStyleSheet * a_sheet, memset (result, 0, sizeof (CRStatement)); result->type = RULESET_STMT; - result->kind.ruleset = g_try_malloc (sizeof (CRRuleSet)); + result->kind.ruleset = (CRRuleSet *)g_try_malloc (sizeof (CRRuleSet)); if (!result->kind.ruleset) { cr_utils_trace_info ("Out of memory"); @@ -1172,7 +1170,8 @@ cr_statement_at_media_rule_parse_from_buf (const guchar * a_buf, CRDocHandler *sac_handler = NULL; enum CRStatus status = CR_OK; - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + parser = cr_parser_new_from_buf ((guchar*)a_buf, + strlen ((char *)a_buf), a_enc, FALSE); if (!parser) { cr_utils_trace_info ("Instanciation of the parser failed"); @@ -1238,13 +1237,12 @@ CRStatement * cr_statement_new_at_media_rule (CRStyleSheet * a_sheet, CRStatement * a_rulesets, GList * a_media) { - CRStatement *result = NULL, - *cur = NULL; + CRStatement *cur = NULL; if (a_rulesets) g_return_val_if_fail (a_rulesets->type == RULESET_STMT, NULL); - result = g_try_malloc (sizeof (CRStatement)); + CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -1254,7 +1252,7 @@ cr_statement_new_at_media_rule (CRStyleSheet * a_sheet, memset (result, 0, sizeof (CRStatement)); result->type = AT_MEDIA_RULE_STMT; - result->kind.media_rule = g_try_malloc (sizeof (CRAtMediaRule)); + result->kind.media_rule = (CRAtMediaRule *)g_try_malloc (sizeof (CRAtMediaRule)); if (!result->kind.media_rule) { cr_utils_trace_info ("Out of memory"); g_free (result); @@ -1297,9 +1295,7 @@ cr_statement_new_at_import_rule (CRStyleSheet * a_container_sheet, GList * a_media_list, CRStyleSheet * a_imported_sheet) { - CRStatement *result = NULL; - - result = g_try_malloc (sizeof (CRStatement)); + CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -1309,7 +1305,7 @@ cr_statement_new_at_import_rule (CRStyleSheet * a_container_sheet, memset (result, 0, sizeof (CRStatement)); result->type = AT_IMPORT_RULE_STMT; - result->kind.import_rule = g_try_malloc (sizeof (CRAtImportRule)); + result->kind.import_rule = (CRAtImportRule *)g_try_malloc (sizeof (CRAtImportRule)); if (!result->kind.import_rule) { cr_utils_trace_info ("Out of memory"); @@ -1346,7 +1342,8 @@ cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf, CRString *import_string = NULL; CRParsingLocation location = {0,0,0} ; - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + parser = cr_parser_new_from_buf ((guchar*)a_buf, + strlen ((char *)a_buf), a_encoding, FALSE); if (!parser) { cr_utils_trace_info ("Instanciation of parser failed."); @@ -1414,9 +1411,7 @@ cr_statement_new_at_page_rule (CRStyleSheet * a_sheet, CRDeclaration * a_decl_list, CRString * a_name, CRString * a_pseudo) { - CRStatement *result = NULL; - - result = g_try_malloc (sizeof (CRStatement)); + CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -1426,7 +1421,7 @@ cr_statement_new_at_page_rule (CRStyleSheet * a_sheet, memset (result, 0, sizeof (CRStatement)); result->type = AT_PAGE_RULE_STMT; - result->kind.page_rule = g_try_malloc (sizeof (CRAtPageRule)); + result->kind.page_rule = (CRAtPageRule *)g_try_malloc (sizeof (CRAtPageRule)); if (!result->kind.page_rule) { cr_utils_trace_info ("Out of memory"); @@ -1460,14 +1455,14 @@ cr_statement_at_page_rule_parse_from_buf (const guchar * a_buf, enum CREncoding a_encoding) { enum CRStatus status = CR_OK; - CRParser *parser = NULL; CRDocHandler *sac_handler = NULL; CRStatement *result = NULL; CRStatement **resultptr = NULL; g_return_val_if_fail (a_buf, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + CRParser *parser = cr_parser_new_from_buf ((guchar*)a_buf, + strlen ((char *)a_buf), a_encoding, FALSE); if (!parser) { cr_utils_trace_info ("Instanciation of the parser failed."); @@ -1529,11 +1524,9 @@ CRStatement * cr_statement_new_at_charset_rule (CRStyleSheet * a_sheet, CRString * a_charset) { - CRStatement *result = NULL; - g_return_val_if_fail (a_charset, NULL); - result = g_try_malloc (sizeof (CRStatement)); + CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -1543,7 +1536,7 @@ cr_statement_new_at_charset_rule (CRStyleSheet * a_sheet, memset (result, 0, sizeof (CRStatement)); result->type = AT_CHARSET_RULE_STMT; - result->kind.charset_rule = g_try_malloc (sizeof (CRAtCharsetRule)); + result->kind.charset_rule = (CRAtCharsetRule *)g_try_malloc (sizeof (CRAtCharsetRule)); if (!result->kind.charset_rule) { cr_utils_trace_info ("Out of memory"); @@ -1569,13 +1562,13 @@ cr_statement_at_charset_rule_parse_from_buf (const guchar * a_buf, enum CREncoding a_encoding) { enum CRStatus status = CR_OK; - CRParser *parser = NULL; CRStatement *result = NULL; CRString *charset = NULL; g_return_val_if_fail (a_buf, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + CRParser *parser = cr_parser_new_from_buf ((guchar*)a_buf, + strlen ((char *)a_buf), a_encoding, FALSE); if (!parser) { cr_utils_trace_info ("Instanciation of the parser failed."); @@ -1617,9 +1610,7 @@ CRStatement * cr_statement_new_at_font_face_rule (CRStyleSheet * a_sheet, CRDeclaration * a_font_decls) { - CRStatement *result = NULL; - - result = g_try_malloc (sizeof (CRStatement)); + CRStatement *result = (CRStatement *)g_try_malloc (sizeof (CRStatement)); if (!result) { cr_utils_trace_info ("Out of memory"); @@ -1628,7 +1619,7 @@ cr_statement_new_at_font_face_rule (CRStyleSheet * a_sheet, memset (result, 0, sizeof (CRStatement)); result->type = AT_FONT_FACE_RULE_STMT; - result->kind.font_face_rule = g_try_malloc + result->kind.font_face_rule = (CRAtFontFaceRule *)g_try_malloc (sizeof (CRAtFontFaceRule)); if (!result->kind.font_face_rule) { @@ -1659,11 +1650,12 @@ cr_statement_font_face_rule_parse_from_buf (const guchar * a_buf, { CRStatement *result = NULL; CRStatement **resultptr = NULL; - CRParser *parser = NULL; CRDocHandler *sac_handler = NULL; enum CRStatus status = CR_OK; - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), + CRParser *parser = (CRParser *)cr_parser_new_from_buf ( + (guchar*)a_buf, + strlen ((char *)a_buf), a_encoding, FALSE); if (!parser) goto cleanup; @@ -2437,10 +2429,8 @@ cr_statement_dump (CRStatement * a_this, FILE * a_fp, gulong a_indent) void cr_statement_dump_ruleset (CRStatement * a_this, FILE * a_fp, glong a_indent) { - guchar *str = NULL; - g_return_if_fail (a_fp && a_this); - str = cr_statement_ruleset_to_string (a_this, a_indent); + gchar *str = cr_statement_ruleset_to_string (a_this, a_indent); if (str) { fprintf (a_fp, str); g_free (str); @@ -2480,11 +2470,9 @@ cr_statement_dump_font_face_rule (CRStatement * a_this, FILE * a_fp, void cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp, gulong a_indent) { - guchar *str = NULL; - g_return_if_fail (a_this && a_this->type == AT_CHARSET_RULE_STMT); - str = cr_statement_charset_to_string (a_this, + gchar *str = cr_statement_charset_to_string (a_this, a_indent) ; if (str) { fprintf (a_fp, str) ; @@ -2503,13 +2491,11 @@ cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp, gulong a_indent) void cr_statement_dump_page (CRStatement * a_this, FILE * a_fp, gulong a_indent) { - guchar *str = NULL; - g_return_if_fail (a_this && a_this->type == AT_PAGE_RULE_STMT && a_this->kind.page_rule); - str = cr_statement_at_page_rule_to_string (a_this, a_indent) ; + gchar *str = cr_statement_at_page_rule_to_string (a_this, a_indent) ; if (str) { fprintf (a_fp, str); g_free (str) ; diff --git a/src/libcroco/cr-string.c b/src/libcroco/cr-string.c index 2529b72be..7c656f54d 100644 --- a/src/libcroco/cr-string.c +++ b/src/libcroco/cr-string.c @@ -32,9 +32,7 @@ CRString * cr_string_new (void) { - CRString *result = NULL ; - - result = g_try_malloc (sizeof (CRString)) ; + CRString *result = (CRString *)g_try_malloc (sizeof (CRString)) ; if (!result) { cr_utils_trace_info ("Out of memory") ; return NULL ; @@ -53,9 +51,7 @@ cr_string_new (void) CRString * cr_string_new_from_string (const gchar * a_string) { - CRString *result = NULL ; - - result = cr_string_new () ; + CRString *result = cr_string_new () ; if (!result) { cr_utils_trace_info ("Out of memory") ; return NULL ; @@ -74,9 +70,7 @@ cr_string_new_from_string (const gchar * a_string) CRString * cr_string_new_from_gstring (GString *a_string) { - CRString *result = NULL ; - - result = cr_string_new () ; + CRString *result = cr_string_new () ; if (!result) { cr_utils_trace_info ("Out of memory") ; return NULL ; @@ -93,10 +87,9 @@ cr_string_new_from_gstring (GString *a_string) CRString * cr_string_dup (CRString *a_this) { - CRString *result = NULL ; g_return_val_if_fail (a_this, NULL) ; - result = cr_string_new_from_gstring (a_this->stryng) ; + CRString *result = cr_string_new_from_gstring (a_this->stryng) ; if (!result) { cr_utils_trace_info ("Out of memory") ; return NULL ; diff --git a/src/libcroco/cr-style.c b/src/libcroco/cr-style.c index 789d68f42..82b2a2494 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, (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} + {(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} + {(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} + {(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 (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, + for (int dir = (int) DIR_TOP ; + dir < (int)NB_DIRS ; dir++) { + CRDirection direction = (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 ++) { + for (int dir = (int)DIR_TOP ; dir < (int)NB_DIRS ; dir++) + { + CRDirection direction = (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,12 @@ 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++) { + for (int direction = 0; direction < NB_DIRS; direction++) { set_prop_border_x_from_value (a_style, a_value, - direction); + (CRDirection)direction); } return CR_OK; @@ -1183,7 +1176,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 +1189,9 @@ 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); + for (int direction = 0; direction < (int)NB_DIRS; direction++) { + set_prop_padding_x_from_value (a_style, + cur_term, (CRDirection)direction); } cur_term = cur_term->next; @@ -1234,7 +1227,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 +1240,9 @@ 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); + for (int direction = 0; direction < (int)NB_DIRS; direction++) { + set_prop_margin_x_from_value(a_style, + cur_term, (CRDirection)direction); } cur_term = cur_term->next; @@ -1358,7 +1351,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 +1669,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 +1704,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 +2015,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 +2673,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 ((CRNumProp)i); if (tmp_str) { g_string_append_printf (str, "%s: ", tmp_str); } else { @@ -2696,7 +2687,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 ((CRRgbProp)i); cr_utils_dump_n_chars2 (' ', str, indent); if (tmp_str) { g_string_append_printf (str, "%s: ", tmp_str); @@ -2711,7 +2702,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 ((CRBorderStyleProp)i); cr_utils_dump_n_chars2 (' ', str, indent); if (tmp_str) { g_string_append_printf (str, "%s: ", tmp_str); @@ -2746,7 +2738,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); diff --git a/src/libcroco/cr-stylesheet.c b/src/libcroco/cr-stylesheet.c index 9aeb551e4..06b27fcab 100644 --- a/src/libcroco/cr-stylesheet.c +++ b/src/libcroco/cr-stylesheet.c @@ -36,9 +36,7 @@ CRStyleSheet * cr_stylesheet_new (CRStatement * a_stmts) { - CRStyleSheet *result; - - result = g_try_malloc (sizeof (CRStyleSheet)); + CRStyleSheet *result = (CRStyleSheet *)g_try_malloc (sizeof (CRStyleSheet)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; diff --git a/src/libcroco/cr-term.c b/src/libcroco/cr-term.c index 33eed40f9..63b39271b 100644 --- a/src/libcroco/cr-term.c +++ b/src/libcroco/cr-term.c @@ -84,9 +84,7 @@ cr_term_clear (CRTerm * a_this) CRTerm * cr_term_new (void) { - CRTerm *result = NULL; - - result = g_try_malloc (sizeof (CRTerm)); + CRTerm *result = (CRTerm *)g_try_malloc (sizeof (CRTerm)); if (!result) { cr_utils_trace_info ("Out of memory"); return NULL; @@ -106,14 +104,15 @@ CRTerm * cr_term_parse_expression_from_buf (const guchar * a_buf, enum CREncoding a_encoding) { - CRParser *parser = NULL; CRTerm *result = NULL; enum CRStatus status = CR_OK; g_return_val_if_fail (a_buf, NULL); - parser = cr_parser_new_from_buf ((guchar*)a_buf, strlen (a_buf), - a_encoding, FALSE); + CRParser *parser = cr_parser_new_from_buf ( + (guchar*)a_buf, + strlen ((char *)a_buf), + a_encoding, FALSE); g_return_val_if_fail (parser, NULL); status = cr_parser_try_to_skip_spaces_and_comments (parser); @@ -280,8 +279,8 @@ cr_term_to_string (CRTerm * a_this) { GString *str_buf = NULL; CRTerm *cur = NULL; - guchar *result = NULL, - *content = NULL; + guchar *result = NULL; + gchar *content = NULL; g_return_val_if_fail (a_this, NULL); @@ -330,7 +329,7 @@ cr_term_to_string (CRTerm * a_this) switch (cur->type) { case TERM_NUMBER: if (cur->content.num) { - content = cr_num_to_string (cur->content.num); + content = (gchar *)cr_num_to_string (cur->content.num); } if (content) { @@ -361,7 +360,7 @@ cr_term_to_string (CRTerm * a_this) if (tmp_str) { g_string_append (str_buf, - tmp_str); + (gchar *)tmp_str); g_free (tmp_str); tmp_str = NULL; } @@ -406,8 +405,8 @@ cr_term_to_string (CRTerm * a_this) case TERM_URI: if (cur->content.str) { content = g_strndup - (cur->content.str->stryng->str, - cur->content.str->stryng->len); + (cur->content.str->stryng->str, + cur->content.str->stryng->len); } if (content) { @@ -426,7 +425,7 @@ cr_term_to_string (CRTerm * a_this) tmp_str = cr_rgb_to_string (cur->content.rgb); if (tmp_str) { - g_string_append (str_buf, tmp_str); + g_string_append (str_buf, (gchar *)tmp_str); g_free (tmp_str); tmp_str = NULL; } @@ -464,7 +463,7 @@ cr_term_to_string (CRTerm * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } @@ -476,8 +475,8 @@ guchar * cr_term_one_to_string (CRTerm * a_this) { GString *str_buf = NULL; - guchar *result = NULL, - *content = NULL; + guchar *result = NULL; + gchar *content = NULL; g_return_val_if_fail (a_this, NULL); @@ -525,7 +524,7 @@ cr_term_one_to_string (CRTerm * a_this) switch (a_this->type) { case TERM_NUMBER: if (a_this->content.num) { - content = cr_num_to_string (a_this->content.num); + content = (gchar *)cr_num_to_string (a_this->content.num); } if (content) { @@ -616,10 +615,9 @@ cr_term_one_to_string (CRTerm * a_this) case TERM_RGB: if (a_this->content.rgb) { - guchar *tmp_str = NULL; g_string_append_printf (str_buf, "rgb("); - tmp_str = cr_rgb_to_string (a_this->content.rgb); + gchar *tmp_str = (gchar *)cr_rgb_to_string (a_this->content.rgb); if (tmp_str) { g_string_append (str_buf, tmp_str); @@ -660,7 +658,7 @@ cr_term_one_to_string (CRTerm * a_this) } if (str_buf) { - result = str_buf->str; + result = (guchar *)str_buf->str; g_string_free (str_buf, FALSE); str_buf = NULL; } diff --git a/src/libcroco/cr-tknzr.c b/src/libcroco/cr-tknzr.c index b591770f8..4eb9db7a1 100644 --- a/src/libcroco/cr-tknzr.c +++ b/src/libcroco/cr-tknzr.c @@ -195,7 +195,7 @@ CHECK_PARSING_STATUS (status, TRUE) ; */ #define SKIP_CHARS(a_tknzr, a_nb_chars) \ { \ -glong nb_chars = a_nb_chars ; \ +gulong nb_chars = a_nb_chars ; \ status = cr_input_consume_chars \ (PRIVATE (a_tknzr)->input,0, &nb_chars) ; \ CHECK_PARSING_STATUS (status, TRUE) ; \ @@ -408,7 +408,7 @@ cr_tknzr_try_to_skip_spaces (CRTknzr * a_this) } if (cr_utils_is_white_space (cur_char) == TRUE) { - glong nb_chars = -1; /*consume all spaces */ + gulong nb_chars = -1; /*consume all spaces */ status = cr_input_consume_white_spaces (PRIVATE (a_this)->input, &nb_chars); @@ -1292,7 +1292,7 @@ cr_tknzr_parse_rgb (CRTknzr * a_this, CRRgb ** a_rgb) status = cr_tknzr_parse_num (a_this, &num); ENSURE_PARSING_COND ((status == CR_OK) && (num != NULL)); - red = num->val; + red = (glong)num->val; cr_num_destroy (num); num = NULL; @@ -1318,9 +1318,9 @@ cr_tknzr_parse_rgb (CRTknzr * a_this, CRRgb ** a_rgb) } if (i == 0) { - green = num->val; + green = (glong)num->val; } else if (i == 1) { - blue = num->val; + blue = (glong)num->val; } if (num) { @@ -1582,9 +1582,7 @@ cr_tknzr_parse_num (CRTknzr * a_this, CRTknzr * cr_tknzr_new (CRInput * a_input) { - CRTknzr *result = NULL; - - result = g_try_malloc (sizeof (CRTknzr)); + CRTknzr *result = (CRTknzr *)g_try_malloc (sizeof (CRTknzr)); if (result == NULL) { cr_utils_trace_info ("Out of memory"); @@ -1593,7 +1591,7 @@ cr_tknzr_new (CRInput * a_input) memset (result, 0, sizeof (CRTknzr)); - result->priv = g_try_malloc (sizeof (CRTknzrPriv)); + result->priv = (CRTknzrPriv *)g_try_malloc (sizeof (CRTknzrPriv)); if (result->priv == NULL) { cr_utils_trace_info ("Out of memory"); @@ -1634,9 +1632,7 @@ cr_tknzr_new_from_uri (const guchar * a_file_uri, enum CREncoding a_enc) { CRTknzr *result = NULL; - CRInput *input = NULL; - - input = cr_input_new_from_uri (a_file_uri, a_enc); + CRInput *input = cr_input_new_from_uri ((gchar *)a_file_uri, a_enc); g_return_val_if_fail (input != NULL, NULL); result = cr_tknzr_new (input); @@ -1909,7 +1905,7 @@ cr_tknzr_consume_chars (CRTknzr * a_this, guint32 a_char, glong * a_nb_char) } return cr_input_consume_chars (PRIVATE (a_this)->input, - a_char, a_nb_char); + a_char, (gulong *)a_nb_char); } enum CRStatus diff --git a/src/libcroco/cr-token.c b/src/libcroco/cr-token.c index d2bb492ef..af95751d0 100644 --- a/src/libcroco/cr-token.c +++ b/src/libcroco/cr-token.c @@ -132,9 +132,7 @@ cr_token_clear (CRToken * a_this) CRToken * cr_token_new (void) { - CRToken *result = NULL; - - result = g_try_malloc (sizeof (CRToken)); + CRToken *result = (CRToken *)g_try_malloc (sizeof (CRToken)); if (result == NULL) { cr_utils_trace_info ("Out of memory"); -- 2.30.2