diff options
author | Judd Vinet <judd@archlinux.org> | 2005-10-07 23:29:49 +0000 |
---|---|---|
committer | Judd Vinet <judd@archlinux.org> | 2005-10-07 23:29:49 +0000 |
commit | 5ef51b3e266cf43411947248886372001fdb207a (patch) | |
tree | 8d255349530045686053faacd1804502a96b269c /src/pacman/util.c | |
parent | 79031ccd1a544475162facb8ca3d671f3464d1f8 (diff) |
Merging in recent fixes/additions from 2.9.7
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r-- | src/pacman/util.c | 16 |
1 files changed, 16 insertions, 0 deletions
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 <ctype.h> #include <dirent.h> #include <unistd.h> +#include <regex.h> #ifdef CYGWIN #include <limits.h> /* 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: */ |