summaryrefslogtreecommitdiffstats
path: root/usr.bin/rcs/rcsutil.c
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2010-10-20 19:53:53 +0000
committertobias <tobias@openbsd.org>2010-10-20 19:53:53 +0000
commit394437e69217ff52d485085d17fba7362e00e4bf (patch)
tree8bb593072c9cb02626742068bc3a45a5fa38c5a3 /usr.bin/rcs/rcsutil.c
parentMark repeating keys with "(repeat)" in the key list. (diff)
downloadwireguard-openbsd-394437e69217ff52d485085d17fba7362e00e4bf.tar.xz
wireguard-openbsd-394437e69217ff52d485085d17fba7362e00e4bf.zip
Remove the need for rp_file in parser structure, instead keep only one
FILE pointer in RCSFILE. This fixes some ugliness in closing an fdopen()ed FILE and its underlying file descriptor. Notified by Joerg Sonnenberger <joerg at britannica dot bec to de> discussed with and ok nicm
Diffstat (limited to 'usr.bin/rcs/rcsutil.c')
-rw-r--r--usr.bin/rcs/rcsutil.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index 54f737f5c52..5ea5dd12285 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.36 2010/09/08 15:15:50 tobias Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.37 2010/10/20 19:53:53 tobias Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -50,7 +50,10 @@ rcs_get_mtime(RCSFILE *file)
struct stat st;
time_t mtime;
- if (fstat(file->rf_fd, &st) == -1) {
+ if (file->rf_file == NULL)
+ return (-1);
+
+ if (fstat(fileno(file->rf_file), &st) == -1) {
warn("%s", file->rf_path);
return (-1);
}
@@ -70,13 +73,13 @@ rcs_set_mtime(RCSFILE *file, time_t mtime)
{
static struct timeval tv[2];
- if (mtime == -1)
+ if (file->rf_file == NULL || mtime == -1)
return;
tv[0].tv_sec = mtime;
tv[1].tv_sec = tv[0].tv_sec;
- if (futimes(file->rf_fd, tv) == -1)
+ if (futimes(fileno(file->rf_file), tv) == -1)
err(1, "utimes");
}