summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji <dodji@gnome.org>2004-03-15 22:56:28 +0000
committerDodji Seketeli <dodji@src.gnome.org>2004-03-15 22:56:28 +0000
commit722a570bd3d38db5376a81349001d9bbb15e3506 (patch)
treeedb7ee853f39934daa234b044cddf243fee44a45
parent934fa2ab35547bc858df7f769ef9a5362272580c (diff)
downloadlibcroco-722a570bd3d38db5376a81349001d9bbb15e3506.tar.gz
Merged with libcroco--mainline--0.1--patch-21
2004-03-15 Dodji <dodji@gnome.org> Merged with libcroco--mainline--0.1--patch-21
-rw-r--r--ChangeLog32
-rw-r--r--Makefile.am2
-rw-r--r--src/cr-fonts.h29
-rw-r--r--src/cr-parser.c5
-rw-r--r--src/cr-parser.h3
-rw-r--r--src/cr-rgb.c91
-rw-r--r--src/cr-rgb.h19
-rw-r--r--src/cr-style.c72
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/testctl30
-rwxr-xr-xtests/valgrind-version.sh48
11 files changed, 239 insertions, 94 deletions
diff --git a/ChangeLog b/ChangeLog
index 36c5834..1ffa73d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,32 @@
+2004-03-15 Dodji <dodji@gnome.org>
+
+ * tests/Makefile.am: added the tests/valgrind-version.sh file in
+ the distribution.
+
+ * tests/testctl: enforced the use of valgrind 2.1.1 or higher.
+ * tests/valgrind-version.sh: added this file to test the version of
+ the currently installed version of valgrind.
+
+2004-03-14 Dodji <dodji@gnome.org>
+
+ * src/cr-style.c:
+ (cr_style_set_props_to_defaults): added more default props
+ init.
+ * src/cr-fonts.h: modified some declarations here to
+ ease the support of the "font-weight: bolder" and
+ "font-weight: lighter" support in sewfox.
+
+ * src/cr-parser.[ch],src/cr-rgb.[ch],src/cr-style.c:
+ applied a patch from Benjamin Dauvergne to add
+ CRRgb::parse_from_buf() and CRRgb::set_from_term()
+ methods. Modified the patch to comply with libcroco
+ coding style and to kill a compiler warning.
+
2004-03-13 Dodji <dodji@gnome.org>
- * ====
- merge point of dodji@gnome.org--xml-style-2004/libcroco--snapshots--0.1--patch-1
- ===
+ * Makefile.am,tests/Makefile.am,tests/test-output-refs/Makefile.am:
+ Added some distribution plumbing.
+
* configure.in: bumped version number to 0.5 and bumped version-info.
* src/cr-sel-eng.c,src/cr-stylesheet.c,
@@ -103,8 +127,6 @@
* files.txt,dirs.txt: removed these files.
- ====starting from here, going upward, we use gnu arch ===
-
2004-03-07 Dodji Seketeli <dodji@gnome.org>
* src/cr-statement.c:
diff --git a/Makefile.am b/Makefile.am
index e06ba30..dffc8dc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ cleantar:
rpm: cleantar
@(mkdir -p $(top_srcdir)/rpmbuildroot ; $(MAKE) dist && rpmbuild -ta --buildroot $(top_srcdir)/rpmbuildroot $(distdir).tar.gz)
-test:
+test:
if test -x $(top_srcdir)/tests/testctl ; then $(top_srcdir)/tests/testctl cleanup ; $(top_srcdir)/tests/testctl ; $(top_srcdir)/tests/testctl run ; fi
apidoc:
diff --git a/src/cr-fonts.h b/src/cr-fonts.h
index 76effe7..29fdfe3 100644
--- a/src/cr-fonts.h
+++ b/src/cr-fonts.h
@@ -189,20 +189,21 @@ enum CRFontVariant
enum CRFontWeight
{
- FONT_WEIGHT_NORMAL=0,
- FONT_WEIGHT_BOLD,
- FONT_WEIGHT_BOLDER,
- FONT_WEIGHT_LIGHTER,
- FONT_WEIGHT_100,
- FONT_WEIGHT_200,
- FONT_WEIGHT_300,
- FONT_WEIGHT_400,
- FONT_WEIGHT_500,
- FONT_WEIGHT_600,
- FONT_WEIGHT_700,
- FONT_WEIGHT_800,
- FONT_WEIGHT_900,
- FONT_WEIGHT_INHERIT,
+ FONT_WEIGHT_NORMAL = 1,
+ FONT_WEIGHT_BOLD = 1<<1,
+ FONT_WEIGHT_BOLDER = 1<<2,
+ FONT_WEIGHT_LIGHTER = 1<<3,
+ FONT_WEIGHT_100 = 1<<4,
+ FONT_WEIGHT_200 = 1<<5,
+ FONT_WEIGHT_300 = 1<<6,
+ FONT_WEIGHT_400 = 1<<7,
+ FONT_WEIGHT_500 = 1<<8,
+ FONT_WEIGHT_600 = 1<<9,
+ FONT_WEIGHT_700 = 1<<10,
+ FONT_WEIGHT_800 = 1<<11,
+ FONT_WEIGHT_900 = 1<<12,
+ FONT_WEIGHT_INHERIT = 1<<13,
+ NB_FONT_WEIGHTS
} ;
enum CRFontStretch
diff --git a/src/cr-parser.c b/src/cr-parser.c
index b1e6f8d..f29de0e 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -358,9 +358,6 @@ static enum CRStatus cr_parser_parse_ident (CRParser * a_this,
static enum CRStatus cr_parser_parse_uri (CRParser * a_this,
GString ** a_str);
-static enum CRStatus cr_parser_parse_term (CRParser * a_this,
- CRTerm ** a_term);
-
static enum CRStatus cr_parser_parse_function (CRParser * a_this,
GString ** a_func_name,
CRTerm ** a_expr);
@@ -1777,7 +1774,7 @@ cr_parser_parse_property (CRParser * a_this, GString ** a_property)
*@param a_term out parameter. The successfully parsed term.
*@return CR_OK upon successfull completion, an error code otherwise.
*/
-static enum CRStatus
+enum CRStatus
cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term)
{
enum CRStatus status = CR_PARSING_ERROR;
diff --git a/src/cr-parser.h b/src/cr-parser.h
index 69c7bcc..f67b682 100644
--- a/src/cr-parser.h
+++ b/src/cr-parser.h
@@ -110,6 +110,9 @@ enum CRStatus
cr_parser_set_default_sac_handler (CRParser *a_this) ;
enum CRStatus
+cr_parser_parse_term (CRParser *a_this, CRTerm **a_term) ;
+
+enum CRStatus
cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr) ;
enum CRStatus
diff --git a/src/cr-rgb.c b/src/cr-rgb.c
index 7ceea11..c125675 100644
--- a/src/cr-rgb.c
+++ b/src/cr-rgb.c
@@ -24,6 +24,8 @@
#include <stdio.h>
#include <string.h>
#include "cr-rgb.h"
+#include "cr-term.h"
+#include "cr-parser.h"
static CRRgb gv_standard_colors[] = {
{"aliceblue", 240, 248, 255, 0},
@@ -434,6 +436,42 @@ cr_rgb_set_from_hex_str (CRRgb * a_this, const guchar * a_hex)
}
/**
+ *Set the rgb from a terminal symbol
+ *@param a_this the instance of #CRRgb to set
+ *@param a_value the terminal from which to set
+ */
+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,
+ CR_BAD_PARAM_ERROR) ;
+
+ switch(a_value->type) {
+ case TERM_RGB:
+ if (a_value->content.rgb) {
+ cr_rgb_set_from_rgb
+ (a_this, a_value->content.rgb) ;
+ }
+ break ;
+ case TERM_IDENT:
+ status = cr_rgb_set_from_name
+ (a_this,
+ a_value->content.str->str) ;
+ break ;
+ case TERM_HASH:
+ status = cr_rgb_set_from_hex_str
+ (a_this,
+ a_value->content.str->str) ;
+ break ;
+ default:
+ status = CR_UNKNOWN_TYPE_ERROR ;
+ }
+
+ return status ;
+}
+
+/**
*Destructor of #CRRgb.
*@param a_this the "this pointer" of the
*current instance of #CRRgb.
@@ -445,3 +483,56 @@ cr_rgb_destroy (CRRgb * a_this)
g_free (a_this);
}
+
+/**
+ *Parses a text buffer that contains a rgb color
+ *
+ *@param a_str a string that contains a color description
+ *@param a_enc the encoding of a_str
+ *@return the parsed color, or NULL in case of error
+ */
+CRRgb *cr_rgb_parse_from_buf (const guchar *a_str,
+ enum CREncoding a_enc)
+{
+ enum CRStatus status = CR_OK ;
+ CRTerm *value = NULL ;
+ CRParser * parser = NULL;
+ CRRgb *result = NULL;
+
+ g_return_val_if_fail (a_str, NULL);
+
+ parser = cr_parser_new_from_buf ((guchar*)a_str, strlen (a_str),
+ a_enc, FALSE) ;
+
+ g_return_val_if_fail (parser, NULL);
+
+ status = cr_parser_try_to_skip_spaces_and_comments (parser) ;
+ if (status != CR_OK)
+ goto cleanup;
+
+ status = cr_parser_parse_term (parser, &value);
+ if (status != CR_OK)
+ goto cleanup;
+
+ result = cr_rgb_new ();
+ if (!result)
+ goto cleanup;
+
+ status = cr_rgb_set_from_term (result, value);
+
+cleanup:
+ if (parser) {
+ cr_parser_destroy (parser);
+ parser = NULL;
+ }
+ if (value) {
+ cr_term_destroy(value);
+ value = NULL;
+ }
+ return result ;
+}
+
+
+
+
+
diff --git a/src/cr-rgb.h b/src/cr-rgb.h
index 9a11e6c..2918a4c 100644
--- a/src/cr-rgb.h
+++ b/src/cr-rgb.h
@@ -3,8 +3,6 @@
/*
* This file is part of The Croco Library
*
- * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the GNU Lesser General Public
* License as published by the Free Software Foundation.
@@ -18,19 +16,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
+ *
+ * see COPYRIGHTS file for copyright information.
*/
-/*
- *$Id$
- */
+#ifndef __CR_RGB_H__
+#define __CR_RGB_H__
#include <stdio.h>
#include <glib.h>
#include "cr-utils.h"
-#ifndef __CR_RGB_H__
-#define __CR_RGB_H__
-
G_BEGIN_DECLS
@@ -54,6 +50,9 @@ CRRgb * cr_rgb_new (void) ;
CRRgb * cr_rgb_new_with_vals (gulong a_red, gulong a_green,
gulong a_blue, gboolean a_is_percentage) ;
+CRRgb *cr_rgb_parse_from_buf(const guchar *a_str,
+ enum CREncoding a_enc);
+
enum CRStatus cr_rgb_compute_from_percentage (CRRgb *a_this) ;
enum CRStatus cr_rgb_set (CRRgb *a_this, gulong a_red,
@@ -66,6 +65,10 @@ enum CRStatus cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name) ;
enum CRStatus cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex_value) ;
+struct _CRTerm;
+
+enum CRStatus cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value);
+
guchar * cr_rgb_to_string (CRRgb *a_this) ;
void cr_rgb_dump (CRRgb *a_this, FILE *a_fp) ;
diff --git a/src/cr-style.c b/src/cr-style.c
index 20859d7..04557eb 100644
--- a/src/cr-style.c
+++ b/src/cr-style.c
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
- *see COPYRIGTHS file for information
+ * see COPYRIGTHS file for copyright information
*/
/*
@@ -998,73 +998,30 @@ set_prop_width (CRStyle * a_style, CRTerm * a_value)
return CR_OK;
}
-static enum CRStatus
+static enum CRStatus
set_prop_color (CRStyle * a_style, CRTerm * a_value)
{
- enum CRStatus status = CR_OK;
+ enum CRStatus status = CR_OK;
+ CRRgb *a_rgb = &a_style->rgb_props[RGB_PROP_COLOR].sv;
- g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
+ g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
- switch (a_value->type) {
- case TERM_RGB:
- if (a_value->content.rgb) {
- cr_rgb_set_from_rgb
- (&a_style->rgb_props[RGB_PROP_COLOR].sv,
- a_value->content.rgb);
- }
- break;
- case TERM_IDENT:
- status = cr_rgb_set_from_name
- (&a_style->rgb_props[RGB_PROP_COLOR].sv,
- a_value->content.str->str);
- break;
- case TERM_HASH:
- status = cr_rgb_set_from_hex_str
- (&a_style->rgb_props[RGB_PROP_COLOR].sv,
- a_value->content.str->str);
- break;
- default:
- status = CR_UNKNOWN_TYPE_ERROR;
- }
+ status = cr_rgb_set_from_term (a_rgb, a_value);
- return status;
+ return status;
}
static enum CRStatus
set_prop_background_color (CRStyle * a_style, CRTerm * a_value)
{
- enum CRStatus status = CR_OK;
+ enum CRStatus status = CR_OK;
+ CRRgb *a_rgb = &a_style->rgb_props[RGB_PROP_BACKGROUND_COLOR].sv;
- g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
+ g_return_val_if_fail (a_style && a_value, CR_BAD_PARAM_ERROR);
- switch (a_value->type) {
- case TERM_RGB:
- if (a_value->content.rgb) {
- status = cr_rgb_set_from_rgb
- (&a_style->
- rgb_props[RGB_PROP_BACKGROUND_COLOR].sv,
- a_value->content.rgb);
- }
- break;
-
- case TERM_IDENT:
- status = cr_rgb_set_from_name
- (&a_style->rgb_props[RGB_PROP_BACKGROUND_COLOR].sv,
- a_value->content.str->str);
- break;
-
- case TERM_HASH:
- status = cr_rgb_set_from_hex_str
- (&a_style->rgb_props[RGB_PROP_BACKGROUND_COLOR].sv,
- a_value->content.str->str);
- break;
-
- default:
- status = CR_UNKNOWN_TYPE_ERROR;
- break;
- }
+ status = cr_rgb_set_from_term (a_rgb, a_value);
- return status;
+ return status;
}
/**
@@ -1715,7 +1672,10 @@ cr_style_set_props_to_defaults (CRStyle * a_this)
a_this->position = POSITION_STATIC;
a_this->float_type = FLOAT_NONE;
a_this->parent_style = NULL;
-
+ a_this->font_style = FONT_STYLE_NORMAL;
+ a_this->font_variant = FONT_VARIANT_NORMAL;
+ a_this->font_weight = FONT_WEIGHT_NORMAL;
+ a_this->font_stretch = FONT_STRETCH_NORMAL;
return CR_OK;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3f5ecfe..aecadba 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS=test-inputs test-output-refs
-EXTRA_DIST=testctl vg.supp global-vars.sh\
+EXTRA_DIST=testctl vg.supp global-vars.sh valgrind-version.sh \
test-prop-ident.sh \
test-unknown-at-rule.sh \
test-unknown-at-rule2.sh
diff --git a/tests/testctl b/tests/testctl
index 18ec9ed..88dba5e 100755
--- a/tests/testctl
+++ b/tests/testctl
@@ -12,6 +12,7 @@
#the directory that contains the tests
HERE=`dirname $0`
+
#the list of tests to be run
TEST_PROG_LIST=
@@ -32,6 +33,10 @@ if test x$RUN_VALGRIND = x ; then
else
RUN_VALGRIND=yes
fi
+if test "x$CHECKER" = "x" ; then
+ CHECKER="valgrind --tool=memcheck"
+fi
+
VALGRIND_LOGS_DIR=valgrind-logs
VALGRIND=
TEST_PROG=
@@ -137,12 +142,27 @@ run_test_prog ()
if test x$RUN_VALGRIND = xno ; then
VALGRIND=
else
- VALGRIND=`which valgrind`
- if test x$VALGRIND = x ; then
- echo "Could not find valgrind in your path"
+ if ! test -x $HERE/valgrind-version.sh ; then
+ echo "Argh! Could not find file $HERE/valgrind-version.sh"
+ exit -1 ;
+ fi
+ version=`$HERE/valgrind-version.sh`
+ if ! test "x$version" = "xokay" ; then
+ echo "You must install a valgrind versin greater than 2.1.1"
+ echo "version=$version"
+ exit -1
+ fi
+ if test "x$CHECKER" = "x" ; then
+ VALGRIND=`which valgrind`
+ if test "x$VALGRIND" = x ; then
+ echo "Could not find valgrind in your path"
+ else
+ VALGRIND="$VALGRIND $VALGRIND_OPTIONS"
+ echo "Gonna run the tests with valgrind, using the following options: $VALGRIND_OPTIONS"
+ fi
else
- VALGRIND="$VALGRIND $VALGRIND_OPTIONS"
- echo "Gonna run the tests with valgrind, using the following options: $VALGRIND_OPTIONS"
+ VALGRIND="$CHECKER $VALGRIND_OPTIONS"
+ echo "Gonna run the tests with valgrind, using the cmd line: $VALGRIND"
fi
fi
export VALGRIND
diff --git a/tests/valgrind-version.sh b/tests/valgrind-version.sh
new file mode 100755
index 0000000..fbfd326
--- /dev/null
+++ b/tests/valgrind-version.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+valgrind=`which valgrind`
+awk=`which awk`
+if test "x$valgrind" = "x" ; then
+ echo "valgrind-not-present" ;
+ exit ;
+fi
+
+
+valgrind_version=`$valgrind --version`
+if test "x$valgrind_version" = x ; then
+ echo "not-present" ;
+ exit
+fi
+
+if test "x$awk" = x ; then
+ echo "awk-not-present"
+ exit
+fi
+
+string_version=`echo $valgrind_version | $awk -F '-' '{print $2}'`
+
+if test "x$string_version" = "x" ; then
+ echo "valgrind-version-unknown"
+ exit
+fi
+
+major=`echo $string_version | $awk -F '.' '{print $1}'`
+minor=`echo $string_version | $awk -F '.' '{print $2}'`
+micro=`echo $string_version | $awk -F '.' '{print $3}'`
+
+version=`expr $major \* 10000 + $minor \* 100 + $micro`
+
+if test "x$version" = "x" ; then
+ echo "valgrind-version-unknown"
+ exit ;
+fi
+
+if test "$version" -ge "20101" ; then
+ echo "okay"
+ exit ;
+else
+ echo "valgrind-version-lower"
+ exit ;
+fi
+
+