diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-01-05 09:15:01 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-01-05 09:15:01 +0000 |
commit | c633f332fb77012f6b1915a98fcf172a05792d4d (patch) | |
tree | 4f89bf3f4e19250fda1ed26b07827ad27ed2157a /usr.bin/cvs | |
parent | 181b211e8430f46f51023a3e1792bc25bb69c695 (diff) |
correctly handle time in notifications.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/edit.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c index 3e4d29e34f9..1bba91a42b9 100644 --- a/usr.bin/cvs/edit.c +++ b/usr.bin/cvs/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.19 2007/01/05 08:52:37 xsa Exp $ */ +/* $OpenBSD: edit.c,v 1.20 2007/01/05 09:15:00 xsa Exp $ */ /* * Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org> * @@ -244,7 +244,7 @@ cvs_edit_local(struct cvs_file *cf) FILE *fp; struct tm *t; time_t now; - char *bfpath, *fdate, thishost[MAXHOSTNAMELEN]; + char *bfpath, timebuf[64], thishost[MAXHOSTNAMELEN]; if (cvs_noexec == 1) return; @@ -257,13 +257,15 @@ cvs_edit_local(struct cvs_file *cf) if ((t = gmtime(&now)) == NULL) fatal("gmtime failed"); - fdate = asctime(t); + asctime_r(t, timebuf); + if (timebuf[strlen(timebuf) - 1] == '\n') + timebuf[strlen(timebuf) - 1] = '\0'; if (gethostname(thishost, sizeof(thishost)) == -1) fatal("gethostname failed"); (void)fprintf(fp, "E%s\t%s GMT\t%s\t%s\t\n", - cf->file_name, fdate, thishost, cf->file_wd); + cf->file_name, timebuf, thishost, cf->file_wd); if (edit_aflags & E_EDIT) (void)fprintf(fp, "E"); @@ -303,7 +305,7 @@ cvs_unedit_local(struct cvs_file *cf) struct stat st; struct tm *t; time_t now; - char *bfpath, *fdate, thishost[MAXHOSTNAMELEN]; + char *bfpath, timebuf[64], thishost[MAXHOSTNAMELEN]; if (cvs_noexec == 1) return; @@ -339,13 +341,15 @@ cvs_unedit_local(struct cvs_file *cf) if ((t = gmtime(&now)) == NULL) fatal("gmtime failed"); - fdate = asctime(t); + asctime_r(t, timebuf); + if (timebuf[strlen(timebuf) - 1] == '\n') + timebuf[strlen(timebuf) - 1] = '\0'; if (gethostname(thishost, sizeof(thishost)) == -1) fatal("gethostname failed"); (void)fprintf(fp, "U%s\t%s GMT\t%s\t%s\t\n", - cf->file_name, fdate, thishost, cf->file_wd); + cf->file_name, timebuf, thishost, cf->file_wd); (void)fclose(fp); |