summaryrefslogtreecommitdiff
path: root/src/tool_help.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-02-25 12:25:15 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-02-27 08:14:07 +0100
commit6cc6a447e62f80e88faf64b40ba2ff3b238be0f6 (patch)
tree6a9c54d965d6d4c9ce69805a186988565a2dd76d /src/tool_help.c
parent15ef24985c8f7a576ffa342226be109e53064d74 (diff)
downloadcurl-6cc6a447e62f80e88faf64b40ba2ff3b238be0f6.tar.gz
curl: display --version features sorted alphabetically
Closes #3611
Diffstat (limited to 'src/tool_help.c')
-rw-r--r--src/tool_help.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/tool_help.c b/src/tool_help.c
index aeffd3dea..414e00b21 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -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)
{
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: ");
+ 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;
}
#ifdef USE_METALINK
- printf("Metalink ");
+ featp[numfeat++] = (char *)"Metalink";
#endif
+ qsort(&featp[0], numfeat, sizeof(char *), featcomp);
+ for(i = 0; i< numfeat; i++)
+ printf(" %s", featp[i]);
puts(""); /* newline */
}
}