summaryrefslogtreecommitdiff
path: root/src/file.h
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2022-04-18 21:50:49 +0000
committerChristos Zoulas <christos@zoulas.com>2022-04-18 21:50:49 +0000
commit4254a0afecfd2ae200c694dfcf93f4b4ac21652e (patch)
treea9537c1b9cc9859086c344032f044675551f362e /src/file.h
parentd1a00ae92b2cf09298615cf3aba474d8fec7380f (diff)
downloadfile-git-4254a0afecfd2ae200c694dfcf93f4b4ac21652e.tar.gz
From: Dirk Mueller:
Only regcomp() can return an error, regexec() only returns match or no-match. This allows to merge file_regerror into file_regcomp and thereby simplifies the callers of file_regcomp() as they no longer need to handle errors. Also this reduces memory overhead slightly as we can make file_regex_t directly a regex_t, saving ~ 16 bytes per regex.
Diffstat (limited to 'src/file.h')
-rw-r--r--src/file.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/file.h b/src/file.h
index 51caa599..aea3f101 100644
--- a/src/file.h
+++ b/src/file.h
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.231 2022/04/11 18:07:38 christos Exp $
+ * @(#)$File: file.h,v 1.232 2022/04/18 21:50:49 christos Exp $
*/
#ifndef __file_h__
@@ -171,11 +171,7 @@
#define FILE_COMPILE 2
#define FILE_LIST 3
-typedef struct {
- const char *pat;
- int rc;
- regex_t rx;
-} file_regex_t;
+typedef regex_t file_regex_t;
struct buffer {
int fd;
@@ -601,7 +597,6 @@ protected int file_regcomp(struct magic_set *, file_regex_t *, const char *,
protected int file_regexec(struct magic_set *, file_regex_t *, const char *,
size_t, regmatch_t *, int);
protected void file_regfree(file_regex_t *);
-protected void file_regerror(file_regex_t *, int, struct magic_set *);
typedef struct {
char *buf;