From 40b94fc1fb1c182e0ebb8728a5167e33767b306b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 1 Jul 2003 12:22:42 +0000 Subject: [PATCH] Provide a substitute for a missing readlink() function. --- ChangeLog | 4 +++ config/install-reloc | 2 +- gettext-runtime/ChangeLog | 4 +++ gettext-runtime/configure.ac | 1 + gettext-runtime/lib/ChangeLog | 5 ++++ gettext-runtime/lib/Makefile.am | 1 + gettext-runtime/lib/readlink.c | 1 + gettext-tools/ChangeLog | 4 +++ gettext-tools/configure.ac | 1 + gettext-tools/lib/ChangeLog | 5 ++++ gettext-tools/lib/Makefile.am | 1 + gettext-tools/lib/readlink.c | 48 ++++++++++++++++++++++++++++++++ gettext-tools/lib/relocwrapper.c | 1 + gettext-tools/m4/Makefile.am | 1 + gettext-tools/m4/readlink.m4 | 22 +++++++++++++++ 15 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 gettext-runtime/lib/readlink.c create mode 100644 gettext-tools/lib/readlink.c create mode 100644 gettext-tools/m4/readlink.m4 diff --git a/ChangeLog b/ChangeLog index a2f1566b9..c31bc4ad9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Bruno Haible + + * config/install-reloc: Also compile readlink.c. + 2003-06-19 Bruno Haible * PACKAGING: Add intmax.m4, longdouble.m4, longlong.m4, diff --git a/config/install-reloc b/config/install-reloc index 8dea6c3de..8d5cc64dc 100755 --- a/config/install-reloc +++ b/config/install-reloc @@ -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 diff --git a/gettext-runtime/ChangeLog b/gettext-runtime/ChangeLog index 2f9a688a4..f4fa11a95 100644 --- a/gettext-runtime/ChangeLog +++ b/gettext-runtime/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Bruno Haible + + * configure.ac: Invoke gl_FUNC_READLINK. + 2003-06-19 Bruno Haible * Makefile.am (config.h_vms, config.h.msvc): Update. diff --git a/gettext-runtime/configure.ac b/gettext-runtime/configure.ac index 0332dc3b1..962712a9f 100644 --- a/gettext-runtime/configure.ac +++ b/gettext-runtime/configure.ac @@ -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 diff --git a/gettext-runtime/lib/ChangeLog b/gettext-runtime/lib/ChangeLog index ab1c6db72..ef75ef956 100644 --- a/gettext-runtime/lib/ChangeLog +++ b/gettext-runtime/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-07-01 Bruno Haible + + * readlink.c: New file, trivial link to ../../gettext-tools/lib. + * Makefile.am (LIBADD_SOURCE): Add readlink.c. + 2003-07-01 Bruno Haible * Makefile.am (EXTRA_DIST, stdbool.h): Use stdbool_.h instead of diff --git a/gettext-runtime/lib/Makefile.am b/gettext-runtime/lib/Makefile.am index e1b6280e7..0a584e299 100644 --- a/gettext-runtime/lib/Makefile.am +++ b/gettext-runtime/lib/Makefile.am @@ -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 index 000000000..736d74a2f --- /dev/null +++ b/gettext-runtime/lib/readlink.c @@ -0,0 +1 @@ +#include "../../gettext-tools/lib/readlink.c" diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index b230feb1a..9a560a34f 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,7 @@ +2003-07-01 Bruno Haible + + * configure.ac: Invoke gl_FUNC_READLINK. + 2003-07-01 Bruno Haible * Makefile.am (windows/stdbool.h): Use stdbool_.h instead of diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index 6902a8497..aa392fdec 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -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 diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 3fce88529..23b45fd1c 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-07-01 Bruno Haible + + * readlink.c: New file, from gnulib. + * Makefile.am (LIBADD_SOURCE): Add it. + 2003-07-01 Bruno Haible * Makefile.am (EXTRA_DIST, stdbool.h): Use stdbool_.h instead of diff --git a/gettext-tools/lib/Makefile.am b/gettext-tools/lib/Makefile.am index 97d29dbce..0d7a574b3 100644 --- a/gettext-tools/lib/Makefile.am +++ b/gettext-tools/lib/Makefile.am @@ -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 index 000000000..c264efd8c --- /dev/null +++ b/gettext-tools/lib/readlink.c @@ -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 +#endif + +#include +#include +#include + +#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 diff --git a/gettext-tools/lib/relocwrapper.c b/gettext-tools/lib/relocwrapper.c index 6a847850f..684442c94 100644 --- a/gettext-tools/lib/relocwrapper.c +++ b/gettext-tools/lib/relocwrapper.c @@ -21,6 +21,7 @@ -> progname -> progreloc -> xreadlink + -> readlink -> canonicalize -> relocatable -> setenv diff --git a/gettext-tools/m4/Makefile.am b/gettext-tools/m4/Makefile.am index bfac6f135..32e11c303 100644 --- a/gettext-tools/m4/Makefile.am +++ b/gettext-tools/m4/Makefile.am @@ -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 index 000000000..fd73d49f1 --- /dev/null +++ b/gettext-tools/m4/readlink.m4 @@ -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], +[ + : +]) -- 2.47.3