summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2017-02-22 11:34:15 +0000
committertavmjong-free <tavmjong@free.fr>2017-02-22 11:34:15 +0000
commitdd2c89e3d5892bd01981044a4aa2be74bce2d86f (patch)
tree8d55832e8419d39b2a8ad74448592672712f56b9 /src
parentImprovements to fill between strokes and fill between many LPE's (diff)
downloadinkscape-dd2c89e3d5892bd01981044a4aa2be74bce2d86f.tar.gz
inkscape-dd2c89e3d5892bd01981044a4aa2be74bce2d86f.zip
Finish partially completed "cr_selector_parse_from_buf" and make it publicly accessible.
(bzr r15538)
Diffstat (limited to 'src')
-rw-r--r--src/libcroco/cr-parser.c2
-rw-r--r--src/libcroco/cr-parser.h2
-rw-r--r--src/libcroco/cr-selector.c25
3 files changed, 27 insertions, 2 deletions
diff --git a/src/libcroco/cr-parser.c b/src/libcroco/cr-parser.c
index 544b35ab0..4e50b5402 100644
--- a/src/libcroco/cr-parser.c
+++ b/src/libcroco/cr-parser.c
@@ -2002,7 +2002,7 @@ cr_parser_parse_simple_sels (CRParser * a_this,
*Returns CR_OK upon successful completion, an error
*code otherwise.
*/
-static enum CRStatus
+enum CRStatus
cr_parser_parse_selector (CRParser * a_this,
CRSelector ** a_selector)
{
diff --git a/src/libcroco/cr-parser.h b/src/libcroco/cr-parser.h
index 6dce9439e..24cf5dfe8 100644
--- a/src/libcroco/cr-parser.h
+++ b/src/libcroco/cr-parser.h
@@ -97,6 +97,8 @@ 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_selector (CRParser * a_this, CRSelector ** a_selector) ;
+
enum CRStatus cr_parser_parse_expr (CRParser *a_this, CRTerm **a_expr) ;
enum CRStatus cr_parser_parse_prio (CRParser *a_this, CRString **a_prio) ;
diff --git a/src/libcroco/cr-selector.c b/src/libcroco/cr-selector.c
index c56c43fda..f9193feda 100644
--- a/src/libcroco/cr-selector.c
+++ b/src/libcroco/cr-selector.c
@@ -51,6 +51,19 @@ cr_selector_new (CRSimpleSel * a_simple_sel)
return result;
}
+/**
+ * cr_selector_parse_from_buf:
+ *
+ *@a_char_buf: the buffer to parse.
+ *@a_enc: the encoding of the input buffer a_char_buf.
+ *
+ *Parses a buf for selectors.
+ *
+ *Fix Me: parsing will fail for some cases if buf does not end with '{'.
+ *
+ *Returns the newly built instance of #CRSelector, or
+ *NULL in case of failure.
+ */
CRSelector *
cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc)
{
@@ -62,7 +75,17 @@ cr_selector_parse_from_buf (const guchar * a_char_buf, enum CREncoding a_enc)
a_enc, FALSE);
g_return_val_if_fail (parser, NULL);
- return NULL;
+ CRSelector *selector = NULL;
+ enum CRStatus status = CR_OK;
+ status = cr_parser_parse_selector (parser, &selector);
+
+ if (status != CR_OK) {
+ if (selector) {
+ cr_selector_unref (selector);
+ selector = NULL;
+ }
+ }
+ return selector;
}
/**