From 6ab55413243ab347f4c3cc09c33ce329bc058b08 Mon Sep 17 00:00:00 2001 From: jbj Date: Mon, 28 Jan 2002 15:18:18 +0000 Subject: [PATCH] Avoid accidental collisions with POPT_BIT_SET for flags in popt tables. CVS patchset: 5277 CVS date: 2002/01/28 15:18:18 --- build/poptBT.c | 24 ++++++++++++------------ lib/poptI.c | 22 ++++++++++++++++------ lib/poptQV.c | 14 +++++++------- rpmqv.c | 24 ++++++++++++------------ 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/build/poptBT.c b/build/poptBT.c index 72f78c5..5b96194 100644 --- a/build/poptBT.c +++ b/build/poptBT.c @@ -15,18 +15,18 @@ /*@unchecked@*/ struct rpmBuildArguments_s rpmBTArgs; -#define POPT_USECATALOG 1000 -#define POPT_NOLANG 1001 -#define POPT_RMSOURCE 1002 -#define POPT_RMBUILD 1003 -#define POPT_BUILDROOT 1004 -#define POPT_TARGETPLATFORM 1007 -#define POPT_NOBUILD 1008 -#define POPT_SHORTCIRCUIT 1009 -#define POPT_RMSPEC 1010 -#define POPT_NODEPS 1011 -#define POPT_SIGN 1012 -#define POPT_FORCE 1013 +#define POPT_USECATALOG -1000 +#define POPT_NOLANG -1001 +#define POPT_RMSOURCE -1002 +#define POPT_RMBUILD -1003 +#define POPT_BUILDROOT -1004 +#define POPT_TARGETPLATFORM -1007 +#define POPT_NOBUILD -1008 +#define POPT_SHORTCIRCUIT -1009 +#define POPT_RMSPEC -1010 +#define POPT_NODEPS -1011 +#define POPT_SIGN -1012 +#define POPT_FORCE -1013 #define POPT_REBUILD 0x4220 #define POPT_RECOMPILE 0x4320 diff --git a/lib/poptI.c b/lib/poptI.c index 69c9018..d2f4d23 100644 --- a/lib/poptI.c +++ b/lib/poptI.c @@ -16,9 +16,9 @@ extern time_t get_date(const char * p, void * now); /* XXX expedient lies */ /*@unchecked@*/ struct rpmInstallArguments_s rpmIArgs; -#define POPT_RELOCATE 1016 -#define POPT_EXCLUDEPATH 1019 -#define POPT_ROLLBACK 1024 +#define POPT_RELOCATE -1016 +#define POPT_EXCLUDEPATH -1019 +#define POPT_ROLLBACK -1024 /*@exits@*/ static void argerror(const char * desc) /*@*/ @@ -40,7 +40,13 @@ static void installArgCallback( /*@unused@*/ poptContext con, { struct rpmInstallArguments_s * ia = &rpmIArgs; +#if 0 +fprintf(stderr, "*** opt %s %c info 0x%x arg %p val 0x%x arg %p %s\n", opt->longName, opt->shortName, opt->argInfo, opt->arg, opt->val, arg, arg); +#endif + + /* XXX avoid accidental collisions with POPT_BIT_SET for flags */ /*@-branchstate@*/ + if (opt->arg == NULL) switch (opt->val) { case POPT_EXCLUDEPATH: if (arg == NULL || *arg != '/') @@ -74,11 +80,15 @@ static void installArgCallback( /*@unused@*/ poptContext con, } break; case POPT_ROLLBACK: { time_t tid; + if (arg == NULL) + argerror(_("rollback takes a time/date stamp argument")); + /*@-moduncon@*/ tid = get_date(arg, NULL); /*@=moduncon@*/ - if (tid == (time_t)-1) - argerror(_("malformed rollback time")); + + if (tid == (time_t)-1 || tid == (time_t)0) + argerror(_("malformed rollback time/date stamp argument")); ia->rbtid = tid; } break; } @@ -211,7 +221,7 @@ struct poptOption rpmInstallPoptTable[] = { &rpmIArgs.probFilter, RPMPROB_FILTER_REPLACEPKG, N_("reinstall if the package is already present"), NULL}, { "rollback", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN, 0, POPT_ROLLBACK, - N_("deinstall new package(s), reinstall old package(s), back to date"), + N_("deinstall new, reinstall old, package(s), back to "), N_("") }, { "test", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_TEST, N_("don't install, but tell if it would work or not"), NULL}, diff --git a/lib/poptQV.c b/lib/poptQV.c index 2a47171..a896725 100644 --- a/lib/poptQV.c +++ b/lib/poptQV.c @@ -16,13 +16,13 @@ struct rpmQVKArguments_s rpmQVKArgs; /*@unchecked@*/ int specedit = 0; -#define POPT_QUERYFORMAT 1000 -#define POPT_WHATREQUIRES 1001 -#define POPT_WHATPROVIDES 1002 -#define POPT_QUERYBYNUMBER 1003 -#define POPT_TRIGGEREDBY 1004 -#define POPT_DUMP 1005 -#define POPT_SPECFILE 1006 +#define POPT_QUERYFORMAT -1000 +#define POPT_WHATREQUIRES -1001 +#define POPT_WHATPROVIDES -1002 +#define POPT_QUERYBYNUMBER -1003 +#define POPT_TRIGGEREDBY -1004 +#define POPT_DUMP -1005 +#define POPT_SPECFILE -1006 /* ========== Query/Verify/Signature source args */ static void rpmQVSourceArgCallback( /*@unused@*/ poptContext con, diff --git a/rpmqv.c b/rpmqv.c index 8f0cd88..8fe95aa 100755 --- a/rpmqv.c +++ b/rpmqv.c @@ -13,15 +13,15 @@ #include #include -#define POPT_NODEPS 1025 -#define POPT_FORCE 1026 -#define POPT_NOMD5 1027 -#define POPT_NOSCRIPTS 1028 +#define POPT_NODEPS -1025 +#define POPT_FORCE -1026 +#define POPT_NOMD5 -1027 +#define POPT_NOSCRIPTS -1028 #ifdef IAM_RPMBT #include "build.h" -#define GETOPT_REBUILD 1003 -#define GETOPT_RECOMPILE 1004 +#define GETOPT_REBUILD -1003 +#define GETOPT_RECOMPILE -1004 #endif #if defined(IAM_RPMBT) || defined(IAM_RPMK) @@ -30,12 +30,12 @@ #include "debug.h" -#define GETOPT_DBPATH 1010 -#define GETOPT_SHOWRC 1018 -#define GETOPT_DEFINEMACRO 1020 -#define GETOPT_EVALMACRO 1021 +#define GETOPT_DBPATH -1010 +#define GETOPT_SHOWRC -1018 +#define GETOPT_DEFINEMACRO -1020 +#define GETOPT_EVALMACRO -1021 #ifdef NOTYET -#define GETOPT_RCFILE 1022 +#define GETOPT_RCFILE -1022 #endif enum modes { @@ -1033,7 +1033,7 @@ int main(int argc, const char ** argv) #ifdef IAM_RPMEIU case MODE_ERASE: if (!poptPeekArg(optCon)) - argerror(_("no packages given for uninstall")); + argerror(_("no packages given for erase")); if (ia->noDeps) ia->eraseInterfaceFlags |= UNINSTALL_NODEPS; -- 2.7.4