From owner-svn-src-user@FreeBSD.ORG Sun Feb 26 18:54:45 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D338D106564A; Sun, 26 Feb 2012 18:54:45 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BDCAF8FC16; Sun, 26 Feb 2012 18:54:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1QIsjvT078421; Sun, 26 Feb 2012 18:54:45 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1QIsjZS078416; Sun, 26 Feb 2012 18:54:45 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201202261854.q1QIsjZS078416@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 26 Feb 2012 18:54:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232189 - in user/gabor/tre-integration: contrib/tre/lib include lib/libc/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Feb 2012 18:54:45 -0000 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 + * 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 +#endif /* HAVE_CONFIG_H */ + +#include +#include + +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;