public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Peter Jones <pjones@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/popt] pmatilai-v6: Make it use %%autosetup -S git and fix a memory leak
Date: Mon, 23 Nov 2026 09:56:10 GMT	[thread overview]
Message-ID: <179542777071.1.17747927389683446594.rpms-popt-befacb44b02b@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/popt
            Branch : pmatilai-v6
            Commit : befacb44b02b0f8bf20adbebb95c4cfe0efdb6a1
            Author : Peter Jones <pjones@redhat.com>
            Date   : 2017-07-28T16:43:24-04:00
            Stats  : +433/-286 in 11 file(s)
            URL    : https://src.fedoraproject.org/rpms/popt/c/befacb44b02b0f8bf20adbebb95c4cfe0efdb6a1?branch=pmatilai-v6

            Log:
            Make it use %%autosetup -S git and fix a memory leak

Signed-off-by: Peter Jones <pjones@redhat.com>

---
diff --git a/.gitignore b/.gitignore
index 98c85f3..c09bba9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
-/popt-1.??.tar.gz
+/popt-*.tar
+/popt-*.tar.*
+/*/
+/.build*.log
+/*.rpm

diff --git a/0001-Update-pkgconfig-directory.patch b/0001-Update-pkgconfig-directory.patch
new file mode 100644
index 0000000..5ac7020
--- /dev/null
+++ b/0001-Update-pkgconfig-directory.patch
@@ -0,0 +1,47 @@
+From cac87554c89d55dd7c082ad4b234314e72d73a22 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Fri, 28 Jul 2017 15:16:17 -0400
+Subject: [PATCH 1/4] Update pkgconfig directory
+
+Patch by Robert Scheck <robert@fedoraproject.org> for popt <= 1.16 which changes
+$(pkgconfigdir) on 64 bit systems from /usr/lib/pkgconfig to /usr/lib64/pkgconfig.
+Using $(libdir)/pkgconfig rather $(prefix)/lib/pkgconfig seems to be common when
+searching on the Internet. This patch however is not really compliant with Fedora
+/%{_lib} vs. %{_libdir} handling before the UsrMove with Fedora 17. Alternatively
+--with-pkgconfigdir or similar should be implemented.
+
+This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0265.html
+---
+ Makefile.am | 2 +-
+ Makefile.in | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index d7aec9e..8cc6220 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -47,7 +47,7 @@ usrlib_LTLIBRARIES = libpopt.la
+ libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
+ libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@
+ 
+-pkgconfigdir = $(prefix)/lib/pkgconfig
++pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = popt.pc
+ 
+ if HAVE_LD_VERSION_SCRIPT
+diff --git a/Makefile.in b/Makefile.in
+index 2e6890d..c331e20 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -370,7 +370,7 @@ usrlib_LTLIBRARIES = libpopt.la
+ libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
+ libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@ \
+ 	$(am__append_1)
+-pkgconfigdir = $(prefix)/lib/pkgconfig
++pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = popt.pc
+ man_MANS = popt.3
+ BUILT_SOURCES = popt.pc # popt.lcd
+-- 
+2.13.3
+

diff --git a/0002-kludge-poptBadOption-to-return-value-on-exec-alias-f.patch b/0002-kludge-poptBadOption-to-return-value-on-exec-alias-f.patch
new file mode 100644
index 0000000..857950c
--- /dev/null
+++ b/0002-kludge-poptBadOption-to-return-value-on-exec-alias-f.patch
@@ -0,0 +1,89 @@
+From 61cc5004fb8e14464ae0afcffc6e2ee852b45a41 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Fri, 28 Jul 2017 15:17:22 -0400
+Subject: [PATCH 2/4] kludge poptBadOption() to return value on exec alias
+ failure
+
+Patch by Panu Matilainen <pmatilai@redhat.com> for popt <= 1.16 which kludges
+poptBadOption() to return something semi-meaningful on exec alias fail:
+
+- poptBadOption() is totally unaware of exec alias failures, and will return
+  either the first argument or last option, giving wonderfully misleading error
+  messages (#697435, #710267).
+- Remember execvp() first argument on failure and return that from
+  poptBadOption() if present to give the user a reasonable clue what exactly
+  went wrong.
+
+This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0264.html
+---
+ popt.c    | 19 +++++++++++++++----
+ poptint.h |  1 +
+ 2 files changed, 16 insertions(+), 4 deletions(-)
+
+diff --git a/popt.c b/popt.c
+index a1c38a5..1a53f40 100644
+--- a/popt.c
++++ b/popt.c
+@@ -192,6 +192,7 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv,
+     con->flags = flags;
+     con->execs = NULL;
+     con->numExecs = 0;
++    con->execFail = NULL;
+     con->finalArgvAlloced = argc * 2;
+     con->finalArgv = calloc( (size_t)con->finalArgvAlloced, sizeof(*con->finalArgv) );
+     con->execAbsolute = 1;
+@@ -236,6 +237,7 @@ void poptResetContext(poptContext con)
+     con->nextLeftover = 0;
+     con->restLeftover = 0;
+     con->doExec = NULL;
++    con->execFail = _free(con->execFail);
+ 
+     if (con->finalArgv != NULL)
+     for (i = 0; i < con->finalArgvCount; i++) {
+@@ -564,6 +566,7 @@ if (_popt_debug)
+ /*@-nullstate@*/
+     rc = execvp(argv[0], (char *const *)argv);
+ /*@=nullstate@*/
++    con->execFail = xstrdup(argv[0]);
+ 
+ exit:
+     if (argv) {
+@@ -1697,11 +1700,19 @@ int poptAddItem(poptContext con, poptItem newItem, int flags)
+ const char * poptBadOption(poptContext con, unsigned int flags)
+ {
+     struct optionStackEntry * os = NULL;
++    const char *badOpt = NULL;
++
++    if (con != NULL) {
++       /* Stupid hack to return something semi-meaningful from exec failure */
++       if (con->execFail) {
++           badOpt = con->execFail;
++       } else {
++           os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
++           badOpt = os->argv[os->next - 1];
++       }
++    }
+ 
+-    if (con != NULL)
+-	os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+-
+-    return (os != NULL && os->argv != NULL ? os->argv[os->next - 1] : NULL);
++    return badOpt;
+ }
+ 
+ const char * poptStrerror(const int error)
+diff --git a/poptint.h b/poptint.h
+index 80cbaca..0fcb26e 100644
+--- a/poptint.h
++++ b/poptint.h
+@@ -132,6 +132,7 @@ struct poptContext_s {
+ /*@owned@*/ /*@null@*/
+     poptItem execs;
+     int numExecs;
++    char * execFail;
+ /*@only@*/ /*@null@*/
+     poptArgv finalArgv;
+     int finalArgvCount;
+-- 
+2.13.3
+

diff --git a/0003-Fix-some-spelling-mistakes-in-the-man-page.patch b/0003-Fix-some-spelling-mistakes-in-the-man-page.patch
new file mode 100644
index 0000000..2bcee3e
--- /dev/null
+++ b/0003-Fix-some-spelling-mistakes-in-the-man-page.patch
@@ -0,0 +1,79 @@
+From abc7cc36f265e2fff199eca94e8cbf1cd0a28ab5 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Fri, 28 Jul 2017 15:18:15 -0400
+Subject: [PATCH 3/4] Fix some spelling mistakes in the man page.
+
+Patch by John Bradshaw <john@johnbradshaw.org> for popt <= 1.16 which fixes some
+spelling mistakes in popt man page.
+
+See https://bugzilla.redhat.com/show_bug.cgi?id=675567 for further details, please.
+This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0263.html
+
+Upstream already corrected some issues with http://rpm5.org/cvs/chngview?cn=16879
+and solved the last ones with http://rpm5.org/cvs/chngview?cn=17375 now. Thus popt
+1.17 should make this patch completely obsolete.
+---
+ popt.3 | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/popt.3 b/popt.3
+index 5d5a556..ca64a92 100644
+--- a/popt.3
++++ b/popt.3
+@@ -200,7 +200,7 @@ arguments.
+ .RB "This macro includes another option table (via " POPT_ARG_INCLUDE_TABLE
+ ; see below) in the main one which provides the table entries for these
+ .RB "arguments. When " --usage " or " --help " are passed to programs which
+-use popt's automatical help, popt displays the appropriate message on 
++use popt's automatic help, popt displays the appropriate message on 
+ stderr as soon as it finds the option, and exits the program with a
+ return code of 0. If you want to use popt's automatic help generation in
+ a different way, you need to explicitly add the option entries to your programs 
+@@ -210,7 +210,7 @@ If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_DOC_HIDDEN\fR,
+ the argument will not be shown in help output.
+ .sp
+ If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_SHOW_DEFAULT\fR,
+-the inital value of the arg will be shown in help output.
++the initial value of the arg will be shown in help output.
+ .sp
+ The final structure in the table should have all the pointer values set
+ .RB "to " NULL " and all the arithmetic values set to 0, marking the "
+@@ -233,7 +233,7 @@ automatic help generation is being used, the \fIdescrip\fR field should
+ contain a overall description of the option table being included.
+ .sp
+ The other special option table entry type tells popt to call a function (a
+-callback) when any option in that table is found. This is especially usefull
++callback) when any option in that table is found. This is especially useful
+ when included option tables are being used, as the program which provides
+ the top-level option table doesn't need to be aware of the other options
+ which are provided by the included table. When a callback is set for
+@@ -473,7 +473,7 @@ A parsed string has a quotation mismatch (such as a single quotation
+ .TP
+ .B POPT_ERROR_BADNUMBER
+ A conversion from a string to a number (int or long) failed due
+-to the string containing nonnumeric characters. This occurs when
++to the string containing non-numeric characters. This occurs when
+ .BR poptGetNextOpt() " is processing an argument of type " 
+ .BR POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
+ .RB POPT_ARG_FLOAT ", or " POPT_ARG_DOUBLE "."  
+@@ -517,7 +517,7 @@ These two functions make popt error handling trivial for most
+ applications. When an error is detected from most of the functions, 
+ an error message is printed along with the error string from 
+ .BR poptStrerror() ". When an error occurs during argument parsing, "
+-code similiar to the following displays a useful error message:
++code similar to the following displays a useful error message:
+ .sp
+ .nf
+ fprintf(stderr, "%s: %s\\n",
+@@ -608,7 +608,7 @@ Although popt is usually used for parsing arguments already divided into
+ .RI "an " argv "-style array, some programs need to parse strings that "
+ are formatted identically to command lines. To facilitate this, popt 
+ provides a function that parses a string into an array of strings, 
+-using rules similiar to normal shell parsing.
++using rules similar to normal shell parsing.
+ .sp
+ .nf
+ .B "#include <popt.h>"
+-- 
+2.13.3
+

diff --git a/0004-Make-help-and-usage-translatable.patch b/0004-Make-help-and-usage-translatable.patch
new file mode 100644
index 0000000..29bf215
--- /dev/null
+++ b/0004-Make-help-and-usage-translatable.patch
@@ -0,0 +1,123 @@
+From 1d86877a865338e554aa2480f021da517a86954f Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Fri, 28 Jul 2017 15:18:46 -0400
+Subject: [PATCH 4/4] Make --help and --usage translatable.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Patch initially by Miloslav Trmač <mitr@redhat.com> and revised by Akira Tagoh
+<tagoh@redhat.com> for popt <= 1.16 which fixes the problem that help messages
+for --help and --usage seem not translatable. There already was some i18n support
+for autohelp in popt.c, but not in popthelp.c, where it actually matters.
+
+See https://bugzilla.redhat.com/show_bug.cgi?id=734434 for further details, please.
+
+This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0287.html
+---
+ popthelp.c | 39 ++++++++++++++++++++++++++-------------
+ 1 file changed, 26 insertions(+), 13 deletions(-)
+
+diff --git a/popthelp.c b/popthelp.c
+index 4859980..008fb2b 100644
+--- a/popthelp.c
++++ b/popthelp.c
+@@ -89,7 +89,7 @@ static struct poptOption poptHelpOptions2[] = {
+   { "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0,
+ 	N_("Display option defaults in message"), NULL },
+ #endif
+-  { "", '\0',	0, NULL, 0, N_("Terminate options"), NULL },
++  { NULL, '\0',	0, NULL, 0, N_("Terminate options"), NULL },
+     POPT_TABLEEND
+ } ;
+ 
+@@ -527,8 +527,11 @@ static size_t maxArgWidth(const struct poptOption * opt,
+     if (opt != NULL)
+     while (opt->longName || opt->shortName || opt->arg) {
+ 	if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
+-	    if (opt->arg)	/* XXX program error */
+-	        len = maxArgWidth(opt->arg, translation_domain);
++	    void * arg = opt->arg;
++	    /* XXX sick hack to preserve pretense of ABI. */
++	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
++	    if (arg)	/* XXX program error */
++		len = maxArgWidth(arg, translation_domain);
+ 	    if (len > max) max = len;
+ 	} else if (!F_ISSET(opt, DOC_HIDDEN)) {
+ 	    len = sizeof("  ")-1;
+@@ -619,19 +622,22 @@ static void singleTableHelp(poptContext con, FILE * fp,
+ 
+     if (table != NULL)
+     for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
++	void * arg = opt->arg;
+ 	if (poptArgType(opt) != POPT_ARG_INCLUDE_TABLE)
+ 	    continue;
+-	sub_transdom = getTableTranslationDomain(opt->arg);
++	/* XXX sick hack to preserve pretense of ABI. */
++	if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
++	    sub_transdom = getTableTranslationDomain(arg);
+ 	if (sub_transdom == NULL)
+ 	    sub_transdom = translation_domain;
+ 	    
+ 	/* If no popt aliases/execs, skip poptAliasOption processing. */
+-	if (opt->arg == poptAliasOptions && !(con->numAliases || con->numExecs))
++	if (arg == poptAliasOptions && !(con->numAliases || con->numExecs))
+ 	    continue;
+ 	if (opt->descrip)
+ 	    xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
+ 
+-	singleTableHelp(con, fp, opt->arg, columns, sub_transdom);
++	singleTableHelp(con, fp, arg, columns, sub_transdom);
+     }
+ }
+ 
+@@ -808,22 +814,25 @@ static size_t singleTableUsage(poptContext con, FILE * fp, columns_t columns,
+ 	    translation_domain = (const char *)opt->arg;
+ 	} else
+ 	if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
++	    void * arg = opt->arg;
++	    /* XXX sick hack to preserve pretense of ABI. */
++	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
+ 	    if (done) {
+ 		int i = 0;
+ 		if (done->opts != NULL)
+ 		for (i = 0; i < done->nopts; i++) {
+ 		    const void * that = done->opts[i];
+-		    if (that == NULL || that != opt->arg)
++		    if (that == NULL || that != arg)
+ 			/*@innercontinue@*/ continue;
+ 		    /*@innerbreak@*/ break;
+ 		}
+ 		/* Skip if this table has already been processed. */
+-		if (opt->arg == NULL || i < done->nopts)
++		if (arg == NULL || i < done->nopts)
+ 		    continue;
+ 		if (done->opts != NULL && done->nopts < done->maxopts)
+-		    done->opts[done->nopts++] = (const void *) opt->arg;
++		    done->opts[done->nopts++] = (const void *) arg;
+ 	    }
+-	    columns->cur = singleTableUsage(con, fp, columns, opt->arg,
++	    columns->cur = singleTableUsage(con, fp, columns, arg,
+ 			translation_domain, done);
+ 	} else
+ 	if ((opt->longName || opt->shortName) && !F_ISSET(opt, DOC_HIDDEN)) {
+@@ -864,9 +873,13 @@ static size_t showShortOptions(const struct poptOption * opt, FILE * fp,
+ 	    if (!strchr(s, opt->shortName) && isprint((int)opt->shortName)
+ 	     && opt->shortName != ' ')
+ 		s[strlen(s)] = opt->shortName;
+-	} else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE)
+-	    if (opt->arg)	/* XXX program error */
+-		len = showShortOptions(opt->arg, fp, s);
++	} else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
++	    void * arg = opt->arg;
++	    /* XXX sick hack to preserve pretense of ABI. */
++	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
++	    if (arg)	/* XXX program error */
++		len = showShortOptions(arg, fp, s);
++	}
+     } 
+ 
+     /* On return to top level, print the short options, return print length. */
+-- 
+2.13.3
+

