summaryrefslogtreecommitdiff
path: root/lgl
diff options
context:
space:
mode:
authorSimon Josefsson <jas@mocca.josefsson.org>2007-05-25 16:17:12 +0200
committerSimon Josefsson <jas@mocca.josefsson.org>2007-05-25 16:17:12 +0200
commit7d9131036e6d9d9261c7f1ce26243c44a9a6a985 (patch)
tree029c299d0d84c6628ca8409734c8229c352e7a87 /lgl
parent4b6f02bd34367cb1ff41eb673470d1c560b46b78 (diff)
downloadgnutls-7d9131036e6d9d9261c7f1ce26243c44a9a6a985.tar.gz
Update.
Diffstat (limited to 'lgl')
-rw-r--r--lgl/.cvsignore1
-rw-r--r--lgl/Makefile.am13
-rw-r--r--lgl/fseeko.c7
-rw-r--r--lgl/m4/fseeko.m45
-rw-r--r--lgl/m4/gnulib-comp.m44
-rw-r--r--lgl/m4/unistd_h.m44
-rw-r--r--lgl/stdio_.h26
-rw-r--r--lgl/unistd_.h19
8 files changed, 57 insertions, 22 deletions
diff --git a/lgl/.cvsignore b/lgl/.cvsignore
index d1bf8cb44f..ac19279beb 100644
--- a/lgl/.cvsignore
+++ b/lgl/.cvsignore
@@ -20,3 +20,4 @@ getpass.c
getpass.h
float_.h
fseeko.c
+lseek.c
diff --git a/lgl/Makefile.am b/lgl/Makefile.am
index 9efcdcd5b3..8bb2ee4e75 100644
--- a/lgl/Makefile.am
+++ b/lgl/Makefile.am
@@ -255,6 +255,15 @@ LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
## end gnulib module link-warning
+## begin gnulib module lseek
+
+
+EXTRA_DIST += lseek.c
+
+EXTRA_liblgnu_la_SOURCES += lseek.c
+
+## end gnulib module lseek
+
## begin gnulib module memmem
@@ -396,9 +405,7 @@ stdio.h: stdio_.h
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
-e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
-e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
- -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
-e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
- -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
-e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
-e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
@@ -585,6 +592,7 @@ unistd.h: unistd_.h
-e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
-e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
-e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
+ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
-e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
-e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
-e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
@@ -595,6 +603,7 @@ unistd.h: unistd_.h
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
-e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
< $(srcdir)/unistd_.h; \
} > $@-t
mv $@-t $@
diff --git a/lgl/fseeko.c b/lgl/fseeko.c
index f33fa83018..b85e18bd7c 100644
--- a/lgl/fseeko.c
+++ b/lgl/fseeko.c
@@ -25,12 +25,19 @@
#undef fseeko
#if !HAVE_FSEEKO
+# undef fseek
# define fseeko fseek
#endif
int
rpl_fseeko (FILE *fp, off_t offset, int whence)
{
+#if LSEEK_PIPE_BROKEN
+ /* mingw gives bogus answers rather than failure on non-seekable files. */
+ if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
+ return EOF;
+#endif
+
/* These tests are based on fpurge.c. */
#if defined _IO_ferror_unlocked /* GNU libc, BeOS */
if (fp->_IO_read_end == fp->_IO_read_ptr
diff --git a/lgl/m4/fseeko.m4 b/lgl/m4/fseeko.m4
index b544e24102..40be63b4c2 100644
--- a/lgl/m4/fseeko.m4
+++ b/lgl/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 2
+# fseeko.m4 serial 3
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,
@@ -12,10 +12,11 @@ AC_DEFUN([gl_FUNC_FSEEKO],
AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
[
AC_TRY_LINK([#include <stdio.h>], [fseeko (stdin, 0, 0);],
- [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
+ [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
])
if test $gl_cv_func_fseeko = no; then
HAVE_FSEEKO=0
+ gl_REPLACE_FSEEKO
elif test $gl_cv_var_stdin_large_offset = no; then
gl_REPLACE_FSEEKO
fi
diff --git a/lgl/m4/gnulib-comp.m4 b/lgl/m4/gnulib-comp.m4
index ac0643b3d1..11d94e9c76 100644
--- a/lgl/m4/gnulib-comp.m4
+++ b/lgl/m4/gnulib-comp.m4
@@ -80,6 +80,8 @@ AC_DEFUN([lgl_INIT],
AM_GNU_GETTEXT_VERSION([0.16.1])
AC_SUBST([LIBINTL])
AC_SUBST([LTLIBINTL])
+ gl_FUNC_LSEEK
+ gl_UNISTD_MODULE_INDICATOR([lseek])
gl_FUNC_MEMMEM
gl_STRING_MODULE_INDICATOR([memmem])
gl_FUNC_MEMMOVE
@@ -172,6 +174,7 @@ AC_DEFUN([lgl_FILE_LIST], [
lib/hmac-md5.c
lib/hmac-sha1.c
lib/hmac.h
+ lib/lseek.c
lib/md2.c
lib/md2.h
lib/md4.c
@@ -259,6 +262,7 @@ AC_DEFUN([lgl_FILE_LIST], [
m4/lib-prefix.m4
m4/lock.m4
m4/longlong.m4
+ m4/lseek.m4
m4/md2.m4
m4/md4.m4
m4/md5.m4
diff --git a/lgl/m4/unistd_h.m4 b/lgl/m4/unistd_h.m4
index d62da6953d..60dd73081a 100644
--- a/lgl/m4/unistd_h.m4
+++ b/lgl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 6
+# unistd_h.m4 serial 7
dnl Copyright (C) 2006-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,
@@ -39,6 +39,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
+ GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
dnl Assume proper GNU behavior unless another module says otherwise.
@@ -50,4 +51,5 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
+ REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
])
diff --git a/lgl/stdio_.h b/lgl/stdio_.h
index 232a3b78ea..2c33e489a4 100644
--- a/lgl/stdio_.h
+++ b/lgl/stdio_.h
@@ -42,9 +42,7 @@
#include <stdarg.h>
#include <stddef.h>
-#if (@GNULIB_FFLUSH@ && @REPLACE_FFLUSH@) \
- || (@GNULIB_FSEEKO@ && (!@HAVE_FSEEKO@ || @REPLACE_FSEEKO@)) \
- || (@GNULIB_FTELLO@ && (!@HAVE_FTELLO@ || @REPLACE_FTELLO@))
+#if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@)
/* Get off_t. */
# include <sys/types.h>
#endif
@@ -218,16 +216,13 @@ extern int vsprintf (char *str, const char *format, va_list args)
# endif
#endif
-#if (@GNULIB_FFLUSH@ && @REPLACE_FFLUSH@) || (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@)
-/* Provide fseek, fseeko functions that are aware of a preceding fflush(). */
-# define fseeko rpl_fseeko
+#if @GNULIB_FSEEKO@
+# if @REPLACE_FSEEKO@
+/* Provide fseek, fseeko functions that are aware of a preceding
+ fflush(), and which detect pipes. */
+# define fseeko rpl_fseeko
extern int fseeko (FILE *fp, off_t offset, int whence);
-# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
-#elif @GNULIB_FSEEKO@
-# if !@HAVE_FSEEKO@
-/* Assume 'off_t' is the same type as 'long'. */
-typedef int verify_fseeko_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
-# define fseeko fseek
+# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
# endif
#elif defined GNULIB_POSIXCHECK
# undef fseeko
@@ -248,13 +243,10 @@ typedef int verify_fseeko_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
#endif
#if @GNULIB_FTELLO@
-# if !@HAVE_FTELLO@
-/* Assume 'off_t' is the same type as 'long'. */
-typedef int verify_ftello_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
-# define ftello ftell
-# elif @REPLACE_FTELLO@
+# if @REPLACE_FTELLO@
# define ftello rpl_ftello
extern off_t ftello (FILE *fp);
+# define ftell(fp) ftello (fp)
# endif
#elif defined GNULIB_POSIXCHECK
# undef ftello
diff --git a/lgl/unistd_.h b/lgl/unistd_.h
index fb25d31277..4112507445 100644
--- a/lgl/unistd_.h
+++ b/lgl/unistd_.h
@@ -176,6 +176,25 @@ extern int getlogin_r (char *name, size_t size);
#endif
+#if @GNULIB_LSEEK@
+# if @REPLACE_LSEEK@
+/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
+ Return the new offset if successful, otherwise -1 and errno set.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/lseek.html>. */
+# define lseek rpl_lseek
+ extern off_t lseek (int fd, off_t offset, int whence);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lseek
+# define lseek(f,o,w) \
+ (GL_LINK_WARNING ("lseek does not fail with ESPIPE on non-seekable " \
+ "files on some systems - " \
+ "use gnulib module lseek for portability"), \
+ lseek (f, o, w))
+#endif
+
+
#if @GNULIB_READLINK@
/* Read the contents of the symbolic link FILE and place the first BUFSIZE
bytes of it into BUF. Return the number of bytes placed into BUF if