From owner-svn-src-head@freebsd.org Mon Jan 22 02:44:43 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F02AAEC9736; Mon, 22 Jan 2018 02:44:43 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B107F39DC; Mon, 22 Jan 2018 02:44:43 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9B54144C8; Mon, 22 Jan 2018 02:44:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0M2igDt083092; Mon, 22 Jan 2018 02:44:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0M2if3I083081; Mon, 22 Jan 2018 02:44:41 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801220244.w0M2if3I083081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 22 Jan 2018 02:44:41 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: etc/mtree lib lib/libc/regex lib/libc/tests/regex lib/libregex lib/libregex/tests share/mk X-SVN-Commit-Revision: 328240 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2018 02:44:44 -0000 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 - 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 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 -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 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 + +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 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 +.include 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 +\Babc\B & abc +\B[abc]\B & b +\B[abc]+ - bc +\B[abc]\+ b 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 +# 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 \