Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl: display --version features sorted alphabetically #3611

wants to merge 2 commits into from
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -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 */
return strcasecmp(* (char * const *) p1, * (char * const *) p2);
#elif defined(HAVE_STRCMPI)
return strcmpi(* (char * const *) p1, * (char * const *) p2);
return strcmp(* (char * const *) p1, * (char * const *) p2);

This comment has been minimized.

Copy link

danielgustafsson Feb 25, 2019


Does it make sense to always use the least common denominator in order to make the output consistent across plattforms?

This comment has been minimized.

Copy link

bagder Feb 25, 2019

Author Member

Maybe. I'm not sure how common the case is without a case sensitive function here.

I think sorting it case sensitively makes it look funny since the lowercase features end up last.

I first wanted to use curl_strequal for this, but it doesn't offer the correct return code so we can't use that. (and I didn't feel like refactor everything to make such a version available)

An alternative could be to always specify features with an uppercase first letter to sort of shortcut this, but then I think "Libz" looks odd...


void tool_version_info(void)
const char *const *proto;
@@ -559,15 +574,20 @@ void tool_version_info(void)
puts(""); /* newline */
if(curlinfo->features) {
char *featp[ sizeof(feats) / sizeof(feats[0]) + 1];
size_t numfeat = 0;
unsigned int i;
printf("Features: ");
for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
if(curlinfo->features & feats[i].bitmask)
printf("%s ", feats[i].name);
featp[numfeat++] = (char *)feats[i].name;
printf("Metalink ");
featp[numfeat++] = (char *)"Metalink";
qsort(&featp[0], numfeat, sizeof(char *), featcomp);
for(i = 0; i< numfeat; i++)
printf(" %s", featp[i]);
puts(""); /* newline */
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.