From cd63fa3c14634d47085a96dbaf1e4c3517ddde7a Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 4 Oct 2024 11:30:50 +0100 Subject: [PATCH] K&R calma: remove system header time() K&R style prototype time.h has existed since C89 so is a standard header expected to always be available. sys/time.h was an optional header that historically only some platforms provided. If there is a conflict on specific platforms it is better to '#if !defined()' that specific niche platform with the problem if both headers are included in the same compile unit. But I don't think this is a problem in modern times. So this results in a resolution that removes #ifdef around time.h and the detection by configure for the availabiltiy of sys/time.h. K&R obsolete syntax removal for C23 compatibility series --- calma/CalmaWrite.c | 8 ++------ scripts/configure.in | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index 600bfb66..b4a7da63 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -28,9 +28,8 @@ static char rcsid[] __attribute__ ((unused)) ="$Header: /usr/cvsroot/magic-8.0/c #include #include #include /* for htons() */ -#if defined(SYSV) || defined(EMSCRIPTEN) -#include -#else +#include /* since C89 */ +#ifdef HAVE_SYS_TIME_H #include #endif @@ -164,9 +163,6 @@ HashTable calmaLibHash; HashTable calmaPrefixHash; HashTable calmaUndefHash; -/* Imports */ -extern time_t time(); - /* -------------------------------------------------------------------- */ diff --git a/scripts/configure.in b/scripts/configure.in index befde369..704c6080 100644 --- a/scripts/configure.in +++ b/scripts/configure.in @@ -150,6 +150,9 @@ AC_CHECK_HEADERS(param.h) dnl Check for AC_CHECK_HEADERS(paths.h) +dnl Check for +AC_CHECK_HEADERS(sys/time.h) + dnl Check for va_copy AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, AC_TRY_LINK(