diff --git a/0005-Don-t-leak-the-last-argument-expanded-by-expandNextA.patch b/0005-Don-t-leak-the-last-argument-expanded-by-expandNextA.patch
new file mode 100644
index 0000000..9e1b421
--- /dev/null
+++ b/0005-Don-t-leak-the-last-argument-expanded-by-expandNextA.patch
@@ -0,0 +1,79 @@
+From 6fcb24d785a2c2d626bac6999aee6b3ab368be15 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Fri, 28 Jul 2017 16:11:40 -0400
+Subject: [PATCH] Don't leak the last argument expanded by expandNextArg()
+
+While using POPT_ARG_ARGV, I noticed this in valgrind's leak checker:
+
+==1738== HEAP SUMMARY:
+==1738==     in use at exit: 8 bytes in 1 blocks
+==1738==   total heap usage: 94 allocs, 93 frees, 42,319 bytes allocated
+==1738==
+==1738== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
+==1738==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
+==1738==    by 0x4E3DF47: expandNextArg (popt.c:699)
+==1738==    by 0x4E3F681: poptGetNextOpt (popt.c:1501)
+==1738==    by 0x401F72: main (bingrep.c:433)
+==1738==
+==1738== LEAK SUMMARY:
+==1738==    definitely lost: 8 bytes in 1 blocks
+==1738==    indirectly lost: 0 bytes in 0 blocks
+==1738==      possibly lost: 0 bytes in 0 blocks
+==1738==    still reachable: 0 bytes in 0 blocks
+==1738==         suppressed: 0 bytes in 0 blocks
+
+My command line argument is a 7-byte string, and on first glance, it
+appears this is because both expandNextArg() and poptSaveString()
+duplicate the string.  The copy from poptSaveString() is the consuming
+program's responsibility to free, but the intermediate pointer is popt's
+responsibility.
+
+Upon further examination, it appears popt normally does free this
+string, but it only does it on the next entry to poptGetNextOpt(), and
+on cleanOSE() in the case if we're not already at the bottom of
+con->OptionStack.
+
+This patch modifies poptResetContext() to ensure we'll always attempt to
+free con->os->nextArg regardless of our position in the OptionStack, and
+removes the duplicate free of con->os->argb in poptFreeContext(), as
+it's called unconditionally by the poptResetContext() call on the
+previous line.
+
+This ensures that if poptGetNextOpt() isn't re-intered, poptFreeContext()
+will free the memory that was allocated.  Now valgrind tells me:
+
+==31734== HEAP SUMMARY:
+==31734==     in use at exit: 0 bytes in 0 blocks
+==31734==   total heap usage: 94 allocs, 94 frees, 42,319 bytes allocated
+==31734==
+==31734== All heap blocks were freed -- no leaks are possible
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ popt.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/popt.c b/popt.c
+index 1a53f40..72fbf5c 100644
+--- a/popt.c
++++ b/popt.c
+@@ -230,7 +230,7 @@ void poptResetContext(poptContext con)
+     con->os->argb = PBM_FREE(con->os->argb);
+     con->os->currAlias = NULL;
+     con->os->nextCharArg = NULL;
+-    con->os->nextArg = NULL;
++    con->os->nextArg = _free(con->os->nextArg);
+     con->os->next = 1;			/* skip argv[0] */
+ 
+     con->numLeftovers = 0;
+@@ -1617,7 +1617,6 @@ poptContext poptFreeContext(poptContext con)
+ {
+     if (con == NULL) return con;
+     poptResetContext(con);
+-    con->os->argb = _free(con->os->argb);
+ 
+     con->aliases = poptFreeItems(con->aliases, con->numAliases);
+     con->numAliases = 0;
+-- 
+2.13.3
+

diff --git a/popt-1.16-execfail.patch b/popt-1.16-execfail.patch
deleted file mode 100644
index f530fab..0000000
--- a/popt-1.16-execfail.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-Patch by Panu Matilainen <pmatilai@redhat.com> for popt <= 1.16 which kludges
-poptBadOption() to return something semi-meaningful on exec alias fail:
-
-- poptBadOption() is totally unaware of exec alias failures, and will return
-  either the first argument or last option, giving wonderfully misleading error
-  messages (#697435, #710267).
-- Remember execvp() first argument on failure and return that from
-  poptBadOption() if present to give the user a reasonable clue what exactly
-  went wrong.
-
-This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0264.html
-
---- popt-1.16/popt.c				2010-01-19 01:39:10.000000000 +0100
-+++ popt-1.16/popt.c.execfail			2013-11-24 15:50:06.000000000 +0100
-@@ -192,6 +192,7 @@
-     con->flags = flags;
-     con->execs = NULL;
-     con->numExecs = 0;
-+    con->execFail = NULL;
-     con->finalArgvAlloced = argc * 2;
-     con->finalArgv = calloc( (size_t)con->finalArgvAlloced, sizeof(*con->finalArgv) );
-     con->execAbsolute = 1;
-@@ -236,6 +237,7 @@
-     con->nextLeftover = 0;
-     con->restLeftover = 0;
-     con->doExec = NULL;
-+    con->execFail = _free(con->execFail);
- 
-     if (con->finalArgv != NULL)
-     for (i = 0; i < con->finalArgvCount; i++) {
-@@ -564,6 +566,7 @@
- /*@-nullstate@*/
-     rc = execvp(argv[0], (char *const *)argv);
- /*@=nullstate@*/
-+    con->execFail = xstrdup(argv[0]);
- 
- exit:
-     if (argv) {
-@@ -1697,11 +1700,19 @@
- const char * poptBadOption(poptContext con, unsigned int flags)
- {
-     struct optionStackEntry * os = NULL;
-+    const char *badOpt = NULL;
- 
--    if (con != NULL)
--	os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
-+    if (con != NULL) {
-+       /* Stupid hack to return something semi-meaningful from exec failure */
-+       if (con->execFail) {
-+           badOpt = con->execFail;
-+       } else {
-+           os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
-+           badOpt = os->argv[os->next - 1];
-+       }
-+    }
- 
--    return (os != NULL && os->argv != NULL ? os->argv[os->next - 1] : NULL);
-+    return badOpt;
- }
- 
- const char * poptStrerror(const int error)
---- popt-1.16/poptint.h				2010-01-19 01:39:10.000000000 +0100
-+++ popt-1.16/poptint.h.execfail		2013-11-24 15:50:38.000000000 +0100
-@@ -132,6 +132,7 @@
- /*@owned@*/ /*@null@*/
-     poptItem execs;
-     int numExecs;
-+    char * execFail;
- /*@only@*/ /*@null@*/
-     poptArgv finalArgv;
-     int finalArgvCount;

diff --git a/popt-1.16-help.patch b/popt-1.16-help.patch
deleted file mode 100644
index 85fd5ce..0000000
--- a/popt-1.16-help.patch
+++ /dev/null
@@ -1,107 +0,0 @@
-Patch initially by Miloslav Trmač <mitr@redhat.com> and revised by Akira Tagoh
-<tagoh@redhat.com> for popt <= 1.16 which fixes the problem that help messages
-for --help and --usage seem not translatable. There already was some i18n support
-for autohelp in popt.c, but not in popthelp.c, where it actually matters.
-
-See https://bugzilla.redhat.com/show_bug.cgi?id=734434 for further details, please.
-
-This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0287.html
-
---- popt-1.16/popthelp.c			2009-08-28 09:06:33.000000000 +0900
-+++ popt-1.16/popthelp.c.help			2014-01-08 12:04:00.888260244 +0900
-@@ -89,7 +89,7 @@ static struct poptOption poptHelpOptions
-   { "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0,
- 	N_("Display option defaults in message"), NULL },
- #endif
--  { "", '\0',	0, NULL, 0, N_("Terminate options"), NULL },
-+  { NULL, '\0',	0, NULL, 0, N_("Terminate options"), NULL },
-     POPT_TABLEEND
- } ;
- 
-@@ -527,8 +527,11 @@ static size_t maxArgWidth(const struct p
-     if (opt != NULL)
-     while (opt->longName || opt->shortName || opt->arg) {
- 	if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
--	    if (opt->arg)	/* XXX program error */
--	        len = maxArgWidth(opt->arg, translation_domain);
-+	    void * arg = opt->arg;
-+	    /* XXX sick hack to preserve pretense of ABI. */
-+	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
-+	    if (arg)	/* XXX program error */
-+		len = maxArgWidth(arg, translation_domain);
- 	    if (len > max) max = len;
- 	} else if (!F_ISSET(opt, DOC_HIDDEN)) {
- 	    len = sizeof("  ")-1;
-@@ -619,19 +622,22 @@ static void singleTableHelp(poptContext
- 
-     if (table != NULL)
-     for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
-+	void * arg = opt->arg;
- 	if (poptArgType(opt) != POPT_ARG_INCLUDE_TABLE)
- 	    continue;
--	sub_transdom = getTableTranslationDomain(opt->arg);
-+	/* XXX sick hack to preserve pretense of ABI. */
-+	if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
-+	    sub_transdom = getTableTranslationDomain(arg);
- 	if (sub_transdom == NULL)
- 	    sub_transdom = translation_domain;
- 	    
- 	/* If no popt aliases/execs, skip poptAliasOption processing. */
--	if (opt->arg == poptAliasOptions && !(con->numAliases || con->numExecs))
-+	if (arg == poptAliasOptions && !(con->numAliases || con->numExecs))
- 	    continue;
- 	if (opt->descrip)
- 	    xx = POPT_fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
- 
--	singleTableHelp(con, fp, opt->arg, columns, sub_transdom);
-+	singleTableHelp(con, fp, arg, columns, sub_transdom);
-     }
- }
- 
-@@ -808,22 +814,25 @@ static size_t singleTableUsage(poptConte
- 	    translation_domain = (const char *)opt->arg;
- 	} else
- 	if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
-+	    void * arg = opt->arg;
-+	    /* XXX sick hack to preserve pretense of ABI. */
-+	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
- 	    if (done) {
- 		int i = 0;
- 		if (done->opts != NULL)
- 		for (i = 0; i < done->nopts; i++) {
- 		    const void * that = done->opts[i];
--		    if (that == NULL || that != opt->arg)
-+		    if (that == NULL || that != arg)
- 			/*@innercontinue@*/ continue;
- 		    /*@innerbreak@*/ break;
- 		}
- 		/* Skip if this table has already been processed. */
--		if (opt->arg == NULL || i < done->nopts)
-+		if (arg == NULL || i < done->nopts)
- 		    continue;
- 		if (done->opts != NULL && done->nopts < done->maxopts)
--		    done->opts[done->nopts++] = (const void *) opt->arg;
-+		    done->opts[done->nopts++] = (const void *) arg;
- 	    }
--	    columns->cur = singleTableUsage(con, fp, columns, opt->arg,
-+	    columns->cur = singleTableUsage(con, fp, columns, arg,
- 			translation_domain, done);
- 	} else
- 	if ((opt->longName || opt->shortName) && !F_ISSET(opt, DOC_HIDDEN)) {
-@@ -864,9 +873,13 @@ static size_t showShortOptions(const str
- 	    if (!strchr(s, opt->shortName) && isprint((int)opt->shortName)
- 	     && opt->shortName != ' ')
- 		s[strlen(s)] = opt->shortName;
--	} else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE)
--	    if (opt->arg)	/* XXX program error */
--		len = showShortOptions(opt->arg, fp, s);
-+	} else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
-+	    void * arg = opt->arg;
-+	    /* XXX sick hack to preserve pretense of ABI. */
-+	    if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
-+	    if (arg)	/* XXX program error */
-+		len = showShortOptions(arg, fp, s);
-+	}
-     } 
- 
-     /* On return to top level, print the short options, return print length. */

diff --git a/popt-1.16-man-page.patch b/popt-1.16-man-page.patch
deleted file mode 100644
index bc8dafd..0000000
--- a/popt-1.16-man-page.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-Patch by John Bradshaw <john@johnbradshaw.org> for popt <= 1.16 which fixes some
-spelling mistakes in popt man page.
-
-See https://bugzilla.redhat.com/show_bug.cgi?id=675567 for further details, please.
-This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0263.html
-
-Upstream already corrected some issues with http://rpm5.org/cvs/chngview?cn=16879
-and solved the last ones with http://rpm5.org/cvs/chngview?cn=17375 now. Thus popt
-1.17 should make this patch completely obsolete.
-
---- popt-1.16/popt.3				2009-07-25 20:52:36.000000000 +0200
-+++ popt-1.16/popt.3.man-page			2013-11-24 15:59:58.000000000 +0100
-@@ -200,7 +200,7 @@
- .RB "This macro includes another option table (via " POPT_ARG_INCLUDE_TABLE
- ; see below) in the main one which provides the table entries for these
- .RB "arguments. When " --usage " or " --help " are passed to programs which
--use popt's automatical help, popt displays the appropriate message on 
-+use popt's automatic help, popt displays the appropriate message on 
- stderr as soon as it finds the option, and exits the program with a
- return code of 0. If you want to use popt's automatic help generation in
- a different way, you need to explicitly add the option entries to your programs 
-@@ -210,7 +210,7 @@
- the argument will not be shown in help output.
- .sp
- If the \fIargInfo\fR value is bitwise or'd with \fBPOPT_ARGFLAG_SHOW_DEFAULT\fR,
--the inital value of the arg will be shown in help output.
-+the initial value of the arg will be shown in help output.
- .sp
- The final structure in the table should have all the pointer values set
- .RB "to " NULL " and all the arithmetic values set to 0, marking the "
-@@ -233,7 +233,7 @@
- contain a overall description of the option table being included.
- .sp
- The other special option table entry type tells popt to call a function (a
--callback) when any option in that table is found. This is especially usefull
-+callback) when any option in that table is found. This is especially useful
- when included option tables are being used, as the program which provides
- the top-level option table doesn't need to be aware of the other options
- which are provided by the included table. When a callback is set for
-@@ -473,7 +473,7 @@
- .TP
- .B POPT_ERROR_BADNUMBER
- A conversion from a string to a number (int or long) failed due
--to the string containing nonnumeric characters. This occurs when
-+to the string containing non-numeric characters. This occurs when
- .BR poptGetNextOpt() " is processing an argument of type " 
- .BR POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
- .RB POPT_ARG_FLOAT ", or " POPT_ARG_DOUBLE "."  
-@@ -517,7 +517,7 @@
- applications. When an error is detected from most of the functions, 
- an error message is printed along with the error string from 
- .BR poptStrerror() ". When an error occurs during argument parsing, "
--code similiar to the following displays a useful error message:
-+code similar to the following displays a useful error message:
- .sp
- .nf
- fprintf(stderr, "%s: %s\\n",
-@@ -608,7 +608,7 @@
- .RI "an " argv "-style array, some programs need to parse strings that "
- are formatted identically to command lines. To facilitate this, popt 
- provides a function that parses a string into an array of strings, 
--using rules similiar to normal shell parsing.
-+using rules similar to normal shell parsing.
- .sp
- .nf
- .B "#include <popt.h>"

diff --git a/popt-1.16-pkgconfig.patch b/popt-1.16-pkgconfig.patch
deleted file mode 100644
index 08d05c6..0000000
--- a/popt-1.16-pkgconfig.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-Patch by Robert Scheck <robert@fedoraproject.org> for popt <= 1.16 which changes
-$(pkgconfigdir) on 64 bit systems from /usr/lib/pkgconfig to /usr/lib64/pkgconfig.
-Using $(libdir)/pkgconfig rather $(prefix)/lib/pkgconfig seems to be common when
-searching on the Internet. This patch however is not really compliant with Fedora
-/%{_lib} vs. %{_libdir} handling before the UsrMove with Fedora 17. Alternatively
---with-pkgconfigdir or similar should be implemented.
-
-This patch was proposed to upstream: http://rpm5.org/community/popt-devel/0265.html
-
---- popt-1.16/Makefile.in			2010-05-04 22:55:59.000000000 +0200
-+++ popt-1.16/Makefile.in.pkgconfig		2013-11-24 15:06:43.000000000 +0100
-@@ -370,7 +370,7 @@
- libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
- libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@ \
- 	$(am__append_1)
--pkgconfigdir = $(prefix)/lib/pkgconfig
-+pkgconfigdir = $(libdir)/pkgconfig
- pkgconfig_DATA = popt.pc
- man_MANS = popt.3
- BUILT_SOURCES = popt.pc # popt.lcd
---- popt-1.16/Makefile.am			2010-05-04 22:55:54.000000000 +0200
-+++ popt-1.16/Makefile.am.pkgconfig		2013-11-24 15:02:21.000000000 +0100
-@@ -47,7 +47,7 @@
- libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
- libpopt_la_LDFLAGS = -no-undefined @LTLIBINTL@ @LTLIBICONV@
- 
--pkgconfigdir = $(prefix)/lib/pkgconfig
-+pkgconfigdir = $(libdir)/pkgconfig
- pkgconfig_DATA = popt.pc
- 
- if HAVE_LD_VERSION_SCRIPT

diff --git a/popt.spec b/popt.spec
index ed40c7a..e6cd034 100644
--- a/popt.spec
+++ b/popt.spec
@@ -1,15 +1,16 @@
 Summary:	C library for parsing command line parameters
 Name:		popt
 Version:	1.16
-Release:	9%{?dist}
+Release:	10%{?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.16-pkgconfig.patch
-Patch1:		popt-1.16-execfail.patch
-Patch2:		popt-1.16-man-page.patch
-Patch3:		popt-1.16-help.patch
+Patch0001:	0001-Update-pkgconfig-directory.patch
+Patch0002:	0002-kludge-poptBadOption-to-return-value-on-exec-alias-f.patch
+Patch0003:	0003-Fix-some-spelling-mistakes-in-the-man-page.patch
+Patch0004:	0004-Make-help-and-usage-translatable.patch
+Patch0005:	0005-Don-t-leak-the-last-argument-expanded-by-expandNextA.patch
 BuildRequires:	gettext
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -43,11 +44,7 @@ The popt-static package includes static libraries of the popt library.
 Install it if you need to link statically with libpopt.
 
 %prep
-%setup -q
-%patch0 -p1 -b .pkgconfig
-%patch1 -p1 -b .execfail
-%patch2 -p1 -b .man-page
-%patch3 -p1 -b .help
+%autosetup -S git
 
 %build
 %if 0%{?fedora} < 17 && 0%{?rhel} < 7
@@ -113,6 +110,10 @@ make check
 %{_libdir}/libpopt.a
 
 %changelog
+* Fri Jul 28 2017 Peter Jones <pjones@redhat.com> - 1.16-10
+- Make it use %%autosetup -S git
+- Fix a memory leak
+
 * Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.16-9
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
 

                 reply	other threads:[~2026-11-23  9:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179542777071.1.17747927389683446594.rpms-popt-befacb44b02b@fedoraproject.org \
    --to=pjones@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox