[tz] [PROPOSED PATCH 1/3] date: port to Ubuntu 14.04 with -DHAVE_UTMPX_H=1

Paul Eggert eggert at cs.ucla.edu
Fri Aug 15 05:53:45 UTC 2014


* date.c (WTMPX_FILE): Define to _PATH_WTMPX if not already defined
and if _PATH_WTMPX is defined.
(reset): Do not use WTMPX_FILE if it is not defined.
* NEWS: Document this.
---
 NEWS   | 5 +++++
 date.c | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 2c8b474..a8218f1 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,11 @@ Unreleased, experimental changes
     tzselect -c now uses a hybrid distance measure that works better
     in Africa.  (Thanks to Alan Barrett for noting the problem.)
 
+    When HAVE_UTMPX_H is set the 'date' command now builds on systems
+    whose <utmpx.h> file does not define WTMPX_FILE, and when setting
+    the date it updates the wtmpx file if _PATH_WTMPX is defined.
+    This affects GNU/Linux and similar systems.
+
   Changes affecting distribution tarballs
 
     The files checktab.awk and zoneinfo2tdf.pl are now distributed in
diff --git a/date.c b/date.c
index 9a0b84c..3d78914 100644
--- a/date.c
+++ b/date.c
@@ -31,6 +31,9 @@
 #ifndef NTIME_MSG
 #define NTIME_MSG "new time"
 #endif
+#if !defined WTMPX_FILE && defined _PATH_WTMPX
+# define WTMPX_FILE _PATH_WTMPX
+#endif
 
 /*
 ** The two things date knows about time are. . .
@@ -378,7 +381,7 @@ reset(const time_t newt, const int nflag)
 	sx.after.ut_type = NEW_TIME;
 	sx.after.ut_tv.tv_sec = newt;
 	(void) strcpy(sx.after.ut_line, NTIME_MSG);
-#if !SUPPRESS_WTMPX_FILE_UPDATE
+#if defined WTMPX_FILE && !SUPPRESS_WTMPX_FILE_UPDATE
 	/* In Solaris 2.5 (and presumably other systems),
 	   'date' does not update /var/adm/wtmpx.
 	   This must be a bug.  If you'd like to reproduce the bug,
@@ -390,7 +393,7 @@ reset(const time_t newt, const int nflag)
 		oops(_("log file write"));
 	if (close(fid) != 0)
 		oops(_("log file close"));
-#endif /* !SUPPRESS_WTMPX_FILE_UPDATE */
+# endif
 	pututxline(&sx.before);
 	pututxline(&sx.after);
 #endif /* HAVE_UTMPX_H */
-- 
1.9.1



More information about the tz mailing list