Date: Sun, 26 Feb 2012 18:54:45 +0000 (UTC) From: Gabor Kovesdan <gabor@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r232189 - in user/gabor/tre-integration: contrib/tre/lib include lib/libc/regex Message-ID: <201202261854.q1QIsjZS078416@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gabor Date: Sun Feb 26 18:54:45 2012 New Revision: 232189 URL: http://svn.freebsd.org/changeset/base/232189 Log: - Add mregerror() Added: user/gabor/tre-integration/contrib/tre/lib/mregerror.c (contents, props changed) Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c user/gabor/tre-integration/include/mregex.h user/gabor/tre-integration/lib/libc/regex/Symbol.map Modified: user/gabor/tre-integration/contrib/tre/lib/mregcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Sun Feb 26 18:42:07 2012 (r232188) +++ user/gabor/tre-integration/contrib/tre/lib/mregcomp.c Sun Feb 26 18:54:45 2012 (r232189) @@ -73,7 +73,10 @@ tre_mcompile(mregex_t *preg, size_t nr, ret = tre_compile(&preg->patterns[i], wregex[i], wn[i], regex[i], n[i], cflags); if (ret != REG_OK) - goto err; + { + preg->err = i; + goto err; + } } /* If not literal, check if any of them have fixed-length prefix. */ Added: user/gabor/tre-integration/contrib/tre/lib/mregerror.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/contrib/tre/lib/mregerror.c Sun Feb 26 18:54:45 2012 (r232189) @@ -0,0 +1,44 @@ +/*- + * Copyright (C) 2012 Gabor Kovesdan <gabor@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <mregex.h> +#include <regex.h> + +size_t +tre_mregerror(int errcode, const mregex_t *preg, int *errpatn, char *errbuf, + size_t errbuf_size) +{ + + if (errpatn) + *errpatn = preg->err; + + /* XXX: 2nd argument is never read in the underlying code */ + return tre_regerror(errcode, NULL, errbuf, errbuf_size); +} Modified: user/gabor/tre-integration/include/mregex.h ============================================================================== --- user/gabor/tre-integration/include/mregex.h Sun Feb 26 18:42:07 2012 (r232188) +++ user/gabor/tre-integration/include/mregex.h Sun Feb 26 18:54:45 2012 (r232189) @@ -37,8 +37,9 @@ typedef struct { size_t k; /* Number of patterns */ regex_t *patterns; /* regex_t structure for each pattern */ - size_t mfrag; /* XXX Number of fragments */ - size_t type; /* XXX Matching type */ + size_t mfrag; /* XXX (private) Number of fragments */ + size_t type; /* XXX (private) Matching type */ + int err; /* XXX (private) Which pattern failed */ void *searchdata; } mregex_t; @@ -56,6 +57,9 @@ FUNC_DECL(mregexec)(const mregex_t *preg size_t nmatch, regmatch_t pmatch[], int eflags); void FUNC_DECL(mregfree)(mregex_t *preg); +size_t +FUNC_DECL(tre_mregerror)(int errcode, const mregex_t *preg, + int *errpatn, char *errbuf, size_t errbuf_size); #ifdef TRE_WCHAR int FUNC_DECL(mregwncomp)(mregex_t *preg, size_t nr, const wchar_t **regex, Modified: user/gabor/tre-integration/lib/libc/regex/Symbol.map ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/Symbol.map Sun Feb 26 18:42:07 2012 (r232188) +++ user/gabor/tre-integration/lib/libc/regex/Symbol.map Sun Feb 26 18:54:45 2012 (r232189) @@ -6,6 +6,7 @@ FBSD_1.2 { mregncomp; mregnexec; mregcomp; + mregerror; mregexec; mregfree; mregwcomp;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202261854.q1QIsjZS078416>