diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/posixplz.h | 8 | ||||
-rw-r--r-- | src/sysdeps/tryemptyregex.c | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h index 639a7c4..22cdf3a 100644 --- 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 new file mode 100644 index 0000000..a2243f7 --- /dev/null +++ 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) ; +} |