mirror of
https://github.com/curl/curl.git
synced 2025-04-12 16:20:35 +08:00
curl: follow-up to fix categories in --help
The commit 6483813b was missing changes necessitated by 2abfc75 that causes a crash. Also, use ARRAYSIZE() for cleaner code. Follow-up to 6483813b Ref #14055
This commit is contained in:
parent
6483813be2
commit
127aa61f06
@ -39,6 +39,10 @@
|
||||
# define USE_WATT32
|
||||
#endif
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
struct category_descriptors {
|
||||
const char *opt;
|
||||
const char *desc;
|
||||
@ -112,7 +116,7 @@ static void print_category(unsigned int category, unsigned int cols)
|
||||
static int get_category_content(const char *category, unsigned int cols)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(categories)/sizeof(categories[0]); ++i)
|
||||
for(i = 0; i < ARRAYSIZE(categories); ++i)
|
||||
if(curl_strequal(categories[i].opt, category)) {
|
||||
printf("%s: %s\n", categories[i].opt, categories[i].desc);
|
||||
print_category(categories[i].category, cols);
|
||||
@ -125,7 +129,7 @@ static int get_category_content(const char *category, unsigned int cols)
|
||||
static void get_categories(void)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < sizeof(categories)/sizeof(categories[0]); ++i)
|
||||
for(i = 0; i < ARRAYSIZE(categories); ++i)
|
||||
printf(" %-11s %s\n", categories[i].opt, categories[i].desc);
|
||||
}
|
||||
|
||||
@ -134,9 +138,9 @@ static void get_categories_list(unsigned int width)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t col = 0;
|
||||
for(i = 0; categories[i].opt; ++i) {
|
||||
for(i = 0; i < ARRAYSIZE(categories); ++i) {
|
||||
size_t len = strlen(categories[i].opt);
|
||||
if(!categories[i + 1].opt) {
|
||||
if(i == ARRAYSIZE(categories) - 1) {
|
||||
/* final category */
|
||||
if(col + len + 1 < width)
|
||||
printf("%s.\n", categories[i].opt);
|
||||
|
@ -47,8 +47,9 @@ Usage: curl [options...] <url>
|
||||
|
||||
This is not the full help; this menu is split into categories.
|
||||
Use "--help category" to get an overview of all categories, which are:
|
||||
auth, connection, curl, dns, file, ftp, http, imap, misc, output, pop3, post,
|
||||
proxy, scp, sftp, smtp, ssh, telnet, tftp, tls, ech, upload, verbose.
|
||||
auth, connection, curl, deprecated, dns, file, ftp, global, http, imap, ldap,
|
||||
output, pop3, post, proxy, scp, sftp, smtp, ssh, telnet, tftp, timeout, tls,
|
||||
upload, verbose.
|
||||
For all options use the manual or "--help all".
|
||||
</stdout>
|
||||
</verify>
|
||||
|
Loading…
x
Reference in New Issue
Block a user