Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Feb 2012 03:37:29 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r231109 - stable/8/usr.sbin/pkg_install/info
Message-ID:  <201202070337.q173bTTD066894@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue Feb  7 03:37:29 2012
New Revision: 231109
URL: http://svn.freebsd.org/changeset/base/231109

Log:
  MFC r226697 and r226708:
  
    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 / .
  
    Staticify elide_root() for now to fix build.

Modified:
  stable/8/usr.sbin/pkg_install/info/show.c
Directory Properties:
  stable/8/usr.sbin/pkg_install/info/   (props changed)

Modified: stable/8/usr.sbin/pkg_install/info/show.c
==============================================================================
--- stable/8/usr.sbin/pkg_install/info/show.c	Tue Feb  7 03:34:57 2012	(r231108)
+++ stable/8/usr.sbin/pkg_install/info/show.c	Tue Feb  7 03:37:29 2012	(r231109)
@@ -207,6 +207,14 @@ show_plist(const char *title, Package *p
     }
 }
 
+static 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 &&



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202070337.q173bTTD066894>