Logo Search packages:      
Sourcecode: inkscape version File versions

enum CRStatus cr_parser_parse_charset ( CRParser a_this,
CRString **  a_value,
CRParsingLocation *  a_charset_sym_location 
)

Parses a charset declaration as defined implictly by the css2 spec in appendix D.1: charset ::= CHARSET_SYM S* STRING S* ';'

Parameters:
a_this the "this pointer" of the current instance of CRParser.
a_value out parameter. The actual parsed value of the charset declararation. Note that for safety check reasons, *a_value must be set to NULL.
a_charset_sym_location the parsing location of
Returns:
CR_OK upon successfull completion, an error code otherwise.

Definition at line 4033 of file cr-parser.c.

References cr_parser_try_to_skip_spaces_and_comments(), cr_parsing_location_copy(), cr_tknzr_get_next_token(), cr_token_destroy(), ENSURE_PARSING_COND, _CRToken::location, RECORD_INITIAL_POS, _CRToken::str, _CRToken::type, and _CRToken::u.

Referenced by cr_parser_parse_stylesheet(), and cr_statement_at_charset_rule_parse_from_buf().

{
        enum CRStatus status = CR_OK;
        CRInputPos init_pos;
        CRToken *token = NULL;
        CRString *charset_str = NULL;

        g_return_val_if_fail (a_this && a_value
                              && (*a_value == NULL), 
                              CR_BAD_PARAM_ERROR);

        RECORD_INITIAL_POS (a_this, &init_pos);

        status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, &token);

        ENSURE_PARSING_COND (status == CR_OK
                             && token && token->type == CHARSET_SYM_TK);
        if (a_charset_sym_location) {
                cr_parsing_location_copy (a_charset_sym_location, 
                                          &token->location) ;
        }
        cr_token_destroy (token);
        token = NULL;

        PRIVATE (a_this)->state = TRY_PARSE_CHARSET_STATE;

        cr_parser_try_to_skip_spaces_and_comments (a_this);

        status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, &token);
        ENSURE_PARSING_COND (status == CR_OK
                             && token && token->type == STRING_TK);
        charset_str = token->u.str;
        token->u.str = NULL;
        cr_token_destroy (token);
        token = NULL;

        cr_parser_try_to_skip_spaces_and_comments (a_this);

        status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, &token);

        ENSURE_PARSING_COND (status == CR_OK
                             && token && token->type == SEMICOLON_TK);
        cr_token_destroy (token);
        token = NULL;

        if (charset_str) {
                *a_value = charset_str;
                charset_str = NULL;
        }

        PRIVATE (a_this)->state = CHARSET_PARSED_STATE;
        return CR_OK;

 error:

        if (token) {
                cr_token_destroy (token);
                token = NULL;
        }

        if (*a_value) {
                cr_string_destroy (*a_value);
                *a_value = NULL;
        }

        if (charset_str) {
                cr_string_destroy (charset_str);
                charset_str = NULL;
        }

        cr_tknzr_set_cur_pos (PRIVATE (a_this)->tknzr, &init_pos);

        return status;
}


Generated by  Doxygen 1.6.0   Back to index