skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 92e40f4f3b8e153b86093996d2a6d2a1160e105d
parent ab0416faed65154c408e4fb5066cd8433a4bfa11
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sat, 11 May 2019 06:22:36 +0000

 Add tryemptyregex/skalibs_regcomp, prepare for 2.8.1.0

Diffstat:
MNEWS | 6++++++
Mconfigure | 1+
Mdoc/index.html | 2+-
Mdoc/upgrade.html | 11+++++++++++
Mpackage/info | 2+-
Msrc/include/skalibs/posixplz.h | 8++++++++
Asrc/sysdeps/tryemptyregex.c | 16++++++++++++++++
7 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS @@ -1,5 +1,11 @@ Changelog for skalibs. +In 2.8.1.0 +---------- + + - Added skalibs_regcomp(), accepting empty regexes on BSDs. + + In 2.8.0.1 ---------- diff --git a/configure b/configure @@ -548,6 +548,7 @@ EOF choose cl namespaces NAMESPACES 'namespaces' choose cl nsgetparent NSGETPARENT 'NS_GET_PARENT' choose cl explicit_bzero EXPLICIT_BZERO 'explicit_bzero()' + choose clr emptyregex EMPTYREGEX 'regcomp() accept empty regexes' echo '#endif' >> $sysdeps/sysdeps.h fi diff --git a/doc/index.html b/doc/index.html @@ -60,7 +60,7 @@ with a standard C development environment </li> <h3> Download </h3> <ul> - <li> The current released version of skalibs is <a href="skalibs-2.8.0.1.tar.gz">2.8.0.1</a>. </li> + <li> The current released version of skalibs is <a href="skalibs-2.8.1.0.tar.gz">2.8.1.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/skalibs/">skalibs git repository</a>: diff --git a/doc/upgrade.html b/doc/upgrade.html @@ -16,6 +16,17 @@ <a href="//skarnet.org/">skarnet.org</a> </p> +<h2> in 2.8.1.0 </h2> + +<ul> + <li> New functions: + <ul> + <li> <tt>skalibs_regcomp()</tt>, which accepts empty regexes even +when <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/regcomp.html">regcomp()</a> +does not (e.g. the BSDs). </li> + </ul> </li> +</ul> + <h2> in 2.8.0.1 </h2> <ul> diff --git a/package/info b/package/info @@ -1,4 +1,4 @@ package=skalibs -version=2.8.0.1 +version=2.8.1.0 category=prog package_macro_name=SKALIBS diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h @@ -5,6 +5,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <regex.h> #include <skalibs/gccattributes.h> #include <skalibs/functypes.h> @@ -44,4 +45,11 @@ extern int mkhtemp (char const *, char *) ; extern int mkctemp (char *, mode_t, dev_t) ; extern int mkbtemp (char *, mode_t, dev_t) ; + + /* + Wrappers around functions that should be specified better. + */ + +#define skalibs_regcomp(re, s, flags) regcomp(re, (s)[0] ? (s) : ".*", flags) + #endif diff --git a/src/sysdeps/tryemptyregex.c b/src/sysdeps/tryemptyregex.c @@ -0,0 +1,16 @@ +/* ISC license. */ + +#include <regex.h> + +int main (void) +{ + regex_t re ; + int r = regcomp(&re, "", REG_EXTENDED | REG_NOSUB) ; + switch (r) + { + case 0 : break ; + case REG_ESPACE : return 111 ; + default : return 1 ; + } + return !!regexec(&re, "a", 0, 0, 0) ; +}