diff --git a/popt-1.13-alias-equal-arg.patch b/popt-1.13-alias-equal-arg.patch new file mode 100644 index 0000000..64a5460 --- /dev/null +++ b/popt-1.13-alias-equal-arg.patch @@ -0,0 +1,121 @@ +diff -up popt-1.13/popt.c.alias-equal-arg popt-1.13/popt.c +--- popt-1.13/popt.c.alias-equal-arg 2007-12-11 20:04:06.000000000 +0200 ++++ popt-1.13/popt.c 2011-06-14 11:57:21.000000000 +0300 +@@ -308,8 +308,9 @@ static int handleExec(/*@special@*/ popt + + /* Only one of longName, shortName may be set at a time */ + static int handleAlias(/*@special@*/ poptContext con, +- /*@null@*/ const char * longName, char shortName, +- /*@exposed@*/ /*@null@*/ const char * nextCharArg) ++ /*@null@*/ const char * longName, size_t longNameLen, ++ char shortName, ++ /*@exposed@*/ /*@null@*/ const char * nextArg) + /*@uses con->aliases, con->numAliases, con->optionStack, con->os, + con->os->currAlias, con->os->currAlias->option.longName @*/ + /*@modifies con @*/ +@@ -319,9 +320,11 @@ static int handleAlias(/*@special@*/ pop + int i; + + if (item) { +- if (longName && (item->option.longName && +- !strcmp(longName, item->option.longName))) ++ if (longName && item->option.longName ++ && longNameLen == strlen(item->option.longName) ++ && !strncmp(longName, item->option.longName, longNameLen)) + return 0; ++ else + if (shortName && shortName == item->option.shortName) + return 0; + } +@@ -331,10 +334,14 @@ static int handleAlias(/*@special@*/ pop + + for (i = con->numAliases - 1; i >= 0; i--) { + item = con->aliases + i; +- if (longName && !(item->option.longName && +- !strcmp(longName, item->option.longName))) +- continue; +- else if (shortName != item->option.shortName) ++ if (longName) { ++ if (item->option.longName == NULL) ++ continue; ++ if (longNameLen != strlen(item->option.longName)) ++ continue; ++ if (strncmp(longName, item->option.longName, longNameLen)) ++ continue; ++ } else if (shortName != item->option.shortName) + continue; + break; + } +@@ -343,8 +350,8 @@ static int handleAlias(/*@special@*/ pop + if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH) + return POPT_ERROR_OPTSTOODEEP; + +- if (nextCharArg && *nextCharArg) +- con->os->nextCharArg = nextCharArg; ++ if (longName == NULL && nextArg && *nextArg) ++ con->os->nextCharArg = nextArg; + + con->os++; + con->os->next = 0; +@@ -352,8 +359,20 @@ static int handleAlias(/*@special@*/ pop + con->os->nextArg = NULL; + con->os->nextCharArg = NULL; + con->os->currAlias = con->aliases + i; +- rc = poptDupArgv(con->os->currAlias->argc, con->os->currAlias->argv, +- &con->os->argc, &con->os->argv); ++ { const char ** av; ++ int ac = con->os->currAlias->argc; ++ /* Append --foo=bar arg to alias argv array (if present). */ ++ if (longName && nextArg && *nextArg) { ++ int i; ++ av = alloca((ac + 1 + 1) * sizeof(*av)); ++ for (i = 0; i < ac; i++) ++ av[i] = con->os->currAlias->argv[i]; ++ av[ac++] = nextArg; ++ av[ac] = NULL; ++ } else ++ av = con->os->currAlias->argv; ++ rc = poptDupArgv(ac, av, &con->os->argc, &con->os->argv); ++ } + con->os->argb = NULL; + + return (rc ? rc : 1); +@@ -795,13 +814,6 @@ int poptGetNextOpt(poptContext con) + else + singleDash = 1; + +- /* XXX aliases with arg substitution need "--alias=arg" */ +- if (handleAlias(con, optString, '\0', NULL)) +- continue; +- +- if (handleExec(con, optString, '\0')) +- continue; +- + /* Check for "--long=arg" option. */ + for (oe = optString; *oe && *oe != '='; oe++) + {}; +@@ -809,6 +821,15 @@ int poptGetNextOpt(poptContext con) + if (*oe == '=') + longArg = oe + 1; + ++ /* XXX aliases with arg substitution need "--alias=arg" */ ++ if (handleAlias(con, optString, optStringLen, '\0', longArg)) { ++ longArg = NULL; ++ continue; ++ } ++ ++ if (handleExec(con, optString, '\0')) ++ continue; ++ + opt = findOption(con->options, optString, optStringLen, '\0', &cb, &cbData, + singleDash); + if (!opt && !singleDash) +@@ -834,7 +855,7 @@ int poptGetNextOpt(poptContext con) + + con->os->nextCharArg = NULL; + +- if (handleAlias(con, NULL, *origOptString, origOptString + 1)) ++ if (handleAlias(con, NULL, 0, *origOptString, origOptString + 1)) + continue; + + if (handleExec(con, NULL, *origOptString)) { diff --git a/popt.spec b/popt.spec index 55a703e..864f6d2 100644 --- a/popt.spec +++ b/popt.spec @@ -1,13 +1,14 @@ Summary: C library for parsing command line parameters Name: popt Version: 1.13 -Release: 8%{?dist} +Release: 9%{?dist} License: MIT Group: System Environment/Libraries URL: http://www.rpm5.org/ Source: http://www.rpm5.org/files/%{name}/%{name}-%{version}.tar.gz Patch0: popt-1.13-multilib.patch Patch1: popt-1.13-popt_fprintf.patch +Patch2: popt-1.13-alias-equal-arg.patch BuildRequires: gettext, doxygen, graphviz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -44,6 +45,7 @@ Install it if you need to link statically with libpopt. %setup -q %patch0 -p1 -b .multilib %patch1 -p1 -b .popt_fprintf +%patch2 -p1 -b .alias-equal-arg %build %configure --libdir=/%{_lib} @@ -92,6 +94,9 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libpopt.a %changelog +* Tue Jun 14 2011 Panu Matilainen +- Backport upstream patch to fix --opt= syntax for aliases (#293531) + * Wed Feb 09 2011 Fedora Release Engineering - 1.13-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild