From 5a48402e8427400ee5d3f2ec1f526a189d6c48d4 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Sat, 29 May 2004 23:18:45 +0000 Subject: Synched with libcroco--mainline--patch-34 . 2004-05-29 Dodji Seketeli Synched with libcroco--mainline--patch-34 . --- ChangeLog | 23 +++++++++++ src/cr-parser.c | 45 +++++++++++++--------- src/cr-stylesheet.c | 2 +- src/cr-term.c | 19 +++++---- src/cr-tknzr.c | 6 ++- tests/test-functional-notation.sh | 6 +++ tests/test-inputs/functional-notation.css | 2 + .../test-output-refs/test-functional-notation.out | 7 ++++ tests/test4-main.c | 9 ++--- 9 files changed, 81 insertions(+), 38 deletions(-) create mode 100755 tests/test-functional-notation.sh create mode 100644 tests/test-inputs/functional-notation.css create mode 100644 tests/test-output-refs/test-functional-notation.out diff --git a/ChangeLog b/ChangeLog index c462ab7..34e6623 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2004-05-29 Dodji Seketeli + + * tests/test-functional-notation.sh,tests/test-inputs/functional-notation.css, + tests/test-output-refs/test-functional-notation.out: + Added regression tests for #143308 + + * src/cr-parser.c: + (cr_parser_parse_term): better handling unary operator. + * src/cr-stylesheet.c : + (cr_stylesheet_dump): fprintf (fd, str) ; doesn't behave + correctly when str contains a '%' char. Do fprintf (fd, "%", str) + instead ; + * src/cr-term.c: + (cr_term_to_string): use g_string_append() instead of + g_string_append_printf() when possible. + Don't forget to close function parenthesis even when argument + list is NULL. + * src/cr-tknzr.c: + (cr_tknzr_parse_ident): + Properly roll back the input stream when an error occurs. + This ChangeLog entry fixes + http://bugzilla.gnome.org/show_bug.cgi?id=143308. + 2004-04-18 Dodji Seketeli ================== 0.5.1 release ======================== diff --git a/src/cr-parser.c b/src/cr-parser.c index 73f6a40..f7f78fa 100644 --- a/src/cr-parser.c +++ b/src/cr-parser.c @@ -1797,16 +1797,32 @@ cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term) if (token->type == DELIM_TK && token->u.unichar == '+') { result->unary_op = PLUS_UOP; + 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); + if (status != CR_OK || !token) + goto error; } else if (token->type == DELIM_TK && token->u.unichar == '-') { result->unary_op = MINUS_UOP; - } else if (token->type == EMS_TK - || token->type == EXS_TK - || token->type == LENGTH_TK - || token->type == ANGLE_TK - || token->type == TIME_TK - || token->type == FREQ_TK - || token->type == PERCENTAGE_TK - || token->type == NUMBER_TK) { + 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); + if (status != CR_OK || !token) + goto error; + } + + if (token->type == EMS_TK + || token->type == EXS_TK + || token->type == LENGTH_TK + || token->type == ANGLE_TK + || token->type == TIME_TK + || token->type == FREQ_TK + || token->type == PERCENTAGE_TK + || token->type == NUMBER_TK) { status = cr_term_set_number (result, token->u.num); CHECK_PARSING_STATUS (status, TRUE); token->u.num = NULL; @@ -1868,7 +1884,7 @@ cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term) cr_parser_clear_errors (a_this); return CR_OK; - error: + error: if (result) { cr_term_destroy (result); @@ -2353,16 +2369,7 @@ cr_parser_parse_function (CRParser * a_this, cr_token_destroy (token); token = NULL; - status = cr_tknzr_get_next_token (PRIVATE (a_this)->tknzr, &token); - if (status != CR_OK) - goto error; - - ENSURE_PARSING_COND (token && token->type == PO_TK); - - cr_token_destroy (token); - token = NULL; - - status = cr_parser_parse_term (a_this, &expr); + status = cr_parser_parse_expr (a_this, &expr); CHECK_PARSING_STATUS (status, FALSE); diff --git a/src/cr-stylesheet.c b/src/cr-stylesheet.c index 97ae79e..cc950ce 100644 --- a/src/cr-stylesheet.c +++ b/src/cr-stylesheet.c @@ -107,7 +107,7 @@ cr_stylesheet_dump (CRStyleSheet * a_this, FILE * a_fp) str = cr_stylesheet_to_string (a_this) ; if (str) { - fprintf (a_fp, str) ; + fprintf (a_fp, "%s", str) ; g_free (str) ; str = NULL ; } diff --git a/src/cr-term.c b/src/cr-term.c index 9828a3d..e8b893f 100644 --- a/src/cr-term.c +++ b/src/cr-term.c @@ -299,16 +299,16 @@ cr_term_to_string (CRTerm * a_this) switch (cur->the_operator) { case DIVIDE: - g_string_append_printf (str_buf, " / "); + g_string_append (str_buf, " / "); break; case COMMA: - g_string_append_printf (str_buf, ", "); + g_string_append (str_buf, ", "); break; case NO_OP: if (cur->prev) { - g_string_append_printf (str_buf, " "); + g_string_append (str_buf, " "); } break; default: @@ -318,11 +318,11 @@ cr_term_to_string (CRTerm * a_this) switch (cur->unary_op) { case PLUS_UOP: - g_string_append_printf (str_buf, "+"); + g_string_append (str_buf, "+"); break; case MINUS_UOP: - g_string_append_printf (str_buf, "-"); + g_string_append (str_buf, "-"); break; default: @@ -354,11 +354,11 @@ cr_term_to_string (CRTerm * a_this) g_string_append_printf (str_buf, "%s(", content); - if (a_this->ext_content.func_param) { + if (cur->ext_content.func_param) { guchar *tmp_str = NULL; tmp_str = cr_term_to_string - (a_this-> + (cur-> ext_content.func_param); if (tmp_str) { @@ -367,12 +367,11 @@ cr_term_to_string (CRTerm * a_this) "%s", tmp_str); g_free (tmp_str); tmp_str = NULL; - } - - g_string_append_printf (str_buf, ")"); + } g_free (content); content = NULL; } + g_string_append_printf (str_buf, ")"); } break; diff --git a/src/cr-tknzr.c b/src/cr-tknzr.c index 11f85ad..5681b70 100644 --- a/src/cr-tknzr.c +++ b/src/cr-tknzr.c @@ -879,8 +879,7 @@ cr_tknzr_parse_nmchar (CRTknzr * a_this, guint32 * a_char) return CR_OK; - error: - + error: cr_tknzr_set_cur_pos (a_this, &init_pos); return status; @@ -954,6 +953,9 @@ cr_tknzr_parse_ident (CRTknzr * a_this, GString ** a_str) g_string_free (stringue, TRUE) ; stringue = NULL ; } + if (status != CR_OK ) { + cr_tknzr_set_cur_pos (a_this, &init_pos) ; + } return status ; } diff --git a/tests/test-functional-notation.sh b/tests/test-functional-notation.sh new file mode 100755 index 0000000..5d23685 --- /dev/null +++ b/tests/test-functional-notation.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +HERE_DIR=`dirname $0` +. $HERE_DIR/global-vars.sh + +$CSSLINT $TEST_INPUTS_DIR/functional-notation.css diff --git a/tests/test-inputs/functional-notation.css b/tests/test-inputs/functional-notation.css new file mode 100644 index 0000000..cd80f18 --- /dev/null +++ b/tests/test-inputs/functional-notation.css @@ -0,0 +1,2 @@ +foo { bar: attr(width, length, calc(70% - 5px)) } +foo {bar: attr(x,y) } diff --git a/tests/test-output-refs/test-functional-notation.out b/tests/test-output-refs/test-functional-notation.out new file mode 100644 index 0000000..7fa05fd --- /dev/null +++ b/tests/test-output-refs/test-functional-notation.out @@ -0,0 +1,7 @@ +foo { + bar : attr(width, length, calc(70% -5px)) +} + +foo { + bar : attr(x, y) +} diff --git a/tests/test4-main.c b/tests/test4-main.c index 78501dc..6d99585 100644 --- a/tests/test4-main.c +++ b/tests/test4-main.c @@ -56,14 +56,11 @@ const guchar *gv_at_font_face_buf = const guchar *gv_at_import_buf = "@import \"subs.css\";"; -static void - display_help (char *prg_name); +static void display_help (char *prg_name); -static void - display_about (char *prg_name); +static void display_about (char *prg_name); -static enum CRStatus - test_cr_parser_parse (guchar * a_file_uri); +static enum CRStatus test_cr_parser_parse (guchar * a_file_uri); /** *Displays the usage of the test -- cgit v1.2.1