X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fargp-help.c;h=4c0ca60c590d4799c1a804cbba8e865b5687c081;hb=2fd7e9189c239ef737105bc085ace4dc80435533;hp=ddb803b1498e6bdad646ed90f4510d071225cbcf;hpb=cd7da117f0ea0f176cd883d50e244ee3fa391c0e;p=gnulib.git diff --git a/lib/argp-help.c b/lib/argp-help.c index ddb803b14..4c0ca60c5 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -3,19 +3,18 @@ This file is part of the GNU C Library. Written by Miles Bader . - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 @@ -375,6 +374,9 @@ struct hol_entry /* The argp from which this option came. */ const struct argp *argp; + + /* Position in the array */ + unsigned ord; }; /* A cluster of entries to reflect the argp tree structure. */ @@ -592,7 +594,7 @@ hol_entry_long_iterate (const struct hol_entry *entry, } /* Iterator that returns true for the first short option. */ -static inline int +static int until_short (const struct argp_option *opt, const struct argp_option *real, const char *domain, void *cookie) { @@ -733,7 +735,7 @@ canon_doc_option (const char **name) return non_opt; } -#define HOL_ENTRY_PTRCMP(a,b) ((a) < (b) ? -1 : 1) +#define HOL_ENTRY_PTRCMP(a,b) ((a)->ord < (b)->ord ? -1 : 1) /* Order ENTRY1 & ENTRY2 by the order which they should appear in a help listing. */ @@ -829,8 +831,14 @@ static void hol_sort (struct hol *hol) { if (hol->num_entries > 0) - qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry), - hol_entry_qcmp); + { + unsigned i; + struct hol_entry *e; + for (i = 0, e = hol->entries; i < hol->num_entries; i++, e++) + e->ord = i; + qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry), + hol_entry_qcmp); + } } /* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow