-/* $OpenBSD: co.c,v 1.126 2019/06/28 13:35:03 deraadt Exp $ */
+/* $OpenBSD: co.c,v 1.127 2023/08/11 05:02:21 guenther Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
const char *author, *date, *state;
char fpath[PATH_MAX];
char *rev_str, *username;
- time_t rcs_mtime = -1;
+ struct timespec rcs_mtime = { .tv_sec = 0, .tv_nsec = UTIME_OMIT };
flags = ret = 0;
kflag = RCS_KWEXP_ERR;
-/* $OpenBSD: rcsclean.c,v 1.56 2016/08/26 09:02:54 guenther Exp $ */
+/* $OpenBSD: rcsclean.c,v 1.57 2023/08/11 05:02:21 guenther Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
*/
#include <sys/types.h>
+#include <sys/stat.h>
#include <dirent.h>
#include <err.h>
char fpath[PATH_MAX], numb[RCS_REV_BUFSZ];
RCSNUM *rev;
BUF *b1, *b2;
- time_t rcs_mtime = -1;
+ struct timespec rcs_mtime = { .tv_sec = 0, .tv_nsec = UTIME_OMIT };
b1 = b2 = NULL;
file = NULL;
-/* $OpenBSD: rcsprog.c,v 1.164 2023/03/08 04:43:12 guenther Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.165 2023/08/11 05:02:21 guenther Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
RCSFILE *file;
RCSNUM *logrev;
struct rcs_access *acp;
- time_t rcs_mtime = -1;
+ struct timespec rcs_mtime = { .tv_sec = 0, .tv_nsec = UTIME_OMIT };
kflag = RCS_KWEXP_ERR;
lkmode = RCS_LOCK_INVAL;
-/* $OpenBSD: rcsutil.c,v 1.47 2020/10/14 20:07:19 naddy Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.48 2023/08/11 05:02:21 guenther Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* rcs_get_mtime()
*
* Get <filename> last modified time.
- * Returns last modified time on success, or -1 on failure.
+ * Returns last modified time on success, or a timespec with tv_nsec
+ * set to UTIME_OMIT on failure.
*/
-time_t
+struct timespec
rcs_get_mtime(RCSFILE *file)
{
struct stat st;
- time_t mtime;
+ struct timespec mtime = { .tv_sec = 0, .tv_nsec = UTIME_OMIT };
if (file->rf_file == NULL)
- return (-1);
+ return mtime;
if (fstat(fileno(file->rf_file), &st) == -1) {
warn("%s", file->rf_path);
- return (-1);
+ return mtime;
}
- mtime = st.st_mtimespec.tv_sec;
-
- return (mtime);
+ return st.st_mtim;
}
/*
* rcs_set_mtime()
*
- * Set <filename> last modified time to <mtime> if it's not set to -1.
+ * Set <filename> last modified time to <mtime> if its tv_nsec isn't UTIME_OMIT
*/
void
-rcs_set_mtime(RCSFILE *file, time_t mtime)
+rcs_set_mtime(RCSFILE *file, struct timespec mtime)
{
- static struct timeval tv[2];
+ struct timespec ts[2];
- if (file->rf_file == NULL || mtime == -1)
+ if (file->rf_file == NULL || mtime.tv_nsec == UTIME_OMIT)
return;
- tv[0].tv_sec = mtime;
- tv[1].tv_sec = tv[0].tv_sec;
+ ts[0] = ts[1] = mtime;
- if (futimes(fileno(file->rf_file), tv) == -1)
+ if (futimens(fileno(file->rf_file), ts) == -1)
err(1, "utimes");
}
-/* $OpenBSD: rcsutil.h,v 1.15 2016/07/04 01:39:12 millert Exp $ */
+/* $OpenBSD: rcsutil.h,v 1.16 2023/08/11 05:02:21 guenther Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
/* rcsutil.c */
int rcs_getopt(int, char **, const char *);
-void rcs_set_mtime(RCSFILE *, time_t);
+void rcs_set_mtime(RCSFILE *, struct timespec);
int rcs_choosefile(const char *, char *, size_t);
-time_t rcs_get_mtime(RCSFILE *);
+struct timespec rcs_get_mtime(RCSFILE *);
RCSNUM *rcs_getrevnum(const char *, RCSFILE *);
char *rcs_prompt(const char *, int);
u_int rcs_rev_select(RCSFILE *, const char *);