aboutsummaryrefslogtreecommitdiffstats
path: root/g10/trustdb.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-04-03 06:30:08 +0000
committerNIIBE Yutaka <[email protected]>2020-04-03 06:30:08 +0000
commitba247a114c75a84473c11c1484013b09fbb9bcd1 (patch)
treea76cedce73621da0142ceb7d71ae51cad8696ec3 /g10/trustdb.c
parentscd:p15: Implement do_with_keygrip and capabilities. (diff)
downloadgnupg-ba247a114c75a84473c11c1484013b09fbb9bcd1.tar.gz
gnupg-ba247a114c75a84473c11c1484013b09fbb9bcd1.zip
gpg: Add regular expression support.
* AUTHORS, COPYING.other: Update. * Makefile.am (SUBDIRS): Add regexp sub directory. * configure.ac (DISABLE_REGEX): Remove. * g10/Makefile.am (needed_libs): Add libregexp.a. * g10/trustdb.c: Remove DISABLE_REGEX support. * regexp/LICENSE, regexp/jimregexp.c, regexp/jimregexp.h, regexp/utf8.c, regexp/utf8.h: New from Jim Tcl. * regexp/UnicodeData.txt: New from Unicode. * regexp/Makefile.am, regexp/parse-unidata.awk: New. * tests/openpgp/Makefile.am: Remove DISABLE_REGEX support. * tools/Makefile.am: Remove DISABLE_REGEX support. GnuPG-bug-id: 4843 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/trustdb.c')
-rw-r--r--g10/trustdb.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 6232e0320..c4b996a96 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -23,14 +23,10 @@
#include <stdlib.h>
#include <string.h>
-#ifndef DISABLE_REGEX
-#include <sys/types.h>
-#include <regex.h>
-#endif /* !DISABLE_REGEX */
-
#include "gpg.h"
#include "../common/status.h"
#include "../common/iobuf.h"
+#include "../regexp/jimregexp.h"
#include "keydb.h"
#include "../common/util.h"
#include "options.h"
@@ -1526,7 +1522,6 @@ store_validation_status (ctrl_t ctrl, int depth,
/* Returns a sanitized copy of the regexp (which might be "", but not
NULL). */
-#ifndef DISABLE_REGEX
/* Operator characters except '.' and backslash.
See regex(7) on BSD. */
#define REGEXP_OPERATOR_CHARS "^[$()|*+?{"
@@ -1591,7 +1586,6 @@ sanitize_regexp(const char *old)
return new;
}
-#endif /*!DISABLE_REGEX*/
/* Used by validate_one_keyblock to confirm a regexp within a trust
signature. Returns 1 for match, and 0 for no match or regex
@@ -1599,25 +1593,15 @@ sanitize_regexp(const char *old)
static int
check_regexp(const char *expr,const char *string)
{
-#ifdef DISABLE_REGEX
- (void)expr;
- (void)string;
- /* When DISABLE_REGEX is defined, assume all regexps do not
- match. */
- return 0;
-#else
int ret;
char *regexp;
regexp=sanitize_regexp(expr);
-#ifdef __riscos__
- ret=riscos_check_regexp(expr, string, DBG_TRUST);
-#else
{
regex_t pat;
- ret=regcomp(&pat,regexp,REG_ICASE|REG_NOSUB|REG_EXTENDED);
+ ret=regcomp(&pat,regexp,REG_ICASE|REG_EXTENDED);
if(ret==0)
{
ret=regexec(&pat,string,0,NULL,0);
@@ -1625,7 +1609,6 @@ check_regexp(const char *expr,const char *string)
}
ret=(ret==0);
}
-#endif
if(DBG_TRUST)
log_debug("regexp '%s' ('%s') on '%s': %s\n",
@@ -1634,7 +1617,6 @@ check_regexp(const char *expr,const char *string)
xfree(regexp);
return ret;
-#endif
}
/*