8 Commits

Author SHA1 Message Date
7255fae5d0 Bump the version to 0.7.12a. 2023-05-21 15:09:44 +02:00
03407c7afb Correction of Automake macros
Fix Automake macros to include the license file and other files and
directories in the distribution tarball.
2023-05-21 12:05:18 +02:00
dd5fefe22d Update the TODO list and bump the version to 0.7.12. 2023-05-20 20:34:23 +02:00
cbba5c2a33 Remove config.h.in from the git repo, as it is autogenerated. 2023-05-20 20:09:23 +02:00
27082f9629 Minor updates of the documentation. 2023-05-18 13:43:09 +02:00
d17f37b3c5 Include the contrib subdirectory in the distribution tarball. 2023-05-18 13:35:35 +02:00
e004f116b7 Merge branch 'pcre2-port' 2023-05-17 19:40:41 +02:00
e5409a897d Port to the pcre2 library. 2023-05-17 17:58:59 +02:00
18 changed files with 91 additions and 144 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
Makefile Makefile
config.h config.h
config.h.in
config.log config.log
config.status config.status
src/*.o src/*.o

View File

@@ -5,11 +5,15 @@
Autoconf and Automake are used, and the most basic compilation procedure consists of: Autoconf and Automake are used, and the most basic compilation procedure consists of:
``` ```
autoreconf --install
./configure ./configure
make make
make install # root rights probably needed here, prefix with sudo in such case make install # root rights probably needed here, prefix with sudo in such case
``` ```
(Invocation of `autoreconf` is only required if the source tree has been cloned from the
git repository.)
To see the list of flags accepted by the configure script, run: To see the list of flags accepted by the configure script, run:
``` ```
@@ -18,5 +22,5 @@ To see the list of flags accepted by the configure script, run:
Optionally, `mboxgrep` can be linked with the following libraries: Optionally, `mboxgrep` can be linked with the following libraries:
- PCRE, to enable support for regular expressions compatible with Perl 5; - PCRE2, to enable support for regular expressions compatible with Perl 5;
- zlib and bzlib, to enable support for compressed mbox folders. - zlib and bzlib, to enable support for compressed mbox folders.

View File

@@ -1 +1,2 @@
SUBDIRS = doc src SUBDIRS = doc src
EXTRA_DIST = contrib COPYING.md INSTALL.md NEWS.md README.md TODO.md

10
NEWS.md
View File

@@ -1,5 +1,15 @@
# Changes of mboxgrep # Changes of mboxgrep
## Changes since 0.7.12
- Fix Automake macros to include the license file and others.
## Changes since 0.7.11
- Port to the pcre2 library (pcre1 is no longer supported).
- Check command-line options for conflicting matchers and actions.
- Various minor code cleanups.
## Changes since 0.7.10 ## Changes since 0.7.10
- GNU Automake is now utilized instead of manually written Makefile.in files. - GNU Automake is now utilized instead of manually written Makefile.in files.

View File

@@ -1,7 +1,7 @@
# mboxgrep - selects e-mail messages matching a pattern # mboxgrep - selects e-mail messages matching a pattern
`mboxgrep` is a `grep(1)`-like tool which scans mailboxes and selects `mboxgrep` is a `grep(1)`-like tool which scans mailboxes and selects
e-mail messages matching pattern. e-mail messages matching a pattern.
Full description of mboxgrep is contained in the documentation, Full description of mboxgrep is contained in the documentation,
which is provided both in manpage and texinfo format, to satisfy which is provided both in manpage and texinfo format, to satisfy

View File

@@ -3,7 +3,7 @@
## Behavior ## Behavior
- [x] use cryptographic hashes for detecting duplicate messages - [x] use cryptographic hashes for detecting duplicate messages
- [ ] add checking for conflicting command-line options - [x] add checking for conflicting command-line options
- [ ] support for deletion of messages after being matched and displayed - [ ] support for deletion of messages after being matched and displayed
- [x] ignore .overview when grepping Gnus folders - [x] ignore .overview when grepping Gnus folders
- [x] inverted matching - [x] inverted matching
@@ -18,7 +18,7 @@
## File formats, encodings and standards ## File formats, encodings and standards
- [ ] migrate to pcre2, as pcre is obsolete - [x] migrate to pcre2, as pcre is obsolete
- [ ] use a more modern hash function than MD5 - [ ] use a more modern hash function than MD5
- [ ] MIME support - [ ] MIME support
- [ ] support for GnuPG - [ ] support for GnuPG

View File

@@ -18,7 +18,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
# Yawn. # Yawn.
AC_INIT([mboxgrep], [0.7.11], [dspiljar@datatipp.se], [mboxgrep], [https://www.mboxgrep.org/]) AC_INIT([mboxgrep], [0.7.12a], [dspiljar@datatipp.se], [mboxgrep], [https://www.mboxgrep.org/])
#AM_INIT_AUTOMAKE #AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE([foreign]) AM_INIT_AUTOMAKE([foreign])
AC_LANG([C]) AC_LANG([C])
@@ -34,34 +34,35 @@ AC_HEADER_DIRENT
# Checks for libraries. # Checks for libraries.
# Check for PCRE library # Check for PCRE2 library
AC_ARG_WITH(pcre, [ --without-pcre Compile without Perl regexp support],, AC_ARG_WITH(pcre2, [ --without-pcre2 Compile without Perl regexp support],,
[ [
AC_PATH_PROG(PCRE_CONFIG, pcre-config) AC_PATH_PROG(PCRE2_CONFIG, pcre2-config)
if test "$PCRE_CONFIG"; then if test "$PCRE2_CONFIG"; then
CFLAGS="$CFLAGS `$PCRE_CONFIG --cflags`" CFLAGS="$CFLAGS `$PCRE2_CONFIG --cflags`"
LIBS="$LIBS `$PCRE_CONFIG --libs`" LIBS="$LIBS `$PCRE2_CONFIG --libs32`"
AC_LINK_IFELSE( AC_LINK_IFELSE(
[ [
#include <pcre.h> #define PCRE2_CODE_UNIT_WIDTH 32
#include <pcre2.h>
int main () int main ()
{ {
return 0; return 0;
} }
], ],
AC_DEFINE(HAVE_LIBPCRE), AC_DEFINE(HAVE_LIBPCRE2),
[ [
AC_MSG_NOTICE(found pcre-config but could not compile test program.) AC_MSG_NOTICE(found pcre2-config but could not compile test program.)
AC_MSG_FAILURE(is PCRE properly installed?) AC_MSG_FAILURE(is PCRE2 properly installed?)
] ]
) )
else else
AC_MSG_NOTICE(pcre-config not found) AC_MSG_NOTICE(pcre2-config not found)
AC_MSG_NOTICE(trying to find PCRE anyway) AC_MSG_NOTICE(trying to find PCRE2 anyway)
AC_CHECK_LIB(pcre, main) AC_CHECK_LIB(pcre2, main)
fi fi
] ]
) )

View File

@@ -1,4 +1,4 @@
.TH MBOXGREP 1 "24 Mar 2023" .TH MBOXGREP 1 "21 May 2023"
.SH NAME .SH NAME
mboxgrep \- displays email messages matching a pattern mboxgrep \- displays email messages matching a pattern
.SH SYNOPSIS .SH SYNOPSIS
@@ -10,7 +10,7 @@ mboxgrep \- displays email messages matching a pattern
This manual page refers to This manual page refers to
.B mboxgrep .B mboxgrep
version version
.BR 0.7.11 . .BR 0.7.12a .
.PP .PP
.B mboxgrep .B mboxgrep
scans a scans a

View File

@@ -9,7 +9,7 @@ END-INFO-DIR-ENTRY
 
File: mboxgrep.info, Node: Top, Up: (dir) File: mboxgrep.info, Node: Top, Up: (dir)
This file documents 'mboxgrep' (version 0.7.11), a mailbox scanning This file documents 'mboxgrep' (version 0.7.12a), a mailbox scanning
utility. utility.
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
@@ -250,17 +250,17 @@ Sleep well, little friend.
 
Tag Table: Tag Table:
Node: Top197 Node: Top197
Node: Introduction596 Node: Introduction597
Node: Invoking1465 Node: Invoking1466
Node: Miscellaneous1827 Node: Miscellaneous1828
Node: File locking2112 Node: File locking2113
Node: Regexp selection2749 Node: Regexp selection2750
Node: Output control3301 Node: Output control3302
Node: Search scope selection4345 Node: Search scope selection4346
Node: Mailbox type selection4586 Node: Mailbox type selection4587
Node: Examples4907 Node: Examples4908
Node: Bugs5731 Node: Bugs5732
Node: To Vicky6149 Node: To Vicky6150
 
End Tag Table End Tag Table

View File

@@ -5,8 +5,8 @@
@setchapternewpage odd @setchapternewpage odd
@set EDITION 0.7 @set EDITION 0.7
@set VERSION 0.7.11 @set VERSION 0.7.12a
@set UPDATED 24 Mar 2023 @set UPDATED 21 May 2023
@dircategory Mail @dircategory Mail
@direntry @direntry

View File

@@ -1,76 +0,0 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the `fcntl' function. */
#undef HAVE_FCNTL
/* Define to 1 if you have the `flock' function. */
#undef HAVE_FLOCK
/* Define to 1 if you have the `fts_open' function. */
#undef HAVE_FTS_OPEN
/* Define to 1 if you have the `ftw' function. */
#undef HAVE_FTW
/* Define to 1 if you have the `bz2' library (-lbz2). */
#undef HAVE_LIBBZ2
/* Define to 1 if you have the `dmalloc' library (-ldmalloc). */
#undef HAVE_LIBDMALLOC
/* Define to 1 if you have the `garfield' library (-lgarfield). */
#undef HAVE_LIBGARFIELD
/* Define to 1 if you have the `pcre' library (-lpcre). */
#undef HAVE_LIBPCRE
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define to 1 if you have the `regcomp' function. */
#undef HAVE_REGCOMP
/* Define to 1 if you have the `strptime' function. */
#undef HAVE_STRPTIME
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION

View File

@@ -74,9 +74,9 @@ version (void)
/* /*
fprintf (stdout, "HAVE_LIBLOCKFILE "); fprintf (stdout, "HAVE_LIBLOCKFILE ");
*/ */
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
print_wrap ("HAVE_LIBPCRE"); print_wrap ("HAVE_LIBPCRE2");
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
print_wrap ("HAVE_LIBZ"); print_wrap ("HAVE_LIBZ");
#endif /* HAVE_LIBZ */ #endif /* HAVE_LIBZ */
@@ -128,10 +128,10 @@ help (void)
"Matching criteria:\n\n" "Matching criteria:\n\n"
" -E, --extended-regexp\tPATTERN is an extended regular expression\n" " -E, --extended-regexp\tPATTERN is an extended regular expression\n"
" -G, --basic-regexp\t\tPATTERN is a basic regular expression\n"); " -G, --basic-regexp\t\tPATTERN is a basic regular expression\n");
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
fprintf (stdout, fprintf (stdout,
" -P, --perl-regexp\t\tPATTERN is a Perl regular expression\n"); " -P, --perl-regexp\t\tPATTERN is a Perl regular expression\n");
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
fprintf (stdout, fprintf (stdout,
" -e, --regexp=PATTERN\t\tUse PATTERN as a regular expression\n" " -e, --regexp=PATTERN\t\tUse PATTERN as a regular expression\n"
" -i, --ignore-case\t\tIgnore case distinctions\n" " -i, --ignore-case\t\tIgnore case distinctions\n"

View File

@@ -99,11 +99,11 @@ main (int argc, char **argv)
if (config.haveregex) if (config.haveregex)
{ {
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
if (config.regextype == REGEX_PERL) if (config.regextype == REGEX_PERL)
pcre_init (); pcre_init ();
else else
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
regex_init (); regex_init ();
} }
else else

View File

@@ -21,7 +21,7 @@
#define MBOXGREP_H #define MBOXGREP_H
#define APPNAME "mboxgrep" #define APPNAME "mboxgrep"
#define VERSION "0.7.11" #define VERSION "0.7.12a"
#define BUGREPORT_ADDR "dspiljar AT datatipp.se" #define BUGREPORT_ADDR "dspiljar AT datatipp.se"
#define HOST_NAME_SIZE 256 #define HOST_NAME_SIZE 256
@@ -120,7 +120,7 @@ typedef struct
char hostname[HOST_NAME_SIZE]; char hostname[HOST_NAME_SIZE];
char *boxname, *outboxname, *pipecmd, *tmpfilename, *regex_s; char *boxname, *outboxname, *pipecmd, *tmpfilename, *regex_s;
void *pcre_pattern, *pcre_hints, *posix_pattern; void *pcre_pattern, *posix_pattern, *match_data;
int res1, res2; int res1, res2;
action_t action; action_t action;

View File

@@ -373,7 +373,7 @@ set_option_regextype (regextype_t regextype)
exit (2); exit (2);
} }
#ifndef HAVE_LIBPCRE #ifndef HAVE_LIBPCRE2
if (regextype == REGEX_PERL); if (regextype == REGEX_PERL);
{ {
fprintf (stderr, fprintf (stderr,
@@ -381,6 +381,6 @@ set_option_regextype (regextype_t regextype)
APPNAME); APPNAME);
exit (2); exit (2);
} }
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
config.regextype = regextype; config.regextype = regextype;
} }

