OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall
Root: /v/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-src Date: 14-Jun-2008 22:46:19
Branch: HEAD Handle: 2008061421461800
Modified files:
openpkg-src/libxslt libxslt.patch libxslt.spec
Log:
add optional EXSLT RegExp and Crypto support
Summary:
Revision Changes Path
1.8 +418 -3 openpkg-src/libxslt/libxslt.patch
1.101 +28 -5 openpkg-src/libxslt/libxslt.spec
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/libxslt/libxslt.patch
============================================================================
$ cvs diff -u -r1.7 -r1.8 libxslt.patch
--- openpkg-src/libxslt/libxslt.patch 14 Jun 2008 20:18:24 -0000 1.7
+++ openpkg-src/libxslt/libxslt.patch 14 Jun 2008 20:46:18 -0000 1.8
@@ -1,6 +1,6 @@
Index: libexslt/date.c
--- libexslt/date.c.orig 2008-04-08 19:18:06 +0200
-+++ libexslt/date.c 2008-06-14 22:05:17 +0200
++++ libexslt/date.c 2008-06-14 22:39:04 +0200
@@ -28,7 +28,7 @@
#include "config.h"
#endif
@@ -10,9 +10,424 @@
#ifndef _AIX51 /* but on AIX we're not using gnu libc */
#define _POSIX_SOURCE
#endif
+Index: libexslt/exslt.c
+--- libexslt/exslt.c.orig 2007-01-03 16:11:57 +0100
++++ libexslt/exslt.c 2008-06-14 22:39:04 +0200
+@@ -35,5 +35,8 @@
+ exsltDateRegister();
+ exsltSaxonRegister();
+ exsltDynRegister();
++#ifdef EXSLT_REGEXP_ENABLED
++ exsltRegexpRegister();
++#endif
+ }
+
+Index: libexslt/exslt.h
+--- libexslt/exslt.h.orig 2007-01-03 16:11:57 +0100
++++ libexslt/exslt.h 2008-06-14 22:39:04 +0200
+@@ -82,6 +82,7 @@
+ EXSLTPUBFUN void EXSLTCALL exsltDateRegister (void);
+ EXSLTPUBFUN void EXSLTCALL exsltSaxonRegister (void);
+ EXSLTPUBFUN void EXSLTCALL exsltDynRegister(void);
++EXSLTPUBFUN void EXSLTCALL exsltRegexpRegister(void);
+
+ EXSLTPUBFUN void EXSLTCALL exsltRegisterAll (void);
+
+Index: libexslt/regexp.c
+--- /dev/null 2008-06-14 22:39:10 +0200
++++ libexslt/regexp.c 2008-06-14 22:39:04 +0200
+@@ -0,0 +1,376 @@
++/*
++ * regexp.c: Implementation of the EXSLT Regular Expressions module
++ * References: http://exslt.org/regexp/index.html
++ * Authors: Joel W. Reed <[EMAIL PROTECTED]>
++ */
++
++#if 0 /* we are embedded */
++#include <libxml/tree.h>
++#include <libxml/xpath.h>
++#include <libxml/xpathInternals.h>
++
++#define IN_LIBEXSLT
++
++#include <libxslt/xsltconfig.h>
++#include <libxslt/xsltutils.h>
++#include <libxslt/xsltInternals.h>
++#include <libxslt/extensions.h>
++#include <libexslt/exsltexports.h>
++#endif
++
++#include <string.h>
++#include "pcre.h"
++
++/**
++ * EXSLT_REGEXP_NAMESPACE:
++ *
++ * Namespace for EXSLT regexp functions
++ */
++#undef EXSLT_REGEXP_NAMESPACE
++#define EXSLT_REGEXP_NAMESPACE ((const xmlChar
*)"http://exslt.org/regular-expressions")
++
++static void
++exsltRegexpFlagsFromString(
++ const xmlChar* flagstr,
++ int* global, int* flags)
++{
++ const xmlChar* i = flagstr;
++
++ /* defaults */
++ (*flags) = PCRE_UTF8;
++ (*global) = 0;
++
++ while (*i != '\0') {
++ if (*i == 'i')
++ (*flags) |= PCRE_CASELESS;
++ else if (*i == 'g')
++ (*global)= 1;
++ /* TODO: support other flags? */
++ i++;
++ }
++}
++
++static int
++exsltRegexpExecute(
++ xmlXPathParserContextPtr ctxt,
++ const xmlChar* haystack, const xmlChar *regexp,
++ int flags, int ovector[], int ovector_len)
++{
++ int haystack_len = 0;
++ pcre *compiled_regexp = NULL;
++ int rc = 0, erroffset = 0;
++ const char *error = 0;
++
++ compiled_regexp = pcre_compile(
++ (const char *)regexp, /* the pattern */
++ flags, /* default options */
++ &error, /* for error message */
++ &erroffset, /* for error offset */
++ NULL); /* use default character tables */
++ if (compiled_regexp == NULL) {
++ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
++ "exslt:regexp failed to compile %s (char: %d).
%s", regexp, erroffset, error);
++ return -1;
++ }
++
++ haystack_len = xmlUTF8Strlen (haystack);
++
++ rc = pcre_exec(
++ compiled_regexp, /* result of pcre_compile() */
++ NULL, /* we didn't study the pattern */
++ (const char *)haystack, /* the subject string */
++ haystack_len, /* the length of the subject string */
++ 0, /* start at offset 0 in the subject */
++ 0, /* default options */
++ (int*)ovector, /* vector of integers for substring
information */
++ ovector_len); /* number of elements in the vector (NOT
size in bytes) */
++ if (rc < -1) {
++ xsltTransformError(xsltXPathGetTransformContext (ctxt), NULL, NULL,
++ "exslt:regexp failed to execute %s for %s",
regexp, haystack);
++ rc = 0;
++ }
++
++ if (compiled_regexp != NULL)
++ pcre_free(compiled_regexp);
++ return rc;
++}
++
++/**
++ * exsltRegexpMatchFunction:
++ * @ns:
++ *
++ * Returns a node set of string matches
++ */
++static void
++exsltRegexpMatchFunction(
++ xmlXPathParserContextPtr ctxt,
++ int nargs)
++{
++ xsltTransformContextPtr tctxt;
++ xmlNodePtr node;
++ xmlDocPtr container;
++ xmlXPathObjectPtr ret = NULL;
++ xmlChar *haystack, *regexp, *flagstr, *working, *match;
++ int rc, flags, global, ovector[3];
++
++ if ((nargs < 1) || (nargs > 3)) {
++ xmlXPathSetArityError(ctxt);
++ return;
++ }
++
++ flagstr = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (flagstr == NULL)) {
++ return;
++ }
++
++ regexp = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (regexp == NULL)) {
++ xmlFree(flagstr);
++ return;
++ }
++
++ haystack = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (haystack == NULL)) {
++ xmlFree(regexp);
++ xmlFree(flagstr);
++ return;
++ }
++
++ /* Return a result tree fragment */
++ tctxt = xsltXPathGetTransformContext(ctxt);
++ if (tctxt == NULL) {
++ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
++ "exslt:regexp : internal error tctxt == NULL\n");
++ goto fail;
++ }
++
++ container = xsltCreateRVT(tctxt);
++ if (container != NULL) {
++ xsltRegisterTmpRVT(tctxt, container);
++ ret = xmlXPathNewNodeSet(NULL);
++ if (ret != NULL) {
++ ret->boolval = 0;
++
++ exsltRegexpFlagsFromString(flagstr, &global, &flags);
++ working = haystack;
++ rc = exsltRegexpExecute(ctxt, working, regexp, flags,
++ 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, (const xmlChar
*)"match", match);
++ xmlFree(match);
++
++ xmlAddChild((xmlNodePtr) container, node);
++ xmlXPathNodeSetAddUnique(ret->nodesetval, node);
++
++ if (!global) break;
++
++ working = working + ovector[1];
++ rc = exsltRegexpExecute(ctxt, working, regexp, flags,
++ ovector, sizeof(ovector)/sizeof(int));
++ }
++ }
++ }
++
++ fail:
++ if (flagstr != NULL)
++ xmlFree(flagstr);
++ if (regexp != NULL)
++ xmlFree(regexp);
++ if (haystack != NULL)
++ xmlFree(haystack);
++
++ if (ret != NULL)
++ valuePush(ctxt, ret);
++ else
++ valuePush(ctxt, xmlXPathNewNodeSet(NULL));
++}
++
++/**
++ * exsltRegexpReplaceFunction:
++ * @ns:
++ *
++ * Returns a node set of string matches
++ */
++
++static void
++exsltRegexpReplaceFunction(
++ xmlXPathParserContextPtr ctxt,
++ int nargs)
++{
++ xmlChar *haystack, *regexp, *flagstr, *replace, *tmp;
++ xmlChar *result = NULL, *working, *end;
++ int rc, flags, global, ovector[3];
++
++ if ((nargs < 1) || (nargs > 4)) {
++ xmlXPathSetArityError(ctxt);
++ return;
++ }
++
++ replace = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (replace == NULL)) {
++ return;
++ }
++
++ flagstr = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (flagstr == NULL)) {
++ xmlFree(replace);
++ return;
++ }
++
++ regexp = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (regexp == NULL)) {
++ xmlFree(flagstr);
++ xmlFree(replace);
++ return;
++ }
++
++ haystack = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (haystack == NULL)) {
++ xmlFree(regexp);
++ xmlFree(flagstr);
++ xmlFree(replace);
++ return;
++ }
++
++ exsltRegexpFlagsFromString(flagstr, &global, &flags);
++
++ working = haystack;
++ rc = exsltRegexpExecute(
++ ctxt, working, regexp, flags,
++ ovector, sizeof(ovector)/sizeof(int));
++
++ while (rc > 0 ) {
++ if (0 == ovector[0]) {
++ if (NULL==result)
++ result = xmlStrdup(replace);
++ else
++ result = xmlStrcat(result, replace);
++ }
++ else {
++ tmp = xmlStrsub(working, 0, ovector[0]);
++ if (NULL == result)
++ result = tmp;
++ else {
++ result = xmlStrcat(result, tmp);
++ xmlFree(tmp);
++ }
++ result = xmlStrcat(result, replace);
++ }
++
++ working = working + ovector[1];
++
++ if (!global)
++ break;
++ rc = exsltRegexpExecute(
++ ctxt, working, regexp, flags,
++ ovector, sizeof(ovector)/sizeof(int));
++ }
++
++ end = haystack + xmlUTF8Strlen(haystack);
++ if (working < end ) {
++ if (NULL == result)
++ result = xmlStrdup(working);
++ else
++ result = xmlStrcat(result, working);
++ }
++
++ if (replace != NULL)
++ xmlFree(replace);
++ if (flagstr != NULL)
++ xmlFree(flagstr);
++ if (regexp != NULL)
++ xmlFree(regexp);
++ if (haystack != NULL)
++ xmlFree(haystack);
++
++ xmlXPathReturnString(ctxt, result);
++}
++
++/**
++ * exsltRegexpTestFunction:
++ * @ns:
++ *
++ * returns true if the string given as the first argument
++ * matches the regular expression given as the second argument
++ *
++ */
++
++static void
++exsltRegexpTestFunction(
++ xmlXPathParserContextPtr ctxt,
++ int nargs)
++{
++ xmlChar *haystack, *regexp_middle, *regexp, *flagstr;
++ int rc = 0, flags, global, ovector[3];
++
++ if ((nargs < 1) || (nargs > 3)) {
++ xmlXPathSetArityError(ctxt);
++ return;
++ }
++
++ flagstr = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (flagstr == NULL)) {
++ return;
++ }
++
++ regexp_middle = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (regexp_middle == NULL)) {
++ xmlFree(flagstr);
++ return;
++ }
++
++ haystack = xmlXPathPopString(ctxt);
++ if (xmlXPathCheckError(ctxt) || (haystack == NULL)) {
++ xmlFree(regexp_middle);
++ xmlFree(flagstr);
++ return;
++ }
++
++ /* build the regexp */
++ regexp = xmlStrdup((const xmlChar *)"\\A");
++ regexp = xmlStrcat(regexp, regexp_middle);
++ regexp = xmlStrcat(regexp, (const xmlChar *)"\\Z");
++
++ exsltRegexpFlagsFromString(flagstr, &global, &flags);
++ rc = exsltRegexpExecute(
++ ctxt, haystack, regexp, flags,
++ ovector, sizeof(ovector)/sizeof(int));
++
++ if (flagstr != NULL)
++ xmlFree(flagstr);
++ if (regexp != NULL)
++ xmlFree(regexp);
++ if (regexp_middle != NULL)
++ xmlFree(regexp_middle);
++ if (haystack != NULL)
++ xmlFree(haystack);
++
++ xmlXPathReturnBoolean(ctxt, (rc > 0));
++}
++
++/**
++ * exsltRegexpRegister:
++ *
++ * Registers the EXSLT - Regexp module
++ */
++void
++EXSLTPUBFUN exsltRegexpRegister (void)
++{
++ xsltRegisterExtModuleFunction(
++ (const xmlChar *)"match",
++ EXSLT_REGEXP_NAMESPACE,
++ exsltRegexpMatchFunction);
++ xsltRegisterExtModuleFunction(
++ (const xmlChar *)"replace",
++ EXSLT_REGEXP_NAMESPACE,
++ exsltRegexpReplaceFunction);
++ xsltRegisterExtModuleFunction(
++ (const xmlChar *)"test",
++ EXSLT_REGEXP_NAMESPACE,
++ exsltRegexpTestFunction);
++}
++
+Index: libexslt/strings.c
+--- libexslt/strings.c.orig 2007-11-29 11:45:33 +0100
++++ libexslt/strings.c 2008-06-14 22:39:34 +0200
+@@ -674,3 +674,8 @@
+ EXSLT_STRINGS_NAMESPACE,
+ exsltStrReplaceFunction);
+ }
++
++#ifdef EXSLT_REGEXP_ENABLED
++#include "regexp.c"
++#endif
++
Index: libxslt/extra.c
--- libxslt/extra.c.orig 2007-01-03 16:11:57 +0100
-+++ libxslt/extra.c 2008-06-14 22:05:17 +0200
++++ libxslt/extra.c 2008-06-14 22:39:04 +0200
@@ -244,7 +244,12 @@
* Calling localtime() has the side-effect of setting timezone.
* After we know the timezone, we can adjust for it
@@ -29,7 +444,7 @@
* FIXME: it's been too long since I did manual memory management.
Index: libxslt/xsltconfig.h.in
--- libxslt/xsltconfig.h.in.orig 2007-03-27 16:47:36 +0200
-+++ libxslt/xsltconfig.h.in 2008-06-14 22:05:17 +0200
++++ libxslt/xsltconfig.h.in 2008-06-14 22:39:04 +0200
@@ -130,8 +130,10 @@
*/
#ifdef __GNUC__
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/libxslt/libxslt.spec
============================================================================
$ cvs diff -u -r1.100 -r1.101 libxslt.spec
--- openpkg-src/libxslt/libxslt.spec 14 Jun 2008 20:18:24 -0000 1.100
+++ openpkg-src/libxslt/libxslt.spec 14 Jun 2008 20:46:18 -0000 1.101
@@ -34,6 +34,10 @@
Version: 1.1.24
Release: 20080614
+# package options
+%option with_regexp no
+%option with_crypto no
+
# list of sources
Source0: ftp://xmlsoft.org/libxslt/libxslt-%{version}.tar.gz
Patch0: libxslt.patch
@@ -45,6 +49,14 @@
PreReq: OpenPKG, openpkg >= 20040130
BuildPreReq: libxml >= 2.6.32
PreReq: libxml >= 2.6.32
+%if "%{with_regexp}" == "yes"
+BuildPreReq: pcre
+PreReq: pcre
+%endif
+%if "%{with_crypto}" == "yes"
+BuildPreReq: gcrypt
+PreReq: gcrypt
+%endif
AutoReq: no
AutoReqProv: no
@@ -68,16 +80,27 @@
configure
%build
- CC="%{l_cc}" \
- CFLAGS="%{l_cflags -O} %{l_cppflags}" \
- CPPFLAGS="%{l_cppflags}" \
- LDFLAGS="%{l_ldflags}" \
- LIBS="-lz -liconv" \
+ export CC="%{l_cc}"
+ export CFLAGS="%{l_cflags -O} %{l_cppflags}"
+ export CPPFLAGS="%{l_cppflags}"
+ export LDFLAGS="%{l_ldflags}"
+ export LIBS="-lz -liconv"
+%if "%{with_regexp}" == "yes"
+ CPPFLAGS="$CPPFLAGS -DEXSLT_REGEXP_ENABLED"
+ LIBS="$LIBS -lpcre"
+ %{l_shtool} subst \
+ -e 's;\(@[EMAIL PROTECTED]);\1 -lpcre;g' \
+ libexslt.pc.in
+%endif
./configure \
--prefix=%{l_prefix} \
--mandir=%{l_prefix}/man \
--with-libxml-prefix=%{l_prefix} \
+%if "%{with_crypto}" == "yes"
+ --with-crypto \
+%else
--without-crypto \
+%endif
--without-debug \
--without-python \
--disable-shared
@@ .
______________________________________________________________________
OpenPKG http://openpkg.org
CVS Repository Commit List [email protected]