From 3202ad2b9e81df3bd61afa56fd2622e115b334c3 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 7 Feb 2003 21:34:34 +0000 Subject: [PATCH] * dump_setup.cc (compar): Use case insensitive comparisons. (dump_setup): Calculate package_len based on already used "len". Don't bother with version_len. --- winsup/utils/ChangeLog | 6 ++++++ winsup/utils/dump_setup.cc | 16 +++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index ec98c1bd5..11fee820e 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,9 @@ +2003-02-07 Christopher Faylor + + * dump_setup.cc (compar): Use case insensitive comparisons. + (dump_setup): Calculate package_len based on already used "len". Don't + bother with version_len. + 2003-02-07 Igor Pechtchanski * dump_setup.cc (dump_setup): Compute the longest package name diff --git a/winsup/utils/dump_setup.cc b/winsup/utils/dump_setup.cc index 0cac2b129..f140e4b2e 100644 --- a/winsup/utils/dump_setup.cc +++ b/winsup/utils/dump_setup.cc @@ -18,7 +18,6 @@ details. */ #include "path.h" static int package_len = 20; -static int version_len = 20; typedef struct @@ -159,7 +158,7 @@ compar (const void *a, const void *b) { const pkgver *pa = (const pkgver *) a; const pkgver *pb = (const pkgver *) b; - return strcmp (pa->name, pb->name); + return strcasecmp (pa->name, pb->name); } } @@ -220,17 +219,13 @@ dump_setup (int verbose, char **argv, bool /*check_files*/) int len = strlen (package); if (f.what[0]) len += strlen (f.what) + 1; + if (len > package_len) + package_len = len; packages[n].name = (char *) malloc (len + 1); strcpy (packages[n].name , package); if (f.what[0]) strcat (strcat (packages[n].name, "-"), f.what); - int pkg_len = strlen(packages[n].name); - if (package_len < pkg_len+1) - package_len = pkg_len+1; packages[n].ver = strdup (f.ver); - int ver_len = strlen(packages[n].ver); - if (version_len < ver_len+1) - version_len = ver_len+1; n++; if (strtok (NULL, " ") == NULL) break; @@ -239,10 +234,9 @@ dump_setup (int verbose, char **argv, bool /*check_files*/) qsort (packages, n, sizeof (packages[0]), compar); - printf ("%-*s%-*s\n", package_len, "Package", version_len, "Version"); + printf ("%-*s %s\n", package_len, "Package", "Version"); for (int i = 0; i < n; i++) - printf ("%-*s%-*s\n", package_len, packages[i].name, - version_len, packages[i].ver); + printf ("%-*s %s\n", package_len, packages[i].name, packages[i].ver); fclose (fp); return;