Module Name: src Committed By: christos Date: Wed Aug 17 13:48:11 UTC 2011
Modified Files: src/usr.bin/w: Makefile pr_time.c Log Message: Eliminate non-literal format strings, and now that gcc warns, kill y2k format warning. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.bin/w/Makefile cvs rdiff -u -r1.17 -r1.18 src/usr.bin/w/pr_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/w/Makefile diff -u src/usr.bin/w/Makefile:1.19 src/usr.bin/w/Makefile:1.20 --- src/usr.bin/w/Makefile:1.19 Wed Feb 26 10:01:09 2003 +++ src/usr.bin/w/Makefile Wed Aug 17 09:48:11 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.19 2003/02/26 15:01:09 christos Exp $ +# $NetBSD: Makefile,v 1.20 2011/08/17 13:48:11 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include <bsd.own.mk> @@ -13,4 +13,6 @@ .PATH: ${NETBSDSRCDIR}/bin/ps +COPTS.pr_time.c += -Wno-format-y2k + .include <bsd.prog.mk> Index: src/usr.bin/w/pr_time.c diff -u src/usr.bin/w/pr_time.c:1.17 src/usr.bin/w/pr_time.c:1.18 --- src/usr.bin/w/pr_time.c:1.17 Tue Apr 14 03:41:36 2009 +++ src/usr.bin/w/pr_time.c Wed Aug 17 09:48:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_time.c,v 1.17 2009/04/14 07:41:36 lukem Exp $ */ +/* $NetBSD: pr_time.c,v 1.18 2011/08/17 13:48:11 christos Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)pr_time.c 8.2 (Berkeley) 4/4/94"; #else -__RCSID("$NetBSD: pr_time.c,v 1.17 2009/04/14 07:41:36 lukem Exp $"); +__RCSID("$NetBSD: pr_time.c,v 1.18 2011/08/17 13:48:11 christos Exp $"); #endif #endif /* not lint */ @@ -62,25 +62,22 @@ int tnow_yday; struct tm *tp; time_t diff; - const char *fmt; tnow_yday = localtime(now)->tm_yday; tp = localtime(started); diff = *now - *started; - /* If more than a week, use day-month-year. */ - if (diff > SECSPERDAY * DAYSPERWEEK) - fmt = "%d%b%y"; - - /* If not today, use day-hour-am/pm. */ - else if (tp->tm_yday != tnow_yday) - fmt = "%a%" "I%p"; - - /* Default is hh:mm{am,pm}. */ - else - fmt = "%l:%" "M%p"; + if (diff > SECSPERDAY * DAYSPERWEEK) { + /* If more than a week, use day-month-year. */ + (void)strftime(buf, sizeof(buf), "%d%b%y", tp); + } else if (tp->tm_yday != tnow_yday) { + /* If not today, use day-hour-am/pm. Damn SCCS */ + (void)strftime(buf, sizeof(buf), "%a%" "I%p", tp); + } else { + /* Default is hh:mm{am,pm}. Damn SCCS */ + (void)strftime(buf, sizeof(buf), "%l:%" "M%p", tp); + } - (void)strftime(buf, sizeof(buf), fmt, tp); buf[sizeof(buf) - 1] = '\0'; (void)fputs(buf, stdout); }