summaryrefslogtreecommitdiff
path: root/lib/argp-help.c
Commit message (Collapse)AuthorAgeFilesLines
* argp: Avoid possible NULL access in argp_help.Darren Kenny2021-06-181-1/+2
| | | | | | | Reported by Coverity. The invocation chain is: argp_help -> _help -> fill_in_uparams -> validate_uparams. * lib/argp-help.c (validate_uparams): Don't crash if state == NULL.
* Put LGPLv3+ notices in source files where appropriate.Bruno Haible2021-06-041-7/+7
| | | | | * lib/**.{h,c}: Use LGPLv3+ notice whenever the module description says so.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* argp: Avoid undefined behaviour when invoking qsort().Bruno Haible2020-12-081-78/+173
| | | | | | | | | | | | | This fixes a test-argp-2.sh test failure on macOS and FreeBSD. Reported by Jeffrey Walton <noloader@gmail.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00085.html>. * lib/argp-help.c (group_cmp): Remove third argument. (hol_sibling_cluster_cmp, hol_cousin_cluster_cmp): New functions, based upon hol_cluster_cmp. (hol_cluster_cmp): Use hol_cousin_cluster_cmp. (hol_entry_cmp): Rewritten to implement a total order.
* argp: Improve comments.Bruno Haible2020-12-081-45/+63
| | | | | | | | | | * lib/argp-help.c: Add sectioning comments. Write NULL to designate a null pointer. (struct hol_entry): Fix comment regarding sort order of group. (hol_entry_short_iterate, hol_entry_long_iterate): Add comment. (until_short, canon_doc_option, hol_entry_qcmp): Improve comment. (hol_cluster_is_child, argp_hol): Move functions. (HOL_ENTRY_PTRCMP): Remove unused macro.
* argp: Don't pass invalid arguments to isspace() and isalnum().Bruno Haible2020-12-081-2/+2
| | | | | * lib/argp-help.c (canon_doc_option): Cast character to 'unsigned int' before passing it to isspace() or isalnum().
* argp: Don't rely on undefined behaviour of _tolower().Bruno Haible2020-12-081-6/+4
| | | | | | | | Patch by Eric Blake <https://lists.gnu.org/archive/html/bug-gnulib/2009-09/msg00287.html>. * lib/argp-help.c (hol_entry_cmp): Don't use _tolower on values that are not upper-case. Pass correct range to tolower.
* argp: Emit a warning also with clang.Bruno Haible2020-08-161-1/+1
| | | | | * lib/argp-help.c (__argp_short_program_name): Use #warning also on clang.
* Fix "warning: implicitly declaring library function 'strcasecmp'".Bruno Haible2020-08-161-0/+1
| | | | * lib/argp-help.c: Include <strings.h>.
* Use many __attribute__s with clang.Bruno Haible2020-08-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/gnulib-common.m4 (_Noreturn): Use __attribute__ __noreturn__ also on clang. * lib/cdefs.h (__glibc_clang_has_attribute, __glibc_clang_has_builtin): New macros. (__THROW, __THROWNL, __NTH, __NTHNL): Use __attribute__ __nothrow__ also on clang. (__warndecl, __warnattr, __errordecl): Use __attribute__ __diagnose_if__ also on older clang versions. (__attribute__): Don't define to empty on clang. (__attribute_malloc__): Use __attribute__ __malloc__ also on clang. (__attribute_pure__): Use __attribute__ __pure__ also on clang. (__attribute_const__): Use __attribute__ __const__ also on clang. (__attribute_used__): Use __attribute__ __used__ also on clang. (__attribute_noinline__): Use __attribute__ __noinline__ also on clang. (__attribute_deprecated__): Use __attribute__ __deprecated__ also on clang. (__attribute_format_arg__): Use __attribute__ __format_arg__ also on clang. (__attribute_format_strfmon__): Use __attribute__ __format__ __strfmon__ also on clang. (__nonnull): Use __attribute__ __nonnull__ also on clang. (__attribute_warn_unused_result__): Use __attribute__ __warn_unused_result__ also on clang. (__always_inline): Use __attribute__ __always_inline__ also on clang. (__attribute_artificial__): Use __attribute__ __artificial__ also on clang >= 7. (__glibc_unlikely, __glibc_likely): Use __builtin_expect also on older clang versions. (_Noreturn): Don't redefine on clang >= 3.5. * lib/arg-nonnull.h (_GL_ARG_NONNULL): Use __attribute__ __nonnull__ also on clang. * lib/dirent.in.h (_GL_ATTRIBUTE_PURE): Use __attribute__ __pure__ also on clang. * lib/stdlib.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/string.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/wchar.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/stdio.in.h (_GL_ATTRIBUTE_FORMAT): Use __attribute__ __format__ also on clang. * lib/monetary.in.h (_GL_ATTRIBUTE_FORMAT): Likewise. * lib/textstyle.in.h (ostream_printf, ostream_vprintf): Likewise. * lib/unitypes.in.h (_UC_ATTRIBUTE_CONST): Use __attribute__ __const__ also on clang. (_UC_ATTRIBUTE_PURE): Use __attribute__ __pure__ also on clang. * lib/noreturn.h (_GL_NORETURN_FUNC, _GL_NORETURN_FUNCPTR): Use __attribute__ __noreturn__ also on clang. * lib/obstack.h (__attribute_noreturn__): Likewise. * lib/file-set.h (record_file): Use __attribute__ __nonnull__ also on clang. * lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ always_inline also on clang. * tests/test-printf-posix.c (func1, func2, func3, func4): Test also on clang.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* Fix typos found by codespell.Tim Rühsen2019-01-121-1/+1
| | | | | * lib/*.[hc]: Fix typos in comments. * pygnulib/*.py: Fix typos in error messages and comments.
* argp: Don't pass an invalid argument to dgettext().Bruno Haible2019-01-051-2/+2
| | | | | | | Reported by He X <xw897002528@gmail.com>. * lib/argp-help.c (print_header, argp_doc): Don't pass a NULL doc to dgettext().
* argp: Don't pass an invalid argument to dgettext().Bruno Haible2019-01-051-1/+3
| | | | | | | | Reported by He X <xw897002528@gmail.com>. * lib/argp.h (struct argp): Clarify that the args_doc field may be NULL. * lib/argp-help.c (argp_args_usage): Don't pass a NULL args_doc to dgettext().
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* argp: fix pointer-subtraction bugPaul Eggert2017-05-191-1/+2
| | | | | | | * lib/argp-help.c (hol_append): Don’t subtract pointers to different arrays, as this can run afoul of -fcheck-pointer-bounds. See the thread containing Bruno Haible’s report in: http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00171.html
* argp: Fix mistake in 2017-04-23 commit.Bruno Haible2017-05-051-1/+1
| | | | | * lib/argp-help.c (__argp_failure): If GNULIB_STRERROR_R_POSIX is set, assume that strerror_r returns 'int', not 'char *'.
* argp: Fix typo.Reuben Thomas2017-05-041-1/+1
| | | | * lib/argp-help.c (argp_doc): Fix spelling mistake in comment.
* Fix conflict between strerror_r-posix module and AC_FUNC_STRERROR_R.Bruno Haible2017-04-251-2/+2
| | | | | | | * modules/strerror_r-posix (configure.ac): Invoke gl_MODULE_INDICATOR. * lib/error.c: Test GNULIB_STRERROR_R_POSIX before testing HAVE_DECL_STRERROR_R, HAVE_STRERROR_R, or STRERROR_R_CHAR_P. * lib/argp-help.c (__argp_failure): Likewise.
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* argp: merge changes from glibcPaul Eggert2016-04-031-200/+150
| | | | | | | | | | | | | Among other things, this should fix problems found by a Coverity scan and reported by Andrei Borzenkov: http://lists.gnu.org/archive/html/bug-gnulib/2016-01/msg00015.html http://lists.gnu.org/archive/html/bug-gnulib/2016-01/msg00016.html * lib/argp-ba.c, lib/argp-fmtstream.c, lib/argp-fmtstream.h: * lib/argp-fs-xinl.c, lib/argp-help.c, lib/argp-namefrob.h: * lib/argp-parse.c, lib/argp-pv.c, lib/argp-pvh.c, lib/argp-xinl.c: * lib/argp.h: Merge changes from glibc. * tests/test-argp-2.sh: Adjust to match new behavior.
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2014-12-311-1/+1
| | | | | | * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
* argp: avoid extraneous translation and mem leak with empty pre docAndrei Borzenkov2014-12-021-2/+6
| | | | | | | | | * lib/argp-help.c (argp_doc): Never translate the empty string, when "\v" is the first or last character of the string, as that has a reserved meaning to return the header info from a po file. This also fixes a small memory leak in the !post case. The issue can be seen with this command for example: LC_MESSAGES=en_US grub2-mknetdir --help
* maint: update copyrightEric Blake2014-01-011-1/+1
| | | | | | I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* argp: typo fixAlexandre Duret-Lutz2013-05-171-1/+1
| | | | * lib/argp-help.c: Typo in comment.
* maint: update all copyright year number rangesEric Blake2013-01-011-1/+1
| | | | | | Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
* argp, regex: Ensure strcasecmp gets declared.Bruno Haible2012-06-261-0/+1
| | | | | | * lib/argp-help.c: Include <strings.h>. * lib/regex_internal.h: Likewise. Reported and suggested by Joachim Schmitz <jojo@schmitz-digital.de>.
* maint: spelling fixesPaul Eggert2012-02-051-9/+9
|
* In commentary, do not use ` to quote.Paul Eggert2012-01-051-16/+16
|
* Use ', not `, for quoting output.Paul Eggert2012-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * build-aux/announce-gen (usage, sizes, print_news_deltas) (print_changelog_deltas, get_tool_versions, main program): * build-aux/git-version-gen: * build-aux/gitlog-to-changelog (usage, parse_amend_file): * build-aux/move-if-change (help): * build-aux/useless-if-before-free (usage, main program): * check-module (parse_module_file, usage) (find_included_lib_files, check_module): * lib/argmatch.c (main) [TEST]: * lib/argp-help.c (_help): * lib/getopt1.c (main) [TEST]: * lib/git-merge-changelog.c (usage): * lib/xstrtol-error.c (xstrtol_error): * m4/alloca.m4 (_AC_LIBOBJ_ALLOCA): * m4/argz.m4 (gl_FUNC_ARGZ): * m4/bison.m4 (gl_BISON): * m4/calloc.m4 (gl_FUNC_CALLOC_GNU): * m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): * m4/flexmember.m4 (AC_C_FLEXIBLE_ARRAY_MEMBER): * m4/fpending.m4 (gl_PREREQ_FPENDING): * m4/gc-random.m4 (gl_GC_RANDOM): * m4/intl.m4 (gt_CHECK_DECL): * m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK): * m4/longlong.m4 (AC_TYPE_LONG_LONG_INT) (AC_TYPE_UNSIGNED_LONG_LONG_INT): * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): * m4/lstat.m4 (gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK): * m4/onceonly.m4 (AC_CHECK_FUNCS_ONCE): * m4/posixver.m4 (gl_DEFAULT_POSIX2_VERSION): * tests/test-dirname.c (main): * tests/test-getpass.c (main): * tests/test-iconvme.c (main): * tests/test-parse-datetime.c (LOG): * tests/test-xstrtoimax.sh: * tests/test-xstrtol.sh: * tests/test-xstrtoll.sh: * tests/test-xstrtoumax.sh: * tests/unigbrk/test-uc-is-grapheme-break.c (main): * top/GNUmakefile (abort-due-to-no-makefile): Quote 'like this', not `like this', as per the recent change to the GNU coding standards.
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* Avoid subtracting two pointers that don't point into the same block.Matthew Wala2011-11-301-1/+2
| | | | | | * lib/argp-help.c (hol_append): Reorder pointer subtractions so that only pointers into the same memory block are subtracted. We cannot assume that sizeof (ptrdiff_t) == sizeof (void *).
* argp: Allow coexistence with strerror_r-posix module.Bruno Haible2011-05-291-1/+1
| | | | | | | * lib/argp-help.c (__argp_failure): If strerror_r is defined as a macro (either to __xpg_strerror_r by glibc's <string.h> or to rpl_strerror_r by gnulib's <string.h> replacement), assume it has the POSIX signature, not the glibc signature.
* maint: replace misused "a" with "an"Jim Meyering2011-05-201-3/+3
| | | | | | | | | | | * doc/intprops.texi: "a integer" * doc/regex.texi: "a explanation" * lib/alignof.h: "a object" * lib/argmatch.h: "a explanation" * lib/argp-help.c: "a option" and "a OPTION_DOC" * lib/stdint.in.h: "a integer" * lib/userspec.c: "a owner" * doc/gnulib.texi: Fix "a idea", and reword.
* maint: correct misuse of "a" and "an"Jim Meyering2011-05-201-1/+1
| | | | | | | | | | | * doc/regex.texi (Collating Symbol Operators): s/an close.../a close/ * lib/argp-help.c: "an docum...": s/an/a/ * lib/argp-parse.c: "An vector": s/An/A/ * lib/execute.c: "an native": s/an/a/ * lib/spawn-pipe.c: Likewise. * lib/gc.h: "an Gc_rc": s/an/a/ * lib/unigbrk.in.h: "an grapheme": s/an/a/ * lib/fts.c: "an stat.st_dev": s/an/a/
* Don't interfere with a program's definition of __attribute__.Bruno Haible2011-02-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/argp.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (argp_error, __argp_error, argp_failure, __argp_failure): Use it. * lib/argp-fmtstream.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (__argp_fmtstream_printf, argp_fmtstream_printf): Use it. * lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ only for GCC 3 or newer. * lib/error.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (error, error_at_line): Use it. * lib/hash.h (__attribute__): Remove definition. (ATTRIBUTE_WUR): Update definition. Define always. * lib/openat.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/sigpipe-die.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/vasnprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (asnprintf, vasnprintf): Use it. * lib/xalloc.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. (ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE): Define always. * lib/xmemdup0.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/xprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (xprintf, xvprintf, xfprintf, xvfprintf): Use it. * lib/xstrtol.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/xvasprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (xasprintf, xvasprintf): Use it. * tests/test-argmatch.c (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * tests/test-exclude.c (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. Reported by Paul Eggert.
* maint: update almost all copyright ranges to include 2011Jim Meyering2011-01-011-1/+1
| | | | Run the new "make update-copyright" rule.
* Minor formatting changes.Bruno Haible2010-03-251-5/+5
|
* update nearly all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+1
| | | | | Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
* Use spaces for indentation, not tabs.Bruno Haible2009-12-101-619/+619
|
* argp: fix test failureEric Blake2009-09-281-7/+5
| | | | | | | * lib/argp-help.c (hol_entry_cmp): Don't use _tolower on values that are not upper-case. Pass correct range to tolower. Signed-off-by: Eric Blake <ebb9@byu.net>
* remove trailing blanksJim Meyering2008-05-201-11/+11
|
* Change copyright notice from GPLv2+ to GPLv3+.Bruno Haible2007-10-071-6/+5
|
* (until_short): Remove `inline' qualifier.Sergey Poznyakoff2007-06-221-1/+1
| | | | | Otherwise, passing function as argument to `hol_entry_first_short' fails on some systems.
* (struct hol_entry): New member `ord'.Sergey Poznyakoff2007-05-021-3/+12
| | | | | (HOL_ENTRY_PTRCMP): Use ord for comparison (hol_sort): Initialize ord.
* (hol_entry_cmp): Option sorting algorithmSergey Poznyakoff2007-04-301-4/+11
| | | | | | assumes the sorting is stable, while most qsort implementations are not. Use argument addresses to ensure they never compare as equal.
* (hol_cluster_cmp): Reverse comparison. Change proposed by Sven Verdoolaege.Sergey Poznyakoff2007-04-291-3/+5
|