From: Andi Kleen <a...@linux.intel.com>

---
 tools/perf/util/pmu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index cc888d9..26311d9 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -737,11 +737,51 @@ static char *format_alias_or(char *buf, int len, struct 
perf_pmu *pmu,
        return buf;
 }
 
-static int cmp_string(const void *a, const void *b)
+struct pair {
+       char *name;
+       char *desc;
+};
+
+static int cmp_pair(const void *a, const void *b)
+{
+       const struct pair *as = a;
+       const struct pair *bs = b;
+
+       /* Put downloaded event list last */
+       if (!!as->desc != !!bs->desc)
+               return !!as->desc - !!bs->desc;
+       return strcmp(as->name, bs->name);
+}
+
+static void wordwrap(char *s, int start, int max, int corr)
+{
+       int column = start;
+       int n;
+
+       while (*s) {
+               int wlen = strcspn(s, " \t");
+
+               if (column + wlen >= max && column > start) {
+                       printf("\n%*s", start, "");
+                       column = start + corr;
+               }
+               n = printf("%s%.*s", column > start ? " " : "", wlen, s);
+               if (n <= 0)
+                       break;
+               s += wlen;
+               column += n;
+               while (isspace(*s))
+                       s++;
+       }
+}
+
+static int get_columns(void)
 {
-       const char * const *as = a;
-       const char * const *bs = b;
-       return strcmp(*as, *bs);
+       /*
+        * Should ask the terminal with TIOCGWINSZ here, but we
+        * need the original fd before the pager.
+        */
+       return 79;
 }
 
 void print_pmu_events(const char *event_glob, bool name_only)
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to