summaryrefslogtreecommitdiffstats
path: root/usr.bin/cvs/file.c
diff options
context:
space:
mode:
authorxsa <xsa@openbsd.org>2005-08-03 14:43:08 +0000
committerxsa <xsa@openbsd.org>2005-08-03 14:43:08 +0000
commit58cbd44da9325a339f78cedbee406fe5206e509d (patch)
tree09b370af72eda260e7027620a8344598febf340a /usr.bin/cvs/file.c
parentimprove description of -a and -s a little; (diff)
downloadwireguard-openbsd-58cbd44da9325a339f78cedbee406fe5206e509d.tar.xz
wireguard-openbsd-58cbd44da9325a339f78cedbee406fe5206e509d.zip
check only once for the HOME environment variable and reuse
its value (if any) to check for the .cvsrc and .cvsignore files; ok jfb@ joris@.
Diffstat (limited to 'usr.bin/cvs/file.c')
-rw-r--r--usr.bin/cvs/file.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index d1cd3263d55..7a0931d7b3a 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.110 2005/07/30 21:16:17 moritz Exp $ */
+/* $OpenBSD: file.c,v 1.111 2005/08/03 14:43:08 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -128,7 +128,6 @@ cvs_file_init(void)
size_t len;
char path[MAXPATHLEN], buf[MAXNAMLEN];
FILE *ifp;
- struct passwd *pwd;
TAILQ_INIT(&cvs_ign_pats);
@@ -140,35 +139,30 @@ cvs_file_init(void)
cvs_file_ignore(cvs_ign_std[i]);
/* read the cvsignore file in the user's home directory, if any */
- pwd = getpwuid(getuid());
- if (pwd != NULL) {
- l = snprintf(path, sizeof(path), "%s/.cvsignore", pwd->pw_dir);
- if (l == -1 || l >= (int)sizeof(path)) {
- errno = ENAMETOOLONG;
- cvs_log(LP_ERRNO, "%s", path);
- return (-1);
- }
+ l = snprintf(path, sizeof(path), "%s/.cvsignore", cvs_homedir);
+ if (l == -1 || l >= (int)sizeof(path)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", path);
+ return (-1);
+ }
- ifp = fopen(path, "r");
- if (ifp == NULL) {
- if (errno != ENOENT)
- cvs_log(LP_ERRNO,
- "failed to open user's cvsignore file "
- "`%s'", path);
- } else {
- while (fgets(buf, sizeof(buf), ifp) != NULL) {
- len = strlen(buf);
- if (len == 0)
- continue;
- if (buf[len - 1] != '\n') {
- cvs_log(LP_ERR, "line too long in `%s'",
- path);
- }
- buf[--len] = '\0';
- cvs_file_ignore(buf);
+ ifp = fopen(path, "r");
+ if (ifp == NULL) {
+ if (errno != ENOENT)
+ cvs_log(LP_ERRNO,
+ "failed to open user's cvsignore file `%s'", path);
+ } else {
+ while (fgets(buf, sizeof(buf), ifp) != NULL) {
+ len = strlen(buf);
+ if (len == 0)
+ continue;
+ if (buf[len - 1] != '\n') {
+ cvs_log(LP_ERR, "line too long in `%s'", path);
}
- (void)fclose(ifp);
+ buf[--len] = '\0';
+ cvs_file_ignore(buf);
}
+ (void)fclose(ifp);
}
return (0);