New module 'ftello'.
authorBruno Haible <bruno@clisp.org>
Wed, 25 Apr 2007 07:51:53 +0000 (07:51 +0000)
committerBruno Haible <bruno@clisp.org>
Wed, 25 Apr 2007 07:51:53 +0000 (07:51 +0000)
ChangeLog
lib/stdio_.h
m4/ftello.m4 [new file with mode: 0644]
m4/stdio_h.m4
modules/ftello [new file with mode: 0644]
modules/stdio

index a7062cbfc1a10d010a8cfa67c39c8371c16c35d2..b5f1ee170e61aef8b9b26387d1fdad147287316c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-04-25  Bruno Haible  <bruno@clisp.org>
+
+       * modules/ftello: New file.
+       * m4/ftello.m4: New file.
+       * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Set also GNULIB_FTELLO,
+       HAVE_FTELLO.
+       * lib/stdio_.h (ftello): New declaration.
+       * modules/stdio (Makefile.am): Substitute also GNULIB_FTELLO,
+       HAVE_FTELLO.
+
 2007-04-25  Bruno Haible  <bruno@clisp.org>
 
        * modules/fseeko-tests: New file.
index 54024d28521608306c7faf300c719511256b58fc..46ec407c9ca27d2be7a00fe1813da7a2bebefc27 100644 (file)
@@ -220,6 +220,19 @@ extern int vsprintf (char *str, const char *format, va_list args)
     fseeko (f, o, w))
 #endif
 
+#if @GNULIB_FTELLO@
+# if !@HAVE_FTELLO@
+/* Assume 'off_t' is the same type as 'long'.  */
+#  define ftello ftell
+# endif
+#else
+# undef ftello
+# define ftello(f) \
+   (GL_LINK_WARNING ("ftello is unportable - " \
+                     "use gnulib module ftello for portability"), \
+    ftello (f))
+#endif
+
 #if @GNULIB_FFLUSH@
 # if @REPLACE_FFLUSH@
 #  define fflush rpl_fflush
diff --git a/m4/ftello.m4 b/m4/ftello.m4
new file mode 100644 (file)
index 0000000..c2b826d
--- /dev/null
@@ -0,0 +1,19 @@
+# ftello.m4 serial 1
+dnl Copyright (C) 2007 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.
+
+AC_DEFUN([gl_FUNC_FTELLO],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_REQUIRE([AC_PROG_CC])
+  AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
+    [
+      AC_TRY_LINK([#include <stdio.h>], [ftello (stdin);],
+        [gl_cv_func_ftello=yes], [gl_cv_func_ftello=no])
+    ])
+  if test $gl_cv_func_ftello = no; then
+    HAVE_FTELLO=0
+  fi
+])
index 06bbea024866f1d02c715d7d4d77204f788c7a3c..c696ee2ee75410a7dc6143a0d49daea39e89bfae 100644 (file)
@@ -31,6 +31,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
   GNULIB_VASPRINTF=0;      AC_SUBST([GNULIB_VASPRINTF])
   GNULIB_FSEEKO=0;         AC_SUBST([GNULIB_FSEEKO])
+  GNULIB_FTELLO=0;         AC_SUBST([GNULIB_FTELLO])
   GNULIB_FFLUSH=0;         AC_SUBST([GNULIB_FFLUSH])
   dnl Assume proper GNU behavior unless another module says otherwise.
   REPLACE_FPRINTF=0;       AC_SUBST([REPLACE_FPRINTF])
@@ -46,5 +47,6 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   HAVE_VASPRINTF=1;        AC_SUBST([HAVE_VASPRINTF])
   REPLACE_VASPRINTF=0;     AC_SUBST([REPLACE_VASPRINTF])
   HAVE_FSEEKO=1;           AC_SUBST([HAVE_FSEEKO])
+  HAVE_FTELLO=1;           AC_SUBST([HAVE_FTELLO])
   REPLACE_FFLUSH=0;        AC_SUBST([REPLACE_FFLUSH])
 ])
diff --git a/modules/ftello b/modules/ftello
new file mode 100644 (file)
index 0000000..0994f10
--- /dev/null
@@ -0,0 +1,24 @@
+Description:
+ftello() function: Retrieve the position of a FILE stream.
+
+Files:
+m4/ftello.m4
+
+Depends-on:
+stdio
+
+configure.ac:
+gl_FUNC_FTELLO
+gl_STDIO_MODULE_INDICATOR([ftello])
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
index d1deea963d752fb7c924db4852020b78e0e643f1..519b15745b42f17b8bce1995979269633b9ffee3 100644 (file)
@@ -31,6 +31,7 @@ stdio.h: stdio_.h
              -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
              -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
              -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
+             -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
              -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
              -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
              -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
@@ -45,6 +46,7 @@ stdio.h: stdio_.h
              -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
              -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
              -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+             -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
              -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/stdio_.h; \