diff options
author | sobomax <sobomax@FreeBSD.org> | 2001-08-02 13:13:06 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2001-08-02 13:13:06 +0000 |
commit | 77d54406d5ea20673161903b635c712d3013fb9f (patch) | |
tree | 85001974baefbf2b2c1f82bce9cfd587b562449e | |
parent | 404c0eeec630aa6acda2649e65a4305535b2543b (diff) | |
download | FreeBSD-src-77d54406d5ea20673161903b635c712d3013fb9f.zip FreeBSD-src-77d54406d5ea20673161903b635c712d3013fb9f.tar.gz |
Cosmetics: replace dozen instances of "(tmp = getenv(PKG_DBDIR) ? tmp : DEF_LOG_DIR)"
with macro.
MFC after: 1 month
-rw-r--r-- | usr.sbin/pkg_install/add/perform.c | 8 | ||||
-rw-r--r-- | usr.sbin/pkg_install/delete/main.c | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_install/delete/perform.c | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/perform.c | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/deps.c | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/lib.h | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/match.c | 4 |
7 files changed, 15 insertions, 23 deletions
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index dfa6269..06c5028 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -234,7 +234,7 @@ pkg_do(char *pkg) PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous"; /* See if we're already registered */ - sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, PkgName); + sprintf(LogDir, "%s/%s", LOG_DIR, PkgName); if (isdir(LogDir) && !Force) { warnx("package '%s' already recorded as installed", PkgName); code = 1; @@ -403,7 +403,7 @@ pkg_do(char *pkg) code = 1; goto success; /* well, partial anyway */ } - sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, PkgName); + sprintf(LogDir, "%s/%s", LOG_DIR, PkgName); zapLogDir = 1; if (Verbose) printf("Attempting to record package into %s..\n", LogDir); @@ -440,8 +440,8 @@ pkg_do(char *pkg) continue; if (Verbose) printf("Attempting to record dependency on package '%s'\n", p->name); - sprintf(contents, "%s/%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, - basename_of(p->name), REQUIRED_BY_FNAME); + sprintf(contents, "%s/%s/%s", LOG_DIR, basename_of(p->name), + REQUIRED_BY_FNAME); cfile = fopen(contents, "a"); if (!cfile) warnx("can't open dependency file '%s'!\n" diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index f87af3d..2dba240 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -127,7 +127,7 @@ main(int argc, char **argv) if (pkgs == start && MatchType != MATCH_ALL) warnx("missing package name(s)"), usage(); *pkgs = NULL; - tmp = getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR; + tmp = LOG_DIR; (void) stat(tmp, &stat_s); if (!Fake && getuid() && geteuid() != stat_s.st_uid) { if (!Force) diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 4469299..21815f6 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -97,8 +97,7 @@ pkg_do(char *pkg) if (Plist.head) free_plist(&Plist); - sprintf(LogDir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, - pkg); + sprintf(LogDir, "%s/%s", LOG_DIR, pkg); if (!fexists(LogDir)) { warnx("no such package '%s' installed", pkg); @@ -290,9 +289,7 @@ undepend(PackingList p, char *pkgname) char *tmp; int s; - sprintf(fname, "%s/%s/%s", - (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, - p->name, REQUIRED_BY_FNAME); + sprintf(fname, "%s/%s/%s", LOG_DIR, p->name, REQUIRED_BY_FNAME); fp = fopen(fname, "r"); if (fp == NULL) { warnx("couldn't open dependency file '%s'", fname); diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index 2efae9c..a4aa829 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -42,9 +42,7 @@ pkg_perform(char **pkgs) signal(SIGINT, cleanup); - tmp = getenv(PKG_DBDIR); - if (!tmp) - tmp = DEF_LOG_DIR; + tmp = LOG_DIR; /* Overriding action? */ if (CheckPkg) { @@ -147,8 +145,7 @@ pkg_do(char *pkg) else { char *tmp; - sprintf(log_dir, "%s/%s", (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, - pkg); + sprintf(log_dir, "%s/%s", LOG_DIR, pkg); if (!fexists(log_dir)) { warnx("can't find package '%s' installed or in a file!", pkg); return 1; diff --git a/usr.sbin/pkg_install/lib/deps.c b/usr.sbin/pkg_install/lib/deps.c index 84d5c47..802d6c8 100644 --- a/usr.sbin/pkg_install/lib/deps.c +++ b/usr.sbin/pkg_install/lib/deps.c @@ -88,9 +88,7 @@ chkifdepends(char *pkgname1, char *pkgname2) char *tmp; int retval; - sprintf(fname, "%s/%s/%s", - (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR, - pkgname2, REQUIRED_BY_FNAME); + sprintf(fname, "%s/%s/%s", LOG_DIR, pkgname2, REQUIRED_BY_FNAME); fp = fopen(fname, "r"); if (fp == NULL) { /* Probably pkgname2 doesn't have any packages that depend on it */ diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 841b735..f8965a0 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -57,9 +57,11 @@ #define RMDIR_CMD "rmdir" /* Where we put logging information by default, else ${PKG_DBDIR} if set */ -#define DEF_LOG_DIR "/var/db/pkg" +#define DEF_LOG_DIR "/var/db/pkg" /* just in case we change the environment variable name */ -#define PKG_DBDIR "PKG_DBDIR" +#define PKG_DBDIR "PKG_DBDIR" +/* macro to get name of directory where we put logging information */ +#define LOG_DIR (getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR) /* The names of our "special" files */ #define CONTENTS_FNAME "+CONTENTS" diff --git a/usr.sbin/pkg_install/lib/match.c b/usr.sbin/pkg_install/lib/match.c index 4128e07..2c2ba0d 100644 --- a/usr.sbin/pkg_install/lib/match.c +++ b/usr.sbin/pkg_install/lib/match.c @@ -85,9 +85,7 @@ matchinstalled(match_t MatchType, char **patterns, int *retval) if (retval != NULL) *retval = 0; - tmp = getenv(PKG_DBDIR); - if (!tmp) - tmp = DEF_LOG_DIR; + tmp = LOG_DIR; if (!isdir(tmp)) { if (retval != NULL) *retval = 1; |