Commit a9b4695c authored by Michael Jeanson's avatar Michael Jeanson

Modernize packaging

  + Convert to a full debhelper rules file
  + Multiple autoreconf fixes
  + Fix test suite
  + Add comments to all patches
  + Add Fedora patches
parent d9d0d454
popt (1.16-10) unstable; urgency=low
* debian/rules: move dependency on target autoreconf-stamp from
configure (which isn't called) to configure-deb-stamp and
* debian/rules: move dependency on target autoreconf-stamp from
configure (which isn't called) to configure-deb-stamp and
configure-udeb-stamp.
* Patches: 757935-autoreconf.patch: add change to Makefile.am of
* Patches: 757935-autoreconf.patch: add change to Makefile.am of
testit.sh path.
* That'll teach me to try to be too clever! (Closes: #757935)
......@@ -105,8 +105,8 @@ popt (1.15-1) unstable; urgency=low
popt (1.14-4) unstable; urgency=low
* Remove locale data from the udeb, and change the package
description. The debian-installer developers are sure that they
* Remove locale data from the udeb, and change the package
description. The debian-installer developers are sure that they
don't need the localization information, mainly error messages.
(Thanks to Frans Pop for bringing this to my attention.)
......@@ -114,7 +114,7 @@ popt (1.14-4) unstable; urgency=low
popt (1.14-3) unstable; urgency=low
* Add the locale data to the udeb, as per the package description.
* Add the locale data to the udeb, as per the package description.
(Closes: #485926)
-- Paul Martin <pm@debian.org> Thu, 12 Jun 2008 17:39:07 +0100
......@@ -132,7 +132,7 @@ popt (1.14-1) unstable; urgency=low
+ debian/patches/374797.patch no longer needed
+ Upstream now has po/de.po, po/zh_CN.po
* Move existing bug fixes into quilt:
+ debian/patches/217602.patch: Drop alignment check in
+ debian/patches/217602.patch: Drop alignment check in
poptSaveLong() and poptSaveInt()
+ debian/patches/356669.patch: po/ca.po (Catalan).
* Fix debian/patches/ to allow future source format 3.0 (quilt).
......@@ -141,12 +141,12 @@ popt (1.14-1) unstable; urgency=low
+ substvar-source-version-is-deprecated, changed to ${binary:Version}
+ debian-rules-ignores-make-clean-error
* Updates to CFLAGS in debian/rules to ensure correct build.
* Update to standards-version 3.8.0 and debhelper 7, and move to
* Update to standards-version 3.8.0 and debhelper 7, and move to
section libs.
* Note: config.sub and config.guess are whatever upstream supplies.
The previous use of the latest locally installed versions was a
kluge to avoid build problems on new architectures. This is not
compatible with future source packaging formats, and if not carefully
* Note: config.sub and config.guess are whatever upstream supplies.
The previous use of the latest locally installed versions was a
kluge to avoid build problems on new architectures. This is not
compatible with future source packaging formats, and if not carefully
handled causes build problems when autotools is not installed.
* Accommodate cross-compilation. (Closes: #282913)
......@@ -154,18 +154,18 @@ popt (1.14-1) unstable; urgency=low
popt (1.10-3) unstable; urgency=low
* The lib64 problem remains, as an rpath problem. Patch 374797.patch
changes Makefile.in so that ./configure doesn't put the libraries in
* The lib64 problem remains, as an rpath problem. Patch 374797.patch
changes Makefile.in so that ./configure doesn't put the libraries in
the wrong place or give them the wrong rpath. (Closes: #374797)
PS. This fix is fragile to any of the autoconf files (eg.
PS. This fix is fragile to any of the autoconf files (eg.
configure.ac or Makefile.ac) being touched or modified.
-- Paul Martin <pm@debian.org> Tue, 8 Aug 2006 01:41:49 +0100
popt (1.10-2) unstable; urgency=low
* Fix building on 64-bit architectures where the autoconf tools want
to put things in /usr/lib64 instead of /usr/lib. Thanks to Roberto
* Fix building on 64-bit architectures where the autoconf tools want
to put things in /usr/lib64 instead of /usr/lib. Thanks to Roberto
Pariset for the advice and Simon Huggins for the patch.
(Closes: #370414)
......@@ -210,8 +210,8 @@ popt (1.7-5) unstable; urgency=high
popt (1.7-4) unstable; urgency=low
* Missed alignment check in poptSaveInt(). (Closes: #217602)
* Add shlibdeps check for 1.7-4 if building on m68k, due to
brokenness with older versions of libpopt0 (the alignment checks).
* Add shlibdeps check for 1.7-4 if building on m68k, due to
brokenness with older versions of libpopt0 (the alignment checks).
Other archs may be broken, too. Please make yourselves known if so.
-- Paul Martin <pm@debian.org> Thu, 20 Nov 2003 19:50:10 +0000
......@@ -228,7 +228,7 @@ popt (1.7-2) unstable; urgency=low
* The "Apart from that, how was the play, Mrs Lincoln?" release.
* Acknowledging NMU. (Closes: #195072)
It got unstuck because the pattern it was matching for was X.X.X,
It got unstuck because the pattern it was matching for was X.X.X,
and this version is just X.X. Filip's method is much cleaner.
-- Paul Martin <pm@debian.org> Thu, 29 May 2003 20:24:32 +0100
......@@ -279,15 +279,15 @@ popt (1.6.2-7) unstable; urgency=HIGH
popt (1.6.2-6) unstable; urgency=HIGH
* Modified depends in libpopt-dev to depend on
libpopt0 (= ${Source-Version}). Previous uploads would allow
libpopt0 (= ${Source-Version}). Previous uploads would allow
libpopt0 to get out of step with libpopt-dev, causing compiles to
fail if the user starts from having 1.5-1 installed, and only
upgrades libpopt0. This is a violation of a "should" policy
fail if the user starts from having 1.5-1 installed, and only
upgrades libpopt0. This is a violation of a "should" policy
directive. (Closes: #125685)
* Removed redundant ldconfig call from debian/libpopt0.postinst, as
debhelper does it for us. Fixes lintian postinst-unsafe-ldconfig
warning.
* Uploading with urgency=high, since this upload contains
* Uploading with urgency=high, since this upload contains
only minimal, "important" bugfixes.
-- Paul Martin <pm@debian.org> Wed, 19 Dec 2001 15:59:03 +0000
......@@ -408,13 +408,13 @@ popt (1.3-0.1) unstable; urgency=low
popt (1.1.1-3) unstable; urgency=low
* Now popt builds properly from clean sources. Fixes: 25581, 26277.
-- Enrique Zanardi <ezanard@debian.org> Tue, 1 Sep 1998 11:26:54 +0100
popt (1.1.1-2) unstable; urgency=low
* Don't strip libpopt.a
-- Enrique Zanardi <ezanard@debian.org> Thu, 30 Jul 1998 18:37:27 +0100
popt (1.1.1-1) unstable; urgency=low
......
......@@ -2,17 +2,19 @@ Source: popt
Section: devel
Priority: optional
Maintainer: Michael Jeanson <mjeanson@debian.org>
Build-Depends: debhelper (>> 9), gettext (>= 0.18.1.1-8), dh-autoreconf
Build-Depends: debhelper (>= 9~), gettext (>= 0.18.1.1-8), dh-autoreconf,
api-sanity-checker
Standards-Version: 4.1.3
Vcs-Git: https://salsa.debian.org/debian/popt.git
Vcs-Browser: https://salsa.debian.org/debian/popt.git
Homepage: http://rpm5.org/
Standards-Version: 3.9.5
Package: libpopt0
Architecture: any
Multi-Arch: same
Section: libs
Priority: important
Depends: ${shlibs:Depends}, ${misc:Depends}
Pre-Depends: ${misc:Pre-Depends}
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Conflicts: popt, libpopt-dev (<= 1.4-1), rpm (<= 4.0.2-3)
Replaces: popt
Description: lib for parsing cmdline parameters
......@@ -21,16 +23,15 @@ Description: lib for parsing cmdline parameters
argv[] style arrays and automatically set variables based on command
line arguments. It also allows command line arguments to be aliased via
configuration files and includes utility functions for parsing arbitrary
strings into argv[] arrays using shell-like rules.
strings into argv[] arrays using shell-like rules.
.
This package contains the runtime library and locale data.
Package: libpopt-dev
Architecture: any
Multi-Arch: same
Section: libdevel
Priority: optional
Depends: libc6-dev | libc-dev, libpopt0 (= ${binary:Version}), ${misc:Depends}
Multi-Arch: same
Conflicts: popt
Replaces: popt
Description: lib for parsing cmdline parameters - development files
......@@ -44,7 +45,7 @@ Description: lib for parsing cmdline parameters - development files
This package contains the popt static library and header file.
Package: libpopt0-udeb
XC-Package-Type: udeb
Package-Type: udeb
Architecture: any
Section: debian-installer
Depends: ${shlibs:Depends}, ${misc:Depends}
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: popt
Upstream-Contact: Jeff Johnson <jbj@rpm5.org>
Source: http://rpm5.org/files/popt/
Comment:
popt was originally written by Erik Troan when he was with RedHat. It's
popt was originally written by Erik Troan when he was with RedHat. It's
now maintained as part of Fedora.
Files: *
......@@ -34,6 +34,7 @@ License: X-Consortium
Files: debian/*
Copyright: GNU copyright 1997 to 1999 by Joey Hess
2012, Paul Martin <pm@debian.org>
2018, Michael Jeanson <mjeanson@debian.org>
License: GPL-2+
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
......
[DEFAULT]
upstream-branch=upstream/latest
debian-branch=debian/sid
usr/lib/*/libpopt.so
usr/lib/*/libpopt.la
usr/include/popt.h
usr/lib/*/libpopt.a
usr/lib/*/libpopt.so
usr/lib/*/pkgconfig
usr/share/man/man3/popt.3
usr/include/popt.h
usr/lib/pkgconfig/* usr/lib/x86_64-linux-gnu/pkgconfig
usr/lib/*/libpopt.so
usr/lib/*/libpopt.la
usr/lib/*/libpopt.a
usr/share/man/man3/popt.3
usr/include/popt.h
usr/lib/pkgconfig/* usr/lib/DEB_HOST_MULTIARCH/pkgconfig
lib/DEB_HOST_MULTIARCH/libpopt.so.0 usr/lib/DEB_HOST_MULTIARCH/libpopt.so
debian/tmp-udeb/lib*/libpopt.so.* lib
usr/lib/*/libpopt.so.*
usr/lib/DEB_HOST_MULTIARCH/libpopt.so.* lib/DEB_HOST_MULTIARCH
usr/lib/*/libpopt.so.*
usr/share/locale/*/LC_MESSAGES/popt.mo
lib/DEB_HOST_MULTIARCH/libpopt.so.0.0.0 lib/DEB_HOST_MULTIARCH/libpopt.so.0
Index: popt-1.10/popthelp.c
===================================================================
--- popt-1.10.orig/popthelp.c 2006-05-12 13:56:30.572854743 +0100
+++ popt-1.10/popthelp.c 2006-05-12 13:57:26.403052753 +0100
@@ -222,7 +222,7 @@
/*@modifies *fp, fileSystem @*/
{
size_t indentLength = maxLeftCol + 5;
- size_t lineLength = 79 - indentLength;
+ size_t lineLength = (indentLength > 78) ? 1 : (79 - indentLength);
const char * help = D_(translation_domain, opt->descrip);
const char * argDescrip = getArgDescrip(opt, translation_domain);
size_t helpLength;
Patch by Nicolas Boullis <nboullis@debian.org> and revised by Paul Martin
<pm@debian.org>.
In functions poptSaveLong and poptSaveInt, libpopt somwhat asserts that
{long,}ints are aligned on sizeof({long,}int)-byte boundaries. On m68k
with gcc-3.3 ints and long ints are 4-byte long, but are aligned on 2-bytes
boundaries at least when they are part onf a struct.
Simply remove this check, as it is quite useless.
Index: popt-1.16/popt.c
===================================================================
--- popt-1.16.orig/popt.c 2010-05-13 04:57:52.006009545 +0100
......
Patch by Carl Henrik Lunde <chlunde+news+@ping.uio.no>
There are some minor typos in the manual page:
- "char" can be unsigned
- exit(3) is defined in stdlib.h
- \n must be escaped in nroff
- poptGetArg returns a pointer to const char
Index: popt-1.16/popt.3
===================================================================
--- popt-1.16.orig/popt.3 2010-05-13 04:58:04.357009234 +0100
......
Index: popt-1.16/popt.c
===================================================================
--- popt-1.16.orig/popt.c 2010-05-13 04:57:46.853009777 +0100
+++ popt-1.16/popt.c 2010-05-13 04:57:52.006009545 +0100
Patch by Richard Levitte - VMS Whacker <richard@levitte.org>
If poptStuffArgs() is used twice with the same context, it will invariably
cause memory corruption and possibly memory leaks or a crash.
Change the allocation of leftOvers so it adapts to the input on the fly
instead of trying to pre-allocate it in one go.
--- a/popt.c
+++ b/popt.c
@@ -184,6 +184,7 @@
con->os->next = 1; /* skip argv[0] */
......@@ -10,11 +16,13 @@ Index: popt-1.16/popt.c
/*@-dependenttrans -assignexpose@*/ /* FIX: W2DO? */
con->options = options;
/*@=dependenttrans =assignexpose@*/
@@ -1358,7 +1359,19 @@
@@ -1357,8 +1358,21 @@
con->os->nextArg = xstrdup(origOptString);
return 0;
}
if (con->leftovers != NULL) /* XXX can't happen */
- if (con->leftovers != NULL) /* XXX can't happen */
- con->leftovers[con->numLeftovers++] = origOptString;
+ if (con->leftovers != NULL) { /* XXX can't happen */
+ /* One might think we can never overflow the leftovers
+ array. Actually, that's true, as long as you don't
+ use poptStuffArgs()... */
......@@ -28,10 +36,11 @@ Index: popt-1.16/popt.c
+ = xstrdup(origOptString); /* so a free of a stuffed
+ argv doesn't give us a
+ dangling pointer */
+ }
continue;
}
@@ -1612,6 +1625,8 @@
@@ -1612,6 +1626,8 @@
poptContext poptFreeContext(poptContext con)
{
......@@ -40,7 +49,7 @@ Index: popt-1.16/popt.c
if (con == NULL) return con;
poptResetContext(con);
con->os->argb = _free(con->os->argb);
@@ -1622,7 +1637,11 @@
@@ -1622,7 +1638,11 @@
con->execs = poptFreeItems(con->execs, con->numExecs);
con->numExecs = 0;
......@@ -52,10 +61,8 @@ Index: popt-1.16/popt.c
con->finalArgv = _free(con->finalArgv);
con->appName = _free(con->appName);
con->otherHelp = _free(con->otherHelp);
Index: popt-1.16/poptint.h
===================================================================
--- popt-1.16.orig/poptint.h 2010-05-13 04:57:46.878010140 +0100
+++ popt-1.16/poptint.h 2010-05-13 04:57:52.008009414 +0100
--- a/poptint.h
+++ b/poptint.h
@@ -119,6 +119,7 @@
/*@owned@*/ /*@null@*/
poptArgv leftovers;
......
Patch by Jordi Mallach <jordi@debian.org>
Add Catalan translation.
Index: popt-1.16/po/ca.po
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
......
Add AM_GNU_GETTEXT_VERSION to configure.ac so that autoreconf pulls in recent
gettext auxiliary files.
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,7 @@
AC_CHECK_FUNCS(getuid geteuid iconv mtrace __secure_getenv secure_getenv setregid stpcpy strerror vasprintf srandom)
AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION(0.19.3)
AM_ICONV_LINK
popt_sysconfdir="${sysconfdir}"
Add LT_INIT to configure.ac so that autoreconf pulls in recent libtool
auxiliary files.
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@
AC_PROG_CC
AC_PROG_INSTALL
-AC_PROG_LIBTOOL
+LT_INIT
dnl if CC is gcc, we can rebuild the dependencies (since the depend rule
dnl requires gcc). If it's not, don't rebuild dependencies -- use what was
Fix test to use newer Api Sanity Checker releases.
--- a/auto/Makefile.am
+++ b/auto/Makefile.am
@@ -1,6 +1,6 @@
AUTOMAKE_OPTIONS = 1.4 foreign
-AUTOTEST = api-sanity-autotest.pl
+AUTOTEST = api-sanity-checker
TDIRS = descriptors_storage header_compile_errors test_results tests
@@ -8,5 +8,5 @@
rm -rf $(TDIRS)
check-local:
- -[ -d tests ] && ${AUTOTEST} -l popt -d desc -clean
- -${AUTOTEST} -l popt -d desc -st types -gen -build -run
+ -[ -d tests ] && ${AUTOTEST} -l popt -d popt.xml -clean
+ -${AUTOTEST} -l popt -d popt.xml -st types -gen -build -run
--- /dev/null
+++ b/auto/popt.xml.in
@@ -0,0 +1,28 @@
+<version>
+ 1.15
+</version>
+
+<headers>
+ @abs_top_srcdir@/popt.h
+</headers>
+
+<libs>
+ @abs_top_builddir@/.libs/libpopt.so
+</libs>
+
+<include_paths>
+ @abs_top_srcdir@
+</include_paths>
+
+<gcc_options>
+ @CFLAGS@
+</gcc_options>
+
+<opaque_types>
+</opaque_types>
+<skip_interfaces>
+</skip_interfaces>
+<include_preamble>
+</include_preamble>
+<libs_depend>
+</libs_depend>
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,6 @@
AC_CONFIG_SUBDIRS()
AC_CONFIG_FILES([ po/Makefile.in m4/Makefile
Doxyfile Makefile popt.pc popt.spec test-poptrc
- auto/Makefile auto/desc auto/types
+ auto/Makefile auto/popt.xml auto/types
])
AC_OUTPUT
Recent versions of libtool do not prefix wrapper binaries with "lt-".
--- a/testit.sh
+++ b/testit.sh
@@ -115,7 +115,7 @@
run test1 "test1 - 57" "arg1: 0 arg2: (none) aBits: foo,baz" --bits foo,bar,baz,!bar
run test1 "test1 - 58" "\
-Usage: lt-test1 [-I?] [-c|--cb2=STRING] [--arg1] [-2|--arg2=ARG]
+Usage: test1 [-I?] [-c|--cb2=STRING] [--arg1] [-2|--arg2=ARG]
[-3|--arg3=ANARG] [-onedash] [--optional=STRING] [--val]
[-i|--int=INT] [-s|--short=SHORT] [-l|--long=LONG]
[-L|--longlong=LONGLONG] [-f|--float=FLOAT] [-d|--double=DOUBLE]
@@ -124,7 +124,7 @@
[--bitxor] [--nstr=STRING] [--lstr=STRING] [-I|--inc]
[-c|--cb=STRING] [--longopt] [-?|--help] [--usage] [--simple=ARG]" --usage
run test1 "test1 - 59" "\
-Usage: lt-test1 [OPTION...]
+Usage: test1 [OPTION...]
--arg1 First argument with a really long
description. After all, we have to test
argument help wrapping somehow, right?
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
--- a/popt.c
+++ b/popt.c
@@ -193,6 +193,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;
@@ -237,6 +238,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++) {
@@ -565,6 +567,7 @@
/*@-nullstate@*/
rc = execvp(argv[0], (char *const *)argv);
/*@=nullstate@*/
+ con->execFail = xstrdup(argv[0]);
exit:
if (argv) {
@@ -1727,11 +1730,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)
--- a/poptint.h
+++ b/poptint.h
@@ -133,6 +133,7 @@
/*@owned@*/ /*@null@*/
poptItem execs;
int numExecs;
+ char * execFail;
/*@only@*/ /*@null@*/
poptArgv finalArgv;
int finalArgvCount;
Backport of upstream http://rpm5.org/cvs/chngview?cn=19258
--- popt-1.16/poptconfig.c 2009-05-20 15:18:07.000000000 +0200
+++ popt-1.16/poptconfig.c.glob-error 2017-10-12 23:33:28.868435647 +0200
@@ -108,7 +108,7 @@
if (glob_pattern_p(pat, 0)) {
glob_t _g, *pglob = &_g;
- if (!glob(pat, poptGlobFlags, poptGlob_error, pglob)) {
+ if (!(rc = glob(pat, poptGlobFlags, poptGlob_error, pglob))) {
if (acp) {
*acp = (int) pglob->gl_pathc;
pglob->gl_pathc = 0;
@@ -122,6 +122,10 @@
/*@-nullstate@*/
globfree(pglob);
/*@=nullstate@*/
+ } else if (rc == GLOB_NOMATCH) {
+ *avp = NULL;
+ *acp = 0;
+ rc = 0;
} else
rc = POPT_ERROR_ERRNO;
} else
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. */
Index: popt-1.16/popt.3
===================================================================
--- popt-1.16.orig/popt.3 2010-05-13 04:57:46.665009784 +0100
+++ popt-1.16/popt.3 2010-05-13 04:58:04.357009234 +0100
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
......@@ -29,6 +37,15 @@ Index: popt-1.16/popt.3
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
......
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.