RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 10-Feb-2008 00:12:34
Branch: HEAD Handle: 2008020923123300
Modified files:
rpm CHANGES
rpm/rpmio librpmio.vers mire.c mire.h poptIO.c poptIO.h
tdir.c tfts.c tget.c tglob.c tmire.c
Log:
- jbj: mire: add RPMMIRE_PCRE for the pcre(3) inclined.
- jbj: tweak up tmire with rpmioAllPoptTable.
- jbj: rpmio: add global __debug to use common rpmioAllPopt --debug option.
Summary:
Revision Changes Path
1.2169 +3 -0 rpm/CHANGES
2.38 +1 -0 rpm/rpmio/librpmio.vers
1.10 +43 -0 rpm/rpmio/mire.c
1.8 +11 -4 rpm/rpmio/mire.h
1.2 +3 -3 rpm/rpmio/poptIO.c
1.3 +3 -0 rpm/rpmio/poptIO.h
2.14 +1 -4 rpm/rpmio/tdir.c
2.21 +1 -3 rpm/rpmio/tfts.c
1.16 +1 -5 rpm/rpmio/tget.c
2.13 +2 -4 rpm/rpmio/tglob.c
1.3 +8 -26 rpm/rpmio/tmire.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2168 -r1.2169 CHANGES
--- rpm/CHANGES 9 Feb 2008 20:44:49 -0000 1.2168
+++ rpm/CHANGES 9 Feb 2008 23:12:33 -0000 1.2169
@@ -1,4 +1,7 @@
5.0.0 -> 5.1a1:
+ - jbj: mire: add RPMMIRE_PCRE for the pcre(3) inclined.
+ - jbj: tweak up tmire with rpmioAllPoptTable.
+ - jbj: rpmio: add global __debug to use common rpmioAllPopt --debug option.
- jbj: use poptIO with rpmio noinst_PROGRAMS.
- jbj: rpmio: clone poptIO.[ch] from poptALL.c for rpmio noinst_PROGRAMS.
- jbj: rpmcli: remove duplicate nolibio entry in poptALL.c
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/librpmio.vers
============================================================================
$ cvs diff -u -r2.37 -r2.38 librpmio.vers
--- rpm/rpmio/librpmio.vers 9 Feb 2008 20:44:49 -0000 2.37
+++ rpm/rpmio/librpmio.vers 9 Feb 2008 23:12:33 -0000 2.38
@@ -57,6 +57,7 @@
davStat;
davUnlink;
davWrite;
+ __debug;
delMacro;
expandMacros;
Fclose;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/mire.c
============================================================================
$ cvs diff -u -r1.9 -r1.10 mire.c
--- rpm/rpmio/mire.c 2 Feb 2008 01:33:19 -0000 1.9
+++ rpm/rpmio/mire.c 9 Feb 2008 23:12:33 -0000 1.10
@@ -3,6 +3,10 @@
*/
#include "system.h"
+#ifdef WITH_PCRE
+#include <pcre.h>
+#endif
+
#include <rpmio.h> /* XXX _free */
#include <rpmlog.h>
#define _MIRE_INTERNAL
@@ -29,9 +33,20 @@
mire->preg = _free(mire->preg);
/*@=voidabstract =usereleased @*/
}
+ if (mire->pcre != NULL) {
+#ifdef WITH_PCRE
+ pcre_free(mire->pcre);
+#endif
+ mire->pcre = NULL;
+ }
+ mire->errmsg = NULL;
+ mire->erroff = 0;
+ mire->errcode = 0;
mire->fnflags = 0;
mire->cflags = 0;
mire->eflags = 0;
+ mire->coptions = 0;
+ mire->eoptions = 0;
mire->notmatch = 0;
return 0;
}
@@ -110,6 +125,18 @@
rc = -1;
}
break;
+#ifdef WITH_PCRE
+ case RPMMIRE_PCRE:
+ rc = pcre_exec(mire->pcre, NULL, val, (int)strlen(val), 0,
+ mire->eoptions, NULL, 0);
+ if (rc && rc != PCRE_ERROR_NOMATCH) {
+ rpmlog(RPMLOG_ERR, _("%s: pcre_exec failed: return %d\n"), rc);
+ rc = -1;
+ }
+#else
+ rc = -1;
+#endif
+ break;
case RPMMIRE_GLOB:
rc = fnmatch(mire->pattern, val, mire->fnflags);
if (rc && rc != FNM_NOMATCH)
@@ -137,6 +164,22 @@
case RPMMIRE_DEFAULT:
case RPMMIRE_STRCMP:
break;
+#ifdef WITH_PCRE
+ case RPMMIRE_PCRE:
+ if (mire->coptions == 0)
+ mire->coptions = 0; /* XXX defaults? */
+ mire->pcre = pcre_compile2(mire->pattern, mire->coptions,
+ &mire->errcode, &mire->errmsg, &mire->erroff, NULL);
+ if (mire->pcre == NULL) {
+ rpmlog(RPMLOG_ERR,
+ _("%s: pcre_compile2 failed: %s(%d) at offset %d\n"),
+ mire->pattern, mire->errmsg, mire->errcode, mire->erroff);
+ rc = -1;
+ }
+#else
+ rc = -1;
+#endif
+ break;
case RPMMIRE_REGEX:
mire->preg = xcalloc(1, sizeof(*mire->preg));
if (mire->cflags == 0)
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/mire.h
============================================================================
$ cvs diff -u -r1.7 -r1.8 mire.h
--- rpm/rpmio/mire.h 1 Nov 2007 19:19:21 -0000 1.7
+++ rpm/rpmio/mire.h 9 Feb 2008 23:12:33 -0000 1.8
@@ -44,10 +44,11 @@
* Tag value pattern match mode.
*/
typedef enum rpmMireMode_e {
- RPMMIRE_DEFAULT = 0, /*!< regex with \., .* and ^...$ added */
- RPMMIRE_STRCMP = 1, /*!< strings using strcmp(3) */
- RPMMIRE_REGEX = 2, /*!< regex(7) patterns through regcomp(3) */
- RPMMIRE_GLOB = 3 /*!< glob(7) patterns through fnmatch(3) */
+ RPMMIRE_DEFAULT = 0, /*!< posix regex with \., .* and ^...$ added */
+ RPMMIRE_STRCMP = 1, /*!< strings using strcmp(3) */
+ RPMMIRE_REGEX = 2, /*!< posix regex(7) patterns using regcomp(3) */
+ RPMMIRE_GLOB = 3, /*!< glob(7) patterns using fnmatch(3) */
+ RPMMIRE_PCRE = 4 /*!< pcre patterns using pcre_compile2(3) */
} rpmMireMode;
#if defined(_MIRE_INTERNAL)
@@ -59,9 +60,15 @@
const char *pattern; /*!< pattern string */
/*@only@*/ /*@relnull@*/
regex_t *preg; /*!< regex compiled pattern buffer */
+ void *pcre; /*!< pcre comiled pattern buffer. */
+ const char * errmsg; /*!< pcre error message. */
+ int erroff; /*!< pcre error offset. */
+ int errcode; /*!< pcre error code. */
int fnflags; /*!< fnmatch(3) flags (0 uses FNM_PATHNAME|FNM_PERIOD)*/
int cflags; /*!< regcomp(3) flags (0 uses REG_EXTENDED|REG_NOSUB) */
int eflags; /*!< regexec(3) flags */
+ int coptions; /*!< pcre_compile2(3) options. */
+ int eoptions; /*!< pcre_exec(3) options. */
int notmatch; /*!< non-zero: negative match, like "grep -v" */
int tag; /*!< sort identifier (e.g. an rpmTag) */
/*@refs@*/
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/poptIO.c
============================================================================
$ cvs diff -u -r1.1 -r1.2 poptIO.c
--- rpm/rpmio/poptIO.c 9 Feb 2008 20:12:20 -0000 1.1
+++ rpm/rpmio/poptIO.c 9 Feb 2008 23:12:33 -0000 1.2
@@ -33,7 +33,7 @@
#define POPT_CRYPTO -993
/*@unchecked@*/
-static int _debug = 0;
+int __debug = 0;
#ifdef NOTYET
/*@unchecked@*/
@@ -255,7 +255,7 @@
rpmioAllArgCallback, 0, NULL, NULL },
/*@=type@*/
- { "debug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_debug, -1,
+ { "debug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &__debug, -1,
NULL, NULL },
{ "define", 'D', POPT_ARG_STRING, NULL, 'D',
@@ -528,7 +528,7 @@
/* Read rpm configuration (if not already read). */
rpmioConfigured();
- if (_debug) {
+ if (__debug) {
rpmIncreaseVerbosity();
rpmIncreaseVerbosity();
}
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/poptIO.h
============================================================================
$ cvs diff -u -r1.2 -r1.3 poptIO.h
--- rpm/rpmio/poptIO.h 9 Feb 2008 20:44:49 -0000 1.2
+++ rpm/rpmio/poptIO.h 9 Feb 2008 23:12:33 -0000 1.3
@@ -16,6 +16,9 @@
#include <mire.h>
#include <popt.h>
+/*@unchecked@*/
+extern int __debug; /* XXX I know I'm gonna regret __debug ... */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tdir.c
============================================================================
$ cvs diff -u -r2.13 -r2.14 tdir.c
--- rpm/rpmio/tdir.c 9 Feb 2008 20:44:49 -0000 2.13
+++ rpm/rpmio/tdir.c 9 Feb 2008 23:12:33 -0000 2.14
@@ -5,8 +5,6 @@
#include "debug.h"
-static int _debug = 0;
-
static void printDir(struct dirent * dp, int nentry)
{
if (rpmIsDebug()) {
@@ -52,7 +50,6 @@
}
static struct poptOption optionsTable[] = {
- { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
N_("Common options for all rpmio executables:"),
@@ -71,7 +68,7 @@
const char * dn;
int rc;
- if (_debug) {
+ if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tfts.c
============================================================================
$ cvs diff -u -r2.20 -r2.21 tfts.c
--- rpm/rpmio/tfts.c 9 Feb 2008 20:44:49 -0000 2.20
+++ rpm/rpmio/tfts.c 9 Feb 2008 23:12:33 -0000 2.21
@@ -21,8 +21,6 @@
static int mgNMatches = 0;
static int mgNFails = 0;
-static int _fts_debug = 0;
-
extern int _dav_nooptions;
static int ndirs = 0;
@@ -182,7 +180,7 @@
if (rpmioFtsOpts == 0)
rpmioFtsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
- if (_fts_debug) {
+ if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tget.c
============================================================================
$ cvs diff -u -r1.15 -r1.16 tget.c
--- rpm/rpmio/tget.c 9 Feb 2008 20:44:49 -0000 1.15
+++ rpm/rpmio/tget.c 9 Feb 2008 23:12:33 -0000 1.16
@@ -5,8 +5,6 @@
#include "debug.h"
-static int _debug = 0;
-
static char * rpmPermsString(mode_t st_mode)
{
char *perms = xstrdup("----------");
@@ -119,8 +117,6 @@
}
static struct poptOption optionsTable[] = {
- { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
-
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
N_("Common options for all rpmio executables:"),
@@ -139,7 +135,7 @@
const char * fn;
int rc;
- if (_debug) {
+ if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tglob.c
============================================================================
$ cvs diff -u -r2.12 -r2.13 tglob.c
--- rpm/rpmio/tglob.c 9 Feb 2008 20:44:49 -0000 2.12
+++ rpm/rpmio/tglob.c 9 Feb 2008 23:12:33 -0000 2.13
@@ -5,8 +5,6 @@
#include "debug.h"
-static int _debug = 0;
-
static int my_Glob_error(const char *epath, int eerrno)
{
fprintf(stderr, "*** glob_error(%p,%d) path %s\n", epath, eerrno, epath);
@@ -42,7 +40,7 @@
}
static struct poptOption optionsTable[] = {
- { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
+ { "debug", 'd', POPT_ARG_VAL, &__debug, -1, NULL, NULL },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
N_("Common options for all rpmio executables:"),
@@ -61,7 +59,7 @@
const char * dn;
int rc;
- if (_debug) {
+ if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tmire.c
============================================================================
$ cvs diff -u -r1.2 -r1.3 tmire.c
--- rpm/rpmio/tmire.c 4 Feb 2008 21:24:23 -0000 1.2
+++ rpm/rpmio/tmire.c 9 Feb 2008 23:12:33 -0000 1.3
@@ -1,18 +1,16 @@
#include "system.h"
#define _MIRE_INTERNAL
-#include <rpmio.h>
-#include <rpmcb.h>
-#include <argv.h>
-#include <mire.h>
-#include <popt.h>
+#include <poptIO.h>
#include "debug.h"
-static int _debug = 0;
-
static struct poptOption optionsTable[] = {
- { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL },
+
+ { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
+ N_("Common options for all rpmio executables:"),
+ NULL },
+
POPT_AUTOHELP
POPT_TABLEEND
};
@@ -20,7 +18,7 @@
int
main(int argc, char *argv[])
{
- poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
+ poptContext optCon = rpmioInit(argc, argv, optionsTable);
miRE mire = NULL;
ARGV_t av = NULL;
int ac = 0;
@@ -28,23 +26,7 @@
int xx;
int i;
- while ((rc = poptGetNextOpt(optCon)) > 0) {
- const char * optArg = poptGetOptArg(optCon);
- optArg = _free(optArg);
- switch (rc) {
- case 'v':
- rpmIncreaseVerbosity();
- /*@switchbreak@*/ break;
- default:
- poptPrintUsage(optCon, stderr, 0);
- goto exit;
- /*@switchbreak@*/ break;
- }
- }
-
- if (_debug) {
- rpmIncreaseVerbosity();
- rpmIncreaseVerbosity();
+ if (__debug) {
_mire_debug = 1;
}
@@ .
Received on Sun Feb 10 00:12:34 2008