summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2003-12-22 03:27:38 +0000
committerjbj <devnull@localhost>2003-12-22 03:27:38 +0000
commitfe3f3a6567be0ac2677eae31a265da19b81004d2 (patch)
tree63f2918b56e102e1830abc999d5db11e3214cfe7
parent17bf716992d20285df89df043e560908b699e863 (diff)
downloadrpm-fe3f3a6567be0ac2677eae31a265da19b81004d2.tar.gz
rpm-fe3f3a6567be0ac2677eae31a265da19b81004d2.tar.bz2
rpm-fe3f3a6567be0ac2677eae31a265da19b81004d2.zip
Apply regex patterns to args.
CVS patchset: 6991 CVS date: 2003/12/22 03:27:38
-rw-r--r--lib/tre.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/tre.c b/lib/tre.c
index 4a392912b..eda4181b5 100644
--- a/lib/tre.c
+++ b/lib/tre.c
@@ -11,7 +11,6 @@ static int add_assoc = 1;
/*
* Command-line options.
*/
-static int debug = 0;
static int change = 1;
static int quiet = 0;
#define QPRINTF(args...) do { if (!quiet) printf(args); } while (0)
@@ -22,7 +21,7 @@ static char *rootpath = NULL;
static int rootpathlen = 0;
static struct poptOption optionsTable[] = {
- { "debug", 'd', POPT_ARG_VAL, &debug, 1,
+ { "debug", 'd', POPT_ARG_VAL, &_rpmsx_debug, -1,
N_("show what specification matched each file"), NULL },
{ "nochange", 'n', POPT_ARG_VAL, &change, 0,
N_("do not change any file labels"), NULL },
@@ -45,6 +44,7 @@ int main(int argc, char **argv)
{
poptContext optCon;
const char ** av;
+ const char * arg;
rpmsx sx;
int ec = EXIT_FAILURE; /* assume failure. */
int rc;
@@ -100,20 +100,28 @@ int main(int argc, char **argv)
av = poptGetArgs(optCon);
- _rpmsx_debug = -1;
/* Parse the specification file. */
sx = rpmsxNew(NULL);
- sx = rpmsxInit(sx, 1);
- if (sx != NULL)
- while ((i = rpmsxNext(sx)) >= 0) {
- const char * pattern = rpmsxPattern(sx);
- const char * type = rpmsxType(sx);
- const char * context = rpmsxContext(sx);
+ if (_rpmsx_debug) {
+ sx = rpmsxInit(sx, 1);
+ if (sx != NULL)
+ while ((i = rpmsxNext(sx)) >= 0) {
+ const char * pattern = rpmsxPattern(sx);
+ const char * type = rpmsxType(sx);
+ const char * context = rpmsxContext(sx);
- fprintf(stderr, "%5d: %s\t%s\t%s\n", i,
+ fprintf(stderr, "%5d: %s\t%s\t%s\n", i,
pattern, (type ? type : ""), context);
+ }
}
+
+ if (av != NULL)
+ while ((arg = *av++) != NULL) {
+ const char * context = rpmsxFContext(sx, arg, S_IFREG);
+ fprintf(stderr, "%s: %s\n", arg, context);
+ }
+
sx = rpmsxFree(sx);
/*