Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/sortinfo sort properly.



details:   https://anonhg.NetBSD.org/src/rev/44972199cb72
branches:  trunk
changeset: 342393:44972199cb72
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 20 00:48:36 2015 +0000

description:
sort properly.

diffstat:

 usr.bin/sortinfo/sortinfo.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 87e6e2798b24 -r 44972199cb72 usr.bin/sortinfo/sortinfo.c
--- a/usr.bin/sortinfo/sortinfo.c       Sun Dec 20 00:40:44 2015 +0000
+++ b/usr.bin/sortinfo/sortinfo.c       Sun Dec 20 00:48:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sortinfo.c,v 1.3 2015/12/20 00:40:44 christos Exp $    */
+/*     $NetBSD: sortinfo.c,v 1.4 2015/12/20 00:48:36 christos Exp $    */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: sortinfo.c,v 1.3 2015/12/20 00:40:44 christos Exp $");
+__RCSID("$NetBSD: sortinfo.c,v 1.4 2015/12/20 00:48:36 christos Exp $");
 
 /*
  * Sort a texinfo(1) directory file.
@@ -89,6 +89,14 @@
        return strcmp(sa->name, sb->name);
 }
 
+static int
+strptrcmp(const void *a, const void *b)
+{
+       const char *sa = *(const char * const *)a;
+       const char *sb = *(const char * const *)b;
+       return strcmp(sa, sb);
+}
+
 static void
 printsection(const struct section *s)
 {
@@ -138,8 +146,8 @@
 
        qsort(slist, nsections, sizeof(*slist), compsection);
        for (i = 0; i < nsections; i++) {
-               qsort(s->lines, s->nlines, sizeof(*s->lines),
-                   (int(*)(const void *, const void *))strcmp);
+               s = &slist[i];
+               qsort(s->lines, s->nlines, sizeof(*s->lines), strptrcmp);
                printsection(&slist[i]);
        }
 



Home | Main Index | Thread Index | Old Index