Date: Mon, 22 Jan 2018 02:44:41 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328240 - in head: etc/mtree lib lib/libc/regex lib/libc/tests/regex lib/libregex lib/libregex/tests share/mk Message-ID: <201801220244.w0M2if3I083081@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Mon Jan 22 02:44:41 2018 New Revision: 328240 URL: https://svnweb.freebsd.org/changeset/base/328240 Log: Add libregex, connect it to the build libregex is a regex(3) implementation intended to feature GNU extensions and any other non-POSIX compliant extensions that are deemed worthy. These extensions are separated out into a separate library for the sake of not cluttering up libc further with them as well as not deteriorating the speed (or lack thereof) of the libc implementation. libregex is implemented as a build of the libc implementation with LIBREGEX defined to distinguish this from a libc build. The reasons for implementation like this are two-fold: 1.) Maintenance- This reduces the overhead induced by adding yet another regex implementation to base. 2.) Ease of use- Flipping on GNU extensions will be as simple as linking against libregex, and POSIX-compliant compilations can be guaranteed with a REG_POSIX cflag that should be ignored by libc/regex and disables extensions in libregex. It is also easier to keep REG_POSIX sane and POSIX pure when implemented in this fashion. Tests are added for future functionality, but left disconnected for the time being while other testing is done. Reviewed by: cem (previous version) Differential Revision: https://reviews.freebsd.org/D12934 Added: head/lib/libc/tests/regex/Makefile.inc - copied, changed from r328136, head/lib/libc/tests/regex/Makefile head/lib/libregex/ head/lib/libregex/Makefile (contents, props changed) head/lib/libregex/tests/ head/lib/libregex/tests/Makefile (contents, props changed) head/lib/libregex/tests/gnuext.in (contents, props changed) head/lib/libregex/tests/libregex_test.sh (contents, props changed) Modified: head/etc/mtree/BSD.tests.dist head/lib/Makefile head/lib/libc/regex/Makefile.inc head/lib/libc/tests/regex/Makefile head/share/mk/bsd.libnames.mk head/share/mk/src.libnames.mk Modified: head/etc/mtree/BSD.tests.dist ============================================================================== --- head/etc/mtree/BSD.tests.dist Mon Jan 22 02:26:10 2018 (r328239) +++ head/etc/mtree/BSD.tests.dist Mon Jan 22 02:44:41 2018 (r328240) @@ -354,6 +354,10 @@ .. libproc .. + libregex + data + .. + .. librt .. libsbuf Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Mon Jan 22 02:26:10 2018 (r328239) +++ head/lib/Makefile Mon Jan 22 02:44:41 2018 (r328240) @@ -71,6 +71,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libpjdlog \ ${_libproc} \ libprocstat \ + libregex \ librpcsvc \ librss \ librt \ Modified: head/lib/libc/regex/Makefile.inc ============================================================================== --- head/lib/libc/regex/Makefile.inc Mon Jan 22 02:26:10 2018 (r328239) +++ head/lib/libc/regex/Makefile.inc Mon Jan 22 02:44:41 2018 (r328240) @@ -10,8 +10,11 @@ SRCS+= regcomp.c regerror.c regexec.c regfree.c SYM_MAPS+=${LIBC_SRCTOP}/regex/Symbol.map +# manpages only included in libc version +.if ${LIB} == "c" MAN+= regex.3 MAN+= re_format.7 MLINKS+=regex.3 regcomp.3 regex.3 regexec.3 regex.3 regerror.3 MLINKS+=regexec.3 regfree.3 +.endif Modified: head/lib/libc/tests/regex/Makefile ============================================================================== --- head/lib/libc/tests/regex/Makefile Mon Jan 22 02:26:10 2018 (r328239) +++ head/lib/libc/tests/regex/Makefile Mon Jan 22 02:44:41 2018 (r328240) @@ -1,63 +1,7 @@ # $FreeBSD$ -.include <bsd.own.mk> - PACKAGE= tests -BINDIR= ${TESTSDIR} - -# SKIP_LEFTASSOC -> these testcases fail on FreeBSD. -IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_LEFTASSOC - -CFLAGS.h_regex+=-I${TESTSRC} -I${.CURDIR:H:H}/regex -PROGS+= h_regex -SRCS.h_regex= main.c split.c debug.c - -NETBSD_ATF_TESTS_SH= regex_test - -${PACKAGE}FILES+= README - -FILESGROUPS+= ${PACKAGE}DATA_FILES -${PACKAGE}DATA_FILESPACKAGE=${PACKAGE} - -${PACKAGE}DATA_FILESDIR= ${TESTSDIR}/data -${PACKAGE}DATA_FILES+= data/anchor.in -${PACKAGE}DATA_FILES+= data/backref.in -${PACKAGE}DATA_FILES+= data/basic.in -${PACKAGE}DATA_FILES+= data/bracket.in -${PACKAGE}DATA_FILES+= data/c_comments.in -${PACKAGE}DATA_FILES+= data/complex.in -${PACKAGE}DATA_FILES+= data/error.in -${PACKAGE}DATA_FILES+= data/meta.in -${PACKAGE}DATA_FILES+= data/nospec.in -${PACKAGE}DATA_FILES+= data/paren.in -${PACKAGE}DATA_FILES+= data/regress.in -${PACKAGE}DATA_FILES+= data/repet_bounded.in -${PACKAGE}DATA_FILES+= data/repet_multi.in -${PACKAGE}DATA_FILES+= data/repet_ordinary.in -${PACKAGE}DATA_FILES+= data/startend.in -${PACKAGE}DATA_FILES+= data/subexp.in -${PACKAGE}DATA_FILES+= data/subtle.in -${PACKAGE}DATA_FILES+= data/word_bound.in -${PACKAGE}DATA_FILES+= data/zero.in -#${PACKAGE}DATA_FILES+= data/att/README -${PACKAGE}DATA_FILES+= data/att/basic.dat -${PACKAGE}DATA_FILES+= data/att/categorization.dat -${PACKAGE}DATA_FILES+= data/att/forcedassoc.dat -${PACKAGE}DATA_FILES+= data/att/leftassoc.dat -${PACKAGE}DATA_FILES+= data/att/nullsubexpr.dat -${PACKAGE}DATA_FILES+= data/att/repetition.dat -${PACKAGE}DATA_FILES+= data/att/rightassoc.dat - -NETBSD_ATF_TESTS_C= exhaust_test -NETBSD_ATF_TESTS_C+= regex_att_test - -.for t in ${NETBSD_ATF_TESTS_C} -CFLAGS.$t+= -I${TESTSRC} ${IMPLEMENTATION} -.endfor - -.include "../Makefile.netbsd-tests" - -LIBADD.regex_att_test+= util - +.include "Makefile.inc" +.include "${.CURDIR:H}/Makefile.netbsd-tests" .include <bsd.test.mk> Copied and modified: head/lib/libc/tests/regex/Makefile.inc (from r328136, head/lib/libc/tests/regex/Makefile) ============================================================================== --- head/lib/libc/tests/regex/Makefile Thu Jan 18 20:45:41 2018 (r328136, copy source) +++ head/lib/libc/tests/regex/Makefile.inc Mon Jan 22 02:44:41 2018 (r328240) @@ -2,14 +2,12 @@ .include <bsd.own.mk> -PACKAGE= tests +BINDIR?= ${TESTSDIR} -BINDIR= ${TESTSDIR} - # SKIP_LEFTASSOC -> these testcases fail on FreeBSD. IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_LEFTASSOC -CFLAGS.h_regex+=-I${TESTSRC} -I${.CURDIR:H:H}/regex +CFLAGS.h_regex+=-I${TESTSRC} -I${SRCTOP}/lib/libc/regex PROGS+= h_regex SRCS.h_regex= main.c split.c debug.c @@ -56,8 +54,4 @@ NETBSD_ATF_TESTS_C+= regex_att_test CFLAGS.$t+= -I${TESTSRC} ${IMPLEMENTATION} .endfor -.include "../Makefile.netbsd-tests" - LIBADD.regex_att_test+= util - -.include <bsd.test.mk> Added: head/lib/libregex/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libregex/Makefile Mon Jan 22 02:44:41 2018 (r328240) @@ -0,0 +1,19 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +PACKAGE=lib${LIB} +LIB= regex +SHLIB_MAJOR= 1 +SHLIB_MINOR= 0 + +CFLAGS+= -DLIBREGEX +LIBC_SRCTOP= ${.CURDIR:H}/libc +SYMBOL_MAPS= ${SYM_MAPS} + +#HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + +.include "../Makefile.inc" +.include "${LIBC_SRCTOP}/regex/Makefile.inc" +.include <bsd.lib.mk> Added: head/lib/libregex/tests/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libregex/tests/Makefile Mon Jan 22 02:44:41 2018 (r328240) @@ -0,0 +1,20 @@ +# $FreeBSD$ + +PACKAGE= tests +TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/regex + +.PATH: ${SRCTOP}/tests + +.include "${SRCTOP}/lib/libc/tests/regex/Makefile.inc" + +ATF_TESTS_SH+= libregex_test + +${PACKAGE}DATA_FILES+= gnuext.in + +LIBADD.h_regex+=regex +.for t in ${NETBSD_ATF_TESTS_C} +LIBADD.$t+= regex +.endfor + +.include <netbsd-tests.test.mk> +.include <bsd.test.mk> Added: head/lib/libregex/tests/gnuext.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libregex/tests/gnuext.in Mon Jan 22 02:44:41 2018 (r328240) @@ -0,0 +1,30 @@ +# BRE Quantifiers +ab\?c b abc abc +ab\+c b abc abc +# BRE Branching +abc\|de b abc abc +a\|b\|c b abc a +\(ab\|bc\) b abcd ab +# ERE Backrefs +(ab)\1 - ab +(ab)\1 - abab abab +\1(ab) C ESUBREG +(a)(b)(c)(d)(e)(f)(g)(h)(i)\9 - abcdefghii abcdefghii +# \w, \W, \s, \S (alnum, ^alnum, space, ^space) +\w+ - -%@a0X- a0X +\w\+ b -%@a0X- a0X +\s+ - aSNTb SNT +\s\+ b aSNTb SNT +# Word boundaries (\b, \B, \<, \>, \`, \') +# (is/not boundary, start/end word, start/end subject string) +\babc\b & <abc> abc +\<abc\> & <abc> abc +\Babc\B & abc +\B[abc]\B & <abc> b +\B[abc]+ - <abc> bc +\B[abc]\+ b <abc> bc +\`abc\' & abc abc +\`.+\' - abNc abNc +\`.\+\' b abNc abNc +(\`a) - Na +(a\') - aN Added: head/lib/libregex/tests/libregex_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libregex/tests/libregex_test.sh Mon Jan 22 02:44:41 2018 (r328240) @@ -0,0 +1,55 @@ +# +# Copyright (c) 2017 Kyle Evans <kevans@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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +# +# $FreeBSD$ + +check() +{ + local dataname="${1}"; shift + + prog="$(atf_get_srcdir)/h_regex" + data="$(atf_get_srcdir)/data/${dataname}.in" + + atf_check -x "${prog} <${data}" + atf_check -x "${prog} -el <${data}" + atf_check -x "${prog} -er <${data}" +} + +create_tc() +{ + local name="${1}"; shift + local descr="${1}"; shift + + atf_test_case "${name}" + eval "${name}_head() { atf_set 'descr' '${descr}'; }" + eval "${name}_body() { check '${name}'; }" + + atf_add_test_case "${name}" +} + +atf_init_test_cases() +{ + create_tc gnuext "Check GNU extension functionality" +} Modified: head/share/mk/bsd.libnames.mk ============================================================================== --- head/share/mk/bsd.libnames.mk Mon Jan 22 02:26:10 2018 (r328239) +++ head/share/mk/bsd.libnames.mk Mon Jan 22 02:44:41 2018 (r328240) @@ -132,6 +132,7 @@ LIBPROCSTAT?= ${LIBDESTDIR}${LIBDIR_BASE}/libprocstat. LIBPTHREAD?= ${LIBDESTDIR}${LIBDIR_BASE}/libpthread.a LIBRADIUS?= ${LIBDESTDIR}${LIBDIR_BASE}/libradius.a LIBRDMACM?= ${LIBDESTDIR}${LIBDIR_BASE}/librdmacm.a +LIBREGEX?= ${LIBDESTDIR}${LIBDIR_BASE}/libregex.a LIBROKEN?= ${LIBDESTDIR}${LIBDIR_BASE}/libroken.a LIBRPCSEC_GSS?= ${LIBDESTDIR}${LIBDIR_BASE}/librpcsec_gss.a LIBRPCSVC?= ${LIBDESTDIR}${LIBDIR_BASE}/librpcsvc.a Modified: head/share/mk/src.libnames.mk ============================================================================== --- head/share/mk/src.libnames.mk Mon Jan 22 02:26:10 2018 (r328239) +++ head/share/mk/src.libnames.mk Mon Jan 22 02:44:41 2018 (r328240) @@ -148,6 +148,7 @@ _LIBRARIES= \ pthread \ radius \ readline \ + regex \ roken \ rpcsec_gss \ rpcsvc \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801220244.w0M2if3I083081>