utime-h: New module.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Apr 2017 08:21:22 +0000 (10:21 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Apr 2017 08:21:22 +0000 (10:21 +0200)
* m4/utime_h.m4: New file.
* lib/utime.in.h: New file.
* modules/utime-h: New file.
* doc/posix-headers/utime.texi: Mention the new module.

* tests/test-utime-h.c: New file.
* modules/utime-h-tests: New file.

ChangeLog
doc/posix-headers/utime.texi
lib/utime.in.h [new file with mode: 0644]
m4/utime_h.m4 [new file with mode: 0644]
modules/utime-h [new file with mode: 0644]
modules/utime-h-tests [new file with mode: 0644]
tests/test-utime-h.c [new file with mode: 0644]

index 7eb1ad6021eeb80317e60c496de572b72e1c7fdc..fad9adf6cbcdc44714768aa5423989e358c268c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-04-29  Bruno Haible  <bruno@clisp.org>
+
+       utime-h: New module.
+       * m4/utime_h.m4: New file.
+       * lib/utime.in.h: New file.
+       * modules/utime-h: New file.
+       * doc/posix-headers/utime.texi: Mention the new module.
+
+       * tests/test-utime-h.c: New file.
+       * modules/utime-h-tests: New file.
+
 2017-04-30  Bruno Haible  <bruno@clisp.org>
 
        Fix a few typos.
index cdeb019ea34ff7a5a8883af87189af1eb28b8026..8db231d20c035c98586ece5916d9deacc2cd2f81 100644 (file)
@@ -3,15 +3,14 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/basedefs/utime.h.html}
 
-Gnulib module: ---
+Gnulib module: utime-h
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This header file is missing on some platforms: MSVC 14.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This header file is missing on some platforms: MSVC 9.  Use @code{<sys/utime.h>}
-if @code{<utime.h>} is missing.
 @end itemize
diff --git a/lib/utime.in.h b/lib/utime.in.h
new file mode 100644 (file)
index 0000000..0e3926a
--- /dev/null
@@ -0,0 +1,22 @@
+/* Substitute for <utime.h>
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _@GUARD_PREFIX@_UTIME_H
+#define _@GUARD_PREFIX@_UTIME_H
+
+#include <sys/utime.h>
+
+#endif /* _@GUARD_PREFIX@_UTIME_H */
diff --git a/m4/utime_h.m4 b/m4/utime_h.m4
new file mode 100644 (file)
index 0000000..c29ae42
--- /dev/null
@@ -0,0 +1,19 @@
+# utime_h.m4 serial 1
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_UTIME_H],
+[
+  UTIME_H=''
+  AC_CHECK_HEADERS_ONCE([utime.h])
+  if test $ac_cv_header_utime_h != yes; then
+    dnl Provide a substitute <utime.h> file.
+    UTIME_H=utime.h
+  fi
+  AC_SUBST([UTIME_H])
+  AM_CONDITIONAL([GL_GENERATE_UTIME_H], [test -n "$UTIME_H"])
+])
diff --git a/modules/utime-h b/modules/utime-h
new file mode 100644 (file)
index 0000000..6e32c50
--- /dev/null
@@ -0,0 +1,39 @@
+Description:
+A <utime.h> that conforms to POSIX.
+
+Files:
+lib/utime.in.h
+m4/utime_h.m4
+
+Depends-on:
+
+configure.ac:
+gl_UTIME_H
+
+Makefile.am:
+BUILT_SOURCES += $(UTIME_H)
+
+# We need the following in order to create <utime.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_UTIME_H
+utime.h: utime.in.h $(top_builddir)/config.status
+       $(AM_V_GEN)rm -f $@-t $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
+             < $(srcdir)/utime.in.h; \
+       } > $@-t && \
+       mv $@-t $@
+else
+utime.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += utime.h utime.h-t
+
+Include:
+<utime.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/utime-h-tests b/modules/utime-h-tests
new file mode 100644 (file)
index 0000000..804fd60
--- /dev/null
@@ -0,0 +1,10 @@
+Files:
+tests/test-utime-h.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-utime-h
+check_PROGRAMS += test-utime-h
diff --git a/tests/test-utime-h.c b/tests/test-utime-h.c
new file mode 100644 (file)
index 0000000..a694024
--- /dev/null
@@ -0,0 +1,32 @@
+/* Test of <utime.h> substitute.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2017.  */
+
+#include <config.h>
+
+#include <utime.h>
+
+/* Check that 'struct utimbuf' is defined.  */
+struct utimbuf b;
+
+int
+main (void)
+{
+  b.actime = b.modtime = 1493490248; /* 2017-04-29 18:24:08 GMT */
+
+  return 0;
+}