View File

@@ -21,52 +21,58 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <regex.h> #include <regex.h>
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
# include <pcre.h> # define PCRE2_CODE_UNIT_WIDTH 32
#endif /* HAVE_LIBPCRE */ # include <pcre2.h>
#endif /* HAVE_LIBPCRE2 */
#include "mboxgrep.h" #include "mboxgrep.h"
#include "message.h" #include "message.h"
#include "wrap.h" /* xcalloc() et cetera */ #include "wrap.h" /* xcalloc() et cetera */
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
void void
pcre_init (void) pcre_init (void)
{ {
int errptr; int errornumber;
const char *error; PCRE2_SIZE erroroffset;
config.pcre_pattern = config.pcre_pattern =
(pcre *) pcre_compile (config.regex_s, (pcre2_code *) pcre2_compile ((PCRE2_SPTR) config.regex_s, (PCRE2_SIZE) strlen (config.regex_s),
(config.ignorecase ? PCRE_CASELESS : 0), (config.ignorecase ? PCRE2_CASELESS : 0),
&error, &errptr, NULL); &errornumber, &erroroffset, NULL);
if (config.pcre_pattern == NULL) if (config.pcre_pattern == NULL)
{ {
if (config.merr) if (config.merr)
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, error); {
PCRE2_UCHAR buffer[256];
pcre2_get_error_message (errornumber, buffer, sizeof(buffer));
fprintf (stderr, "%s: PCRE2 compilation failed at offset %d: %s\n",
APPNAME, (int) erroroffset, (char *) buffer);
}
exit (2); exit (2);
} }
config.match_data =
(pcre2_match_data* ) pcre2_match_data_create_from_pattern (config.pcre_pattern, NULL);
} }
void void
pcre_match (message_t * msg) pcre_match (message_t * msg)
{ {
int of[BUFSIZ];
if (config.headers) if (config.headers)
config.res1 = config.res1 =
pcre_exec ((pcre *) config.pcre_pattern, pcre2_match ((pcre2_code *) config.pcre_pattern,
(pcre_extra *) config.pcre_hints, (PCRE2_SPTR) msg->headers, (int) strlen (msg->headers), 0, 0, config.match_data, NULL);
msg->headers, (int) strlen (msg->headers), 0, 0, of, BUFSIZ);
if (config.body) if (config.body)
config.res2 = config.res2 =
pcre_exec ((pcre *) config.pcre_pattern, pcre2_match ((pcre2_code *) config.pcre_pattern,
(pcre_extra *) config.pcre_hints, (PCRE2_SPTR) msg->body, (int) strlen (msg->body), 0, 0, config.match_data, NULL);
msg->body, (int) strlen (msg->body), 0, 0, of, BUFSIZ);
config.res1 = config.res1 ^ 1; config.res1 = config.res1 ^ 1;
config.res2 = config.res2 ^ 1; config.res2 = config.res2 ^ 1;
} }
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
void void
regex_init (void) regex_init (void)

View File

@@ -19,9 +19,9 @@
#include "mboxgrep.h" #include "mboxgrep.h"
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
void pcre_init (void); void pcre_init (void);
void pcre_match (message_t * msg); void pcre_match (message_t * msg);
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
void regex_init (void); void regex_init (void);
void regex_match (message_t * msg); void regex_match (message_t * msg);

View File

@@ -146,11 +146,11 @@ scan_mailbox (char path[])
if (msg->from == NULL) if (msg->from == NULL)
msg->from = (char *) xstrdup ("nobody"); msg->from = (char *) xstrdup ("nobody");
#ifdef HAVE_LIBPCRE #ifdef HAVE_LIBPCRE2
if (config.regextype == REGEX_PERL) if (config.regextype == REGEX_PERL)
pcre_match (msg); pcre_match (msg);
else else
#endif /* HAVE_LIBPCRE */ #endif /* HAVE_LIBPCRE2 */
regex_match (msg); regex_match (msg);
if (config.dedup) if (config.dedup)