From 5ef51b3e266cf43411947248886372001fdb207a Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Fri, 7 Oct 2005 23:29:49 +0000 Subject: Merging in recent fixes/additions from 2.9.7 --- src/pacman/util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/pacman/util.c') diff --git a/src/pacman/util.c b/src/pacman/util.c index 1d3844a3..5a60070b 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef CYGWIN #include /* PATH_MAX */ #endif @@ -224,4 +225,19 @@ int yesno(char *fmt, ...) return(0); } +/* match a string against a regular expression */ +int reg_match(char *string, char *pattern) +{ + int result; + regex_t reg; + + if(regcomp(®, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) { + fprintf(stderr, "error: %s is not a valid regular expression.\n", pattern); + return(-1); + } + result = regexec(®, string, 0, 0, 0); + regfree(®); + return(!(result)); +} + /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3