summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-01-09 09:28:09 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-01-09 09:28:09 +0200
commit4906b9c55e97a9db8f5db4691a09253ddfadd976 (patch)
tree14fde700c584b01b5bccfcf5c8be4f8b9bc521cf
parentce9ba5a7da2a53795f7fa71a593c645debf8f74a (diff)
downloadrpm-4906b9c55e97a9db8f5db4691a09253ddfadd976.tar.gz
rpm-4906b9c55e97a9db8f5db4691a09253ddfadd976.tar.bz2
rpm-4906b9c55e97a9db8f5db4691a09253ddfadd976.zip
Convert '-' to '_' within --define macro names (#124995)
Patch derived from rpm5.org of Jeff Johnson
-rw-r--r--lib/poptALL.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/poptALL.c b/lib/poptALL.c
index 01267e564..02c243295 100644
--- a/lib/poptALL.c
+++ b/lib/poptALL.c
@@ -9,6 +9,7 @@ const char *__progname;
#include <rpm/rpmcli.h>
#include <rpm/rpmgi.h>
#include <rpm/rpmlog.h>
+#include <rpm/rpmstring.h>
#include "debug.h"
@@ -119,13 +120,23 @@ static void rpmcliAllArgCallback( poptContext con,
(void) rpmDefineMacro(NULL, arg, RMIL_CMDLINE);
break;
case 'D':
+ { char *s, *t;
+ /* XXX Convert '-' in macro name to underscore, skip leading %. */
+ s = t = xstrdup(arg);
+ while (*t && !xisspace(*t)) {
+ if (*t == '-') *t = '_';
+ t++;
+ }
+ if (*t == '%') t++;
/* XXX Predefine macro if not initialized yet. */
if (rpmcliInitialized < 0)
- (void) rpmDefineMacro(NULL, arg, RMIL_CMDLINE);
+ (void) rpmDefineMacro(NULL, t, RMIL_CMDLINE);
rpmcliConfigured();
- (void) rpmDefineMacro(NULL, arg, RMIL_CMDLINE);
- (void) rpmDefineMacro(rpmCLIMacroContext, arg, RMIL_CMDLINE);
+ (void) rpmDefineMacro(NULL, t, RMIL_CMDLINE);
+ (void) rpmDefineMacro(rpmCLIMacroContext, t, RMIL_CMDLINE);
+ s = _free(s);
break;
+ }
case 'E':
rpmcliConfigured();
{ char *val = rpmExpand(arg, NULL);