RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/rpmio/ Makefile.am mire.c

From: Jeff Johnson <jbj@rpm5.org>
Date: Sun 10 Feb 2008 - 02:30:57 CET
Message-Id: <20080210013057.C1DEB34848D@rpm5.org>
  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 02:30:57
  Branch: HEAD                             Handle: 2008021001305700

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               Makefile.am mire.c

  Log:
    - rpmio: add tmire to noinst_PROGRAMS.
    - rpmio: add --regex/--pcre/--fnmatch/--strcmp tmire match options

  Summary:
    Revision    Changes     Path
    1.2170      +2  -0      rpm/CHANGES
    1.127       +2  -2      rpm/rpmio/Makefile.am
    1.11        +34 -37     rpm/rpmio/mire.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2169 -r1.2170 CHANGES
  --- rpm/CHANGES	9 Feb 2008 23:12:33 -0000	1.2169
  +++ rpm/CHANGES	10 Feb 2008 01:30:57 -0000	1.2170
  @@ -1,4 +1,6 @@
   5.0.0 -> 5.1a1:
  +    - jbj: rpmio: add tmire to noinst_PROGRAMS.
  +    - jbj: rpmio: add --regex/--pcre/--fnmatch/--strcmp tmire match options
       - 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.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.126 -r1.127 Makefile.am
  --- rpm/rpmio/Makefile.am	9 Feb 2008 20:12:20 -0000	1.126
  +++ rpm/rpmio/Makefile.am	10 Feb 2008 01:30:57 -0000	1.127
  @@ -6,9 +6,9 @@
   
   EXTRA_DIST = gengpg.sh thkp.c thtml.c tinv.c tkey.c tput.c trpmio.c lookup3.c tpw.c librpmio.vers
   
  -EXTRA_PROGRAMS = thkp thtml tinv tkey tmacro tmagic tmire tput tpw trpmio tsw dumpasn1 lookup3
  +EXTRA_PROGRAMS = thkp thtml tinv tkey tmacro tmagic tput tpw trpmio tsw dumpasn1 lookup3
   
  -noinst_PROGRAMS = tdir tfts tget tglob
  +noinst_PROGRAMS = tdir tfts tget tglob tmire
   noinst_SCRIPTS = testit.sh
   
   TESTS = testit.sh
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/mire.c
  ============================================================================
  $ cvs diff -u -r1.10 -r1.11 mire.c
  --- rpm/rpmio/mire.c	9 Feb 2008 23:12:33 -0000	1.10
  +++ rpm/rpmio/mire.c	10 Feb 2008 01:30:57 -0000	1.11
  @@ -216,14 +216,25 @@
   
   #if defined(STANDALONE)
   
  -#include <rpmcb.h>
  -#include <argv.h>
  -#include <popt.h>
  +#include <poptIO.h>
   
  -static int _debug = 0;
  +static rpmMireMode mireMode = RPMMIRE_REGEX;
   
   static struct poptOption optionsTable[] = {
  - { "debug", 'd', POPT_ARG_VAL,	&_debug, -1,		NULL, NULL },
  +
  + { "strcmp", '\0', POPT_ARG_VAL,	&mireMode, RPMMIRE_STRCMP,
  +	N_("use strcmp matching"), NULL},
  + { "regex", '\0', POPT_ARG_VAL,		&mireMode, RPMMIRE_REGEX,
  +	N_("use regex matching"), NULL},
  + { "fnmatch", '\0', POPT_ARG_VAL,	&mireMode, RPMMIRE_GLOB,
  +	N_("use fnmatch matching"), NULL},
  + { "pcre", '\0', POPT_ARG_VAL,		&mireMode, RPMMIRE_PCRE,
  +	N_("use pcre matching"), NULL},
  +
  + { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
  +	N_("Common options for all rpmio executables:"),
  +	NULL },
  +
     POPT_AUTOHELP
     POPT_TABLEEND
   };
  @@ -231,62 +242,48 @@
   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;
  -    int rc;
  +    int rc = 1;
       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;
       }
   
       av = poptGetArgs(optCon);
  -    ac = argvCount(av);
  -    if (ac != 1) {
  -	poptPrintUsage(optCon, stderr, 0);
  +    if ((ac = argvCount(av)) != 1)
   	goto exit;
  -    }
   
  -    mire = mireNew(RPMMIRE_REGEX, 0);
  -    if ((xx = mireRegcomp(mire, argv[1])) != 0)
  +    mire = mireNew(mireMode, 0);
  +    if ((rc = mireRegcomp(mire, av[0])) != 0)
   	goto exit;
       
  -    xx = argvFgets(&av, NULL);
  -    ac = argvCount(av);
  +    av = NULL;
  +    if ((rc = argvFgets(&av, NULL)) != 0)
  +	goto exit;
   
  +    rc = 1;	/* assume nomatch failure. */
  +    ac = argvCount(av);
  +    if (av && *av)
       for (i = 0; i < ac; i++) {
   	xx = mireRegexec(mire, av[i]);
  -	if (xx == 0)
  +	if (xx == 0) {
   	    fprintf(stdout, "%s\n", av[i]);
  +	    rc = 0;
  +	}
       }
  +    av = argvFree(av);
   
   exit:
       mire = mireFree(mire);
   
  -    av = argvFree(av);
  -
  -    optCon = poptFreeContext(optCon);
  +    optCon = rpmioFini(optCon);
   
  -    return 0;
  +    return rc;
   }
   
   #endif	/* STANDALONE */
  @@ .
Received on Sun Feb 10 02:30:57 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.