1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 08:38:49 -05:00

curl: display --version features sorted alphabetically

Closes #3611
This commit is contained in:
Daniel Stenberg 2019-02-25 12:25:15 +01:00
parent 15ef24985c
commit 6cc6a447e6
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -540,6 +540,21 @@ void tool_help(void)
} }
} }
static int
featcomp(const void *p1, const void *p2)
{
/* The arguments to this function are "pointers to pointers to char", but
the comparison arguments are "pointers to char", hence the following cast
plus dereference */
#ifdef HAVE_STRCASECMP
return strcasecmp(* (char * const *) p1, * (char * const *) p2);
#elif defined(HAVE_STRCMPI)
return strcmpi(* (char * const *) p1, * (char * const *) p2);
#else
return strcmp(* (char * const *) p1, * (char * const *) p2);
#endif
}
void tool_version_info(void) void tool_version_info(void)
{ {
const char *const *proto; const char *const *proto;
@ -559,15 +574,20 @@ void tool_version_info(void)
puts(""); /* newline */ puts(""); /* newline */
} }
if(curlinfo->features) { if(curlinfo->features) {
char *featp[ sizeof(feats) / sizeof(feats[0]) + 1];
size_t numfeat = 0;
unsigned int i; unsigned int i;
printf("Features:"); printf("Features:");
for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) { for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
if(curlinfo->features & feats[i].bitmask) if(curlinfo->features & feats[i].bitmask)
printf("%s ", feats[i].name); featp[numfeat++] = (char *)feats[i].name;
} }
#ifdef USE_METALINK #ifdef USE_METALINK
printf("Metalink "); featp[numfeat++] = (char *)"Metalink";
#endif #endif
qsort(&featp[0], numfeat, sizeof(char *), featcomp);
for(i = 0; i< numfeat; i++)
printf(" %s", featp[i]);
puts(""); /* newline */ puts(""); /* newline */
} }
} }