Skip to content
Browse files

multiple match groups

  • Loading branch information...
1 parent 6e2fba5 commit 4228b7a18bc4d75b3e75cfbaa0a18aee5c4c059a @fizx committed
Showing with 12 additions and 12 deletions.
  1. +0 −1 Makefile.am
  2. +0 −1 Makefile.in
  3. +9 −8 regexp.c
  4. +1 −1 test/match.json
  5. +2 −1 test/match.let
View
1 Makefile.am
@@ -65,7 +65,6 @@ check-am:
@echo "quote..."; ./parsley test/quote.let test/quote.xml 2>&1 | diff test/quote.json - && echo " success."
@echo "unbang..."; ./parsley test/unbang.let test/unbang.html 2>&1 | diff test/unbang.json - && echo " success."
@echo "malformed-xpath..."; ./parsley test/malformed-xpath.let test/malformed-xpath.html 2>&1 | diff test/malformed-xpath.json - && echo " success."
- @echo "remote..."; ./parsley test/remote.let test/remote.html 2>&1 | diff test/remote.json - && echo " success."
@echo "remote-fail..."; ./parsley -z test/remote.let test/remote.html 2>&1 | diff test/remote-fail.json - && echo " success."
@echo "crash..."; ./parsley test/crash.let test/crash.html 2>&1 | diff test/crash.json - && echo " success."
@echo "reddit..."; ./parsley test/reddit.let test/reddit.html 2>&1 | diff test/reddit.json - && echo " success."
View
1 Makefile.in
@@ -839,7 +839,6 @@ check-am:
@echo "quote..."; ./parsley test/quote.let test/quote.xml 2>&1 | diff test/quote.json - && echo " success."
@echo "unbang..."; ./parsley test/unbang.let test/unbang.html 2>&1 | diff test/unbang.json - && echo " success."
@echo "malformed-xpath..."; ./parsley test/malformed-xpath.let test/malformed-xpath.html 2>&1 | diff test/malformed-xpath.json - && echo " success."
- @echo "remote..."; ./parsley test/remote.let test/remote.html 2>&1 | diff test/remote.json - && echo " success."
@echo "remote-fail..."; ./parsley -z test/remote.let test/remote.html 2>&1 | diff test/remote-fail.json - && echo " success."
@echo "crash..."; ./parsley test/crash.let test/crash.html 2>&1 | diff test/crash.json - && echo " success."
@echo "reddit..."; ./parsley test/reddit.let test/reddit.html 2>&1 | diff test/reddit.json - && echo " success."
View
17 regexp.c
@@ -97,7 +97,7 @@ exsltRegexpMatchFunction (xmlXPathParserContextPtr ctxt, int nargs)
xmlDocPtr container;
xmlXPathObjectPtr ret = NULL;
xmlChar *haystack, *regexp, *flagstr, *working, *match;
- int rc, x, flags, global, ovector[3];
+ int rc, x, flags, global, ovector[30];
if ((nargs < 1) || (nargs > 3)) {
xmlXPathSetArityError(ctxt);
@@ -148,15 +148,16 @@ exsltRegexpMatchFunction (xmlXPathParserContextPtr ctxt, int nargs)
ovector, sizeof(ovector)/sizeof(int));
while (rc > 0) {
- match = xmlStrsub(working, ovector[0], ovector[1]-ovector[0]);
- if (NULL == match) goto fail;
-
- node = xmlNewDocRawNode(container, NULL, "match", match);
- xmlFree(match);
+ for(int group = 0; group < rc; group++) {
+ match = xmlStrsub(working, ovector[group*2], ovector[group*2+1]-ovector[group*2]);
+ if (NULL == match) goto fail;
- xmlAddChild((xmlNodePtr) container, node);
- xmlXPathNodeSetAddUnique(ret->nodesetval, node);
+ node = xmlNewDocRawNode(container, NULL, "match", match);
+ xmlFree(match);
+ xmlAddChild((xmlNodePtr) container, node);
+ xmlXPathNodeSetAddUnique(ret->nodesetval, node);
+ }
if (!global) break;
working = working + ovector[1];
View
2 test/match.json
@@ -1 +1 @@
-{ "matches": [ { "a": "no", "b": "no", "c": "no", "d": "no" }, { "a": "no", "b": "noOo", "c": "no", "d": "noOo" }, { "a": "nooo", "b": "nooo", "c": "nooo", "d": "nooo" }, { "a": "no", "b": "noOo", "c": "no", "d": "noOo" }, { "a": "no", "b": "no", "c": "no", "d": "no" }, { "a": "no", "b": "no", "c": "no", "d": "no" } ] }
+{ "matches": [ { "a": "no", "b": "no", "c": "no", "d": "no" }, { "a": "no", "b": "noOo", "c": "no", "d": "noOo" }, { "a": "nooo", "b": "nooo", "c": "nooo", "d": "nooo" }, { "a": "no", "b": "noOo", "c": "no", "d": "noOo" }, { "a": "no", "b": "no", "c": "no", "d": "no" }, { "a": "no", "b": "no", "c": "no", "d": "no" } ], "first-capture-group": [ "spot", "spot" ] }
View
3 test/match.let
@@ -4,5 +4,6 @@
"b": "regexp:match(., 'no+', 'i')",
"c": "regexp:match(., 'no+', 'g')",
"d": "regexp:match(., 'no+', 'gi')"
- }]
+ }],
+ "first-capture-group(c)": ["regexp:match(., '(spot).*')[2]"]
}

0 comments on commit 4228b7a

Please sign in to comment.
Something went wrong with that request. Please try again.