]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Provide a substitute for a missing readlink() function.
authorBruno Haible <bruno@clisp.org>
Tue, 1 Jul 2003 12:22:42 +0000 (12:22 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:46 +0000 (12:10 +0200)
15 files changed:
ChangeLog
config/install-reloc
gettext-runtime/ChangeLog
gettext-runtime/configure.ac
gettext-runtime/lib/ChangeLog
gettext-runtime/lib/Makefile.am
gettext-runtime/lib/readlink.c [new file with mode: 0644]
gettext-tools/ChangeLog
gettext-tools/configure.ac
gettext-tools/lib/ChangeLog
gettext-tools/lib/Makefile.am
gettext-tools/lib/readlink.c [new file with mode: 0644]
gettext-tools/lib/relocwrapper.c
gettext-tools/m4/Makefile.am
gettext-tools/m4/readlink.m4 [new file with mode: 0644]

index a2f1566b9e5b2bfe9dba917815ef362c3419de32..c31bc4ad90087aa7c0731022eb11ff0c31e2e3a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-07-01  Bruno Haible  <bruno@clisp.org>
+
+       * config/install-reloc: Also compile readlink.c.
+
 2003-06-19  Bruno Haible  <bruno@clisp.org>
 
        * PACKAGING: Add intmax.m4, longdouble.m4, longlong.m4,
index 8dea6c3de9e6b52eb5ee41cfb8d1d30f104f5770..8d5cc64dcc7b34119c0ef62229576de316fea3b2 100755 (executable)
@@ -110,7 +110,7 @@ test -n "$libdirs" || exit 0
 
 # Compile wrapper.
 installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'`
-func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/canonicalize.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $?
+func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $?
 
 # Rename $destprog.wrapper -> $destprog -> $destprog.bin.
 ln -f $destprog $destprog.bin || exit 1
index 2f9a688a4018c902cb14097862c330e9b89f5662..f4fa11a95a493362a31d827d3ebbf587010d4712 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-01  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Invoke gl_FUNC_READLINK.
+
 2003-06-19  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (config.h_vms, config.h.msvc): Update.
index 0332dc3b189988d72db3178602f4a49217bd5139..962712a9f2a88d0168c8b3584badacc111611092 100644 (file)
@@ -81,6 +81,7 @@ gl_FUNC_STRERROR
 jm_FUNC_GLIBC_UNLOCKED_IO
 gt_FUNC_ERROR_AT_LINE
 gl_PATHMAX
+gl_FUNC_READLINK
 gl_XREADLINK
 gl_CANONICALIZE
 
index ab1c6db7291c2cc93aa189e31a04a61b3616c254..ef75ef956160a07a93321c5f9c016ffb518d61c5 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-01  Bruno Haible  <bruno@clisp.org>
+
+       * readlink.c: New file, trivial link to ../../gettext-tools/lib.
+       * Makefile.am (LIBADD_SOURCE): Add readlink.c.
+
 2003-07-01  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (EXTRA_DIST, stdbool.h): Use stdbool_.h instead of
index e1b6280e7dcbb666e1b596cdbb223f6cc56fef02..0a584e2991e82174f79a6a749a8a0f49aaede12e 100644 (file)
@@ -42,6 +42,7 @@ LIBADD_SOURCE = \
   alloca.c \
   ../../gettext-tools/lib/canonicalize.h canonicalize.c \
   memmove.c \
+  readlink.c \
   ../../gettext-tools/lib/relocatable.h relocatable.c \
   ../../gettext-tools/lib/setenv.h setenv.c unsetenv.c \
   strerror.c
diff --git a/gettext-runtime/lib/readlink.c b/gettext-runtime/lib/readlink.c
new file mode 100644 (file)
index 0000000..736d74a
--- /dev/null
@@ -0,0 +1 @@
+#include "../../gettext-tools/lib/readlink.c"
index b230feb1aa24aa0311a7e9a3778436b7aabf64d7..9a560a34f622b7575e4132da34f5e126426208ae 100644 (file)
@@ -1,3 +1,7 @@
+2003-07-01  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Invoke gl_FUNC_READLINK.
+
 2003-07-01  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (windows/stdbool.h): Use stdbool_.h instead of
index 6902a849745eecdc7fd865ee698687b1c78c9ec9..aa392fdecb2207d45b03e2278461a4533209cad4 100644 (file)
@@ -123,6 +123,7 @@ gl_FUNC_STRERROR
 jm_FUNC_GLIBC_UNLOCKED_IO
 gt_FUNC_ERROR_AT_LINE
 gl_PATHMAX
+gl_FUNC_READLINK
 gl_XREADLINK
 gl_CANONICALIZE
 gt_SETLOCALE
index 3fce8852966ab3374969ecfb33c25fec2d10f9ed..23b45fd1c7d5bbf5e1cbbc0ba96f01cc23d282c2 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-01  Bruno Haible  <bruno@clisp.org>
+
+       * readlink.c: New file, from gnulib.
+       * Makefile.am (LIBADD_SOURCE): Add it.
+
 2003-07-01  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (EXTRA_DIST, stdbool.h): Use stdbool_.h instead of
index 97d29dbce0c1393c40486654ea526d1df7c22640..0d7a574b3633fdefeb6d97c334d124e7fb10b925 100644 (file)
@@ -81,6 +81,7 @@ LIBADD_SOURCE = \
   memset.c \
   mkdtemp.h mkdtemp.c \
   pfnmatch.h pfnmatch.c \
+  readlink.c \
   relocatable.h relocatable.c \
   setenv.h setenv.c unsetenv.c \
   stpcpy.h stpcpy.c \
diff --git a/gettext-tools/lib/readlink.c b/gettext-tools/lib/readlink.c
new file mode 100644 (file)
index 0000000..c264efd
--- /dev/null
@@ -0,0 +1,48 @@
+/* Stub for readlink().
+   Copyright (C) 2003 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 2, 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, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if !HAVE_READLINK
+
+/* readlink() substitute for systems that don't have a readlink() function,
+   such as DJGPP 2.03 and mingw32.  */
+
+/* The official POSIX return type of readlink() is ssize_t, but since here
+   we have no declaration in a public header file, we use 'int' as return
+   type.  */
+
+int
+readlink (const char *path, char *buf, size_t bufsize)
+{
+  struct stat statbuf;
+
+  /* In general we should use lstat() here, not stat().  But on platforms
+     without symbolic links lstat() - if it exists - would be equivalent to
+     stat(), therefore we can use stat().  This saves us a configure check.  */
+  if (stat (path, &statbuf) >= 0)
+    errno = EINVAL;
+  return -1;
+}
+
+#endif
index 6a847850f99f828d65c83e3cfb0c5c0132c098e4..684442c949fb11b9fc61fa2f9772937d16266092 100644 (file)
@@ -21,6 +21,7 @@
     -> progname
     -> progreloc
         -> xreadlink
+           -> readlink
         -> canonicalize
     -> relocatable
     -> setenv
index bfac6f135626d0e656b34e660b186807afae3dfd..32e11c303ce56d133771af363ba224c68ae37d2f 100644 (file)
@@ -53,6 +53,7 @@ mbswidth.m4 \
 mkdtemp.m4 \
 onceonly.m4 \
 pathmax.m4 \
+readlink.m4 \
 relocatable.m4 \
 setenv.m4 \
 setlocale.m4 \
diff --git a/gettext-tools/m4/readlink.m4 b/gettext-tools/m4/readlink.m4
new file mode 100644 (file)
index 0000000..fd73d49
--- /dev/null
@@ -0,0 +1,22 @@
+# readlink.m4 serial 1
+dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_READLINK],
+[
+  AC_CHECK_FUNCS(readlink)
+  if test $ac_cv_func_readlink = no; then
+    AC_LIBOBJ(readlink)
+    gl_PREREQ_READLINK
+  fi
+])
+
+# Prerequisites of lib/readlink.c.
+AC_DEFUN([gl_PREREQ_READLINE],
+[
+  :
+])