From 67ae4b95a62651c71d1ea250308e6479aca048f7 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Fri, 5 Mar 2004 23:41:29 +0000 Subject: applied a patch from Rob BUIS to fix some bugs/memleaks here. Did some 2004-03-06 Dodji Seketeli * csslint/csslint.c: applied a patch from Rob BUIS to fix some bugs/memleaks here. Did some cleanups too. * src/cr-sel-eng.c: (cr_sel_eng_get_matched_rulesets_real): handle the case where the sheet is empty (has no rules). That can happen ! (it actually happened to me during some tests). (put_css_properties_in_props_list): handle the !important keyword in the cascading algorithm. Rob BUIS (again) started this. --- csslint/csslint.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'csslint') diff --git a/csslint/csslint.c b/csslint/csslint.c index 2ac1745..914cf47 100644 --- a/csslint/csslint.c +++ b/csslint/csslint.c @@ -101,21 +101,15 @@ parse_cmd_line (int a_argc, char **a_argv, else if ( !strcmp (a_argv[i], "--evaluate") || !strcmp (a_argv[i], "-e")) { - gchar *xml_doc_path = NULL, - *author_sheet_path = NULL, - *user_sheet_path = NULL, - *ua_sheet_path = NULL ; - for (i++ ; i < a_argc ; i++) { if (!strcmp (a_argv[i], "--author-sheet")) { - if (author_sheet_path) + if (a_options->author_sheet_path) { display_usage () ; exit (-1); } - author_sheet_path = a_argv[i] ; i++ ; if (i >= a_argc || a_argv[i][0] == '-') { @@ -127,12 +121,11 @@ parse_cmd_line (int a_argc, char **a_argv, } else if (!strcmp (a_argv[i], "--user-sheet")) { - if (user_sheet_path) + if (a_options->user_sheet_path) { display_usage () ; exit (-1); } - user_sheet_path = a_argv[i] ; i++ ; if (i >= a_argc || a_argv[i][0] == '-') { @@ -144,12 +137,12 @@ parse_cmd_line (int a_argc, char **a_argv, } else if (!strcmp (a_argv[i], "--ua-sheet")) { - if (ua_sheet_path) + if (a_options->ua_sheet_path) { display_usage () ; exit (-1); } - ua_sheet_path = a_argv[i] ; + i++ ; if (i >= a_argc || a_argv[i][0] == '-') { g_print ("--ua-sheet should be followed by a path to the sheet\n") ; @@ -185,7 +178,9 @@ parse_cmd_line (int a_argc, char **a_argv, break ; } } - if (!author_sheet_path && !user_sheet_path && !ua_sheet_path) + if (!a_options->author_sheet_path + && !a_options->user_sheet_path && + !a_options->ua_sheet_path) { g_print ("Error: you must specify at least one stylesheet\n") ; display_usage () ; @@ -248,7 +243,7 @@ display_usage (void) { g_print ("Usage: csslint \n"); g_print ("\t| csslint -v|--version\n") ; - g_print ("\t| csslint <--evaluate | -e> [--author-sheet --user-sheet --ua-sheet \n] --xml --xpath ") ; + g_print ("\t| csslint <--evaluate | -e> [--author-sheet --user-sheet --ua-sheet \n] --xml --xpath \n") ; } /** @@ -428,6 +423,26 @@ evaluate_selectors (gchar *a_xml_path, cascade) ; } } + + if (xpath_context) + { + xmlXPathFreeContext (xpath_context); + xpath_context = NULL ; + } + if (xpath_context) + { + xmlXPathFreeObject (xpath_object); + xpath_object = NULL ; + } + if (sel_eng) + { + cr_sel_eng_destroy (sel_eng); + sel_eng = NULL ; + } + if (cascade) + { + cr_cascade_destroy (cascade) ; + } return CR_OK ; } -- cgit v1.2.1