Quick 'n dirty macro evaluation.

CVS patchset: 3120
CVS date: 1999/07/02 20:56:04
This commit is contained in:
jbj 1999-07-02 20:56:04 +00:00
parent 5fc70a54d7
commit 56496ce088
3 changed files with 93 additions and 2 deletions

View File

@ -47,3 +47,6 @@ lclint:
tmacro: macro.c tmacro: macro.c
$(CC) $(CFLAGS) ${DEFS} -DDEBUG_MACROS ${INCLUDES} -o $@ $< $(CC) $(CFLAGS) ${DEFS} -DDEBUG_MACROS ${INCLUDES} -o $@ $<
rpmeval: macro.c
$(CC) $(CFLAGS) ${DEFS} -DDEBUG_MACROS -DEVAL_MACROS ${INCLUDES} -o $@ $<

View File

@ -1396,7 +1396,50 @@ rpmGetPath(const char *path, ...)
/* =============================================================== */ /* =============================================================== */
#ifdef DEBUG_MACROS #if defined(DEBUG_MACROS)
#if defined(EVAL_MACROS)
char *macrofiles = "/usr/lib/rpm/macros:/etc/rpm/macros";
int
main(int argc, char *argv[])
{
int c;
int errflg = 0;
extern char *optarg;
extern int optind;
while ((c = getopt(argc, argv, "f:")) != EOF ) {
switch (c) {
case 'f':
macrofiles = optarg;
break;
case '?':
default:
errflg++;
break;
}
}
if (errflg || optind >= argc) {
fprintf(stderr, "Usage: %s [-f macropath ] macro ...\n", argv[0]);
exit(1);
}
initMacros(NULL, macrofiles);
for ( ; optind < argc; optind++) {
const char *val;
val = rpmGetPath(argv[optind], NULL);
if (val) {
fprintf(stdout, "%s:\t%s\n", argv[optind], val);
xfree(val);
}
}
return 0;
}
#else /* !EVAL_MACROS */
char *macrofiles = "../macros:./testmacros"; char *macrofiles = "../macros:./testmacros";
char *testfile = "./test"; char *testfile = "./test";
@ -1430,4 +1473,5 @@ main(int argc, char *argv[])
return 0; return 0;
} }
#endif /* EVAL_MACROS */
#endif /* DEBUG_MACROS */ #endif /* DEBUG_MACROS */

View File

@ -1396,7 +1396,50 @@ rpmGetPath(const char *path, ...)
/* =============================================================== */ /* =============================================================== */
#ifdef DEBUG_MACROS #if defined(DEBUG_MACROS)
#if defined(EVAL_MACROS)
char *macrofiles = "/usr/lib/rpm/macros:/etc/rpm/macros";
int
main(int argc, char *argv[])
{
int c;
int errflg = 0;
extern char *optarg;
extern int optind;
while ((c = getopt(argc, argv, "f:")) != EOF ) {
switch (c) {
case 'f':
macrofiles = optarg;
break;
case '?':
default:
errflg++;
break;
}
}
if (errflg || optind >= argc) {
fprintf(stderr, "Usage: %s [-f macropath ] macro ...\n", argv[0]);
exit(1);
}
initMacros(NULL, macrofiles);
for ( ; optind < argc; optind++) {
const char *val;
val = rpmGetPath(argv[optind], NULL);
if (val) {
fprintf(stdout, "%s:\t%s\n", argv[optind], val);
xfree(val);
}
}
return 0;
}
#else /* !EVAL_MACROS */
char *macrofiles = "../macros:./testmacros"; char *macrofiles = "../macros:./testmacros";
char *testfile = "./test"; char *testfile = "./test";
@ -1430,4 +1473,5 @@ main(int argc, char *argv[])
return 0; return 0;
} }
#endif /* EVAL_MACROS */
#endif /* DEBUG_MACROS */ #endif /* DEBUG_MACROS */