From owner-svn-src-all@FreeBSD.ORG Mon Oct 24 18:29:50 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0EDE106566B; Mon, 24 Oct 2011 18:29:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B084F8FC13; Mon, 24 Oct 2011 18:29:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9OIToe8056777; Mon, 24 Oct 2011 18:29:50 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9OIToRK056775; Mon, 24 Oct 2011 18:29:50 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201110241829.p9OIToRK056775@svn.freebsd.org> From: Ed Maste Date: Mon, 24 Oct 2011 18:29:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226697 - head/usr.sbin/pkg_install/info X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2011 18:29:50 -0000 Author: emaste Date: Mon Oct 24 18:29:50 2011 New Revision: 226697 URL: http://svn.freebsd.org/changeset/base/226697 Log: Avoid printing // for packages that install to / I have some packages that install to / (for whatever reason). Right now we print entries of the form //path/to/file when listing files (pkg_info -L, pkg_info -g etc.) This change avoids printing the redundant / . Modified: head/usr.sbin/pkg_install/info/show.c Modified: head/usr.sbin/pkg_install/info/show.c ============================================================================== --- head/usr.sbin/pkg_install/info/show.c Mon Oct 24 17:09:22 2011 (r226696) +++ head/usr.sbin/pkg_install/info/show.c Mon Oct 24 18:29:50 2011 (r226697) @@ -207,6 +207,14 @@ show_plist(const char *title, Package *p } } +const char * +elide_root(const char *dir) +{ + if (strcmp(dir, "/") == 0) + return ""; + return dir; +} + /* Show all files in the packing list (except ignored ones) */ void show_files(const char *title, Package *plist) @@ -223,7 +231,7 @@ show_files(const char *title, Package *p switch(p->type) { case PLIST_FILE: if (!ign) - printf("%s/%s\n", dir, p->name); + printf("%s/%s\n", elide_root(dir), p->name); ign = FALSE; break; @@ -270,7 +278,7 @@ show_size(const char *title, Package *pl switch (p->type) { case PLIST_FILE: if (!ign) { - snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name); + snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name); if (!lstat(tmp, &sb)) { size += sb.st_size; if (Verbose) @@ -328,7 +336,7 @@ show_cksum(const char *title, Package *p else dir = p->name; } else if (p->type == PLIST_FILE) { - snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name); + snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name); if (!fexists(tmp)) warnx("%s doesn't exist", tmp); else if (p->next && p->next->type == PLIST_COMMENT &&