[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 112-gary-factor-pre89-replacement-funcs.patch
From: |
Gary V. Vaughan |
Subject: |
FYI: 112-gary-factor-pre89-replacement-funcs.patch |
Date: |
Fri, 2 Apr 2004 19:57:59 +0100 (BST) |
User-agent: |
mailnotify/0.3 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Okay to commit?
Interestingly, the memcpy and memmove functions had a void* dereferencing
bug which would have prevented them from ever compiling. I wonder whether
we should just remove the pre89 stuff altogether?
Cheers,
Gary.
- --
Gary V. Vaughan ())_. address@hidden,gnu.org}
Research Scientist ( '/ http://tkd.kicks-ass.net
GNU Hacker / )= http://www.gnu.org/software/libtool
Technical Author `(_~)_ http://sources.redhat.com/autobook
_________________________________________________________
This patch notification generated by tlaapply version 0.1
http://savannah.gnu.org/projects/cvsutils
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (Darwin)
iD8DBQFAbbe3FRMICSmD1gYRAtG8AKCLT9ON3JAQseRD0cs9Owz8XcghygCfVXSv
sWc1ZtQSL701m+YryEQ7c/E=
=Futm
-----END PGP SIGNATURE-----
* looking for address@hidden/libtool--gary--1.0--patch-2 to compare with
* comparing to address@hidden/libtool--gary--1.0--patch-2
A libltdl/.arch-ids/lt__pre89.h.id
A libltdl/.arch-ids/memcpy.c.id
A libltdl/.arch-ids/memmove.c.id
A libltdl/.arch-ids/strchr.c.id
A libltdl/.arch-ids/strcmp.c.id
A libltdl/.arch-ids/strrchr.c.id
A libltdl/lt__pre89.h
A libltdl/memcpy.c
A libltdl/memmove.c
A libltdl/strchr.c
A libltdl/strcmp.c
A libltdl/strrchr.c
M ChangeLog
M libltdl/Makefile.am
M libltdl/ltdl.c
M m4/ltdl.m4
* modified files
Index: Changelog
from Gary V. Vaughan <address@hidden>
Factor out the bottom portability layer from ltdl. Code in this
layer has global symbols renamed by lt__pre89.h, and may not
refer to any symbols except those provided by the system libraries
or other code in the portability layer:
* libltdl/lt__pre89.h: New file. Rename all the symbols from
LTLIBOBJS into the lt__ namespace so that they don't clash with
other libraries.
* libltdl/ltdl.c (rpl_memcpy, rpl_memmove, rpl_strchr, rpl_strcmp)
(rpl_strrchr): Moved from here...
* libltdl/memcpy.c (memcpy): ...to here, and fixed void *
dereference bug...
* libltdl/memmove.c (memmove): ...to here, and fixed void *
dereference bug...
* libltdl/strchr.c (strchr): ...to here...
* libltdl/strcmp.c (strcmp): ...here...
* libltdl/strrchr.c (strrchr): ...and here.
* libltdl/Makefile.am (libltdl_la_SOURCES): Add lt__pre89.h.
(libltdl_la_LIBADD, libltdlc_la_LIBADD): Add $(LTLIBOBJS).
(ltdldata_DATA): Add replacement sources files.
* m4/ltdl.m4 (AC_LIB_LTDL): Do careful config.h and LTLIBOBJ
setting for missing pre89 functions.
2004-04-02 Gary V. Vaughan <address@hidden>
--- orig/libltdl/Makefile.am
+++ mod/libltdl/Makefile.am
@@ -38,14 +38,16 @@
## default.
CLEANFILES = libltdl.la libltdlc.la
-libltdl_la_SOURCES = lt__alloc.c lt__alloc.h lt_system.h ltdl.c ltdl.h
+libltdl_la_SOURCES = lt__alloc.c lt__alloc.h lt__pre89.h lt_system.h \
+ ltdl.c ltdl.h
libltdl_la_LDFLAGS = -no-undefined -version-info 5:0:2
-libltdl_la_LIBADD = $(LIBADD_DL)
+libltdl_la_LIBADD = $(LIBADD_DL) $(LTLIBOBJS)
libltdlc_la_SOURCES = $(libltdl_la_SOURCES)
-libltdlc_la_LIBADD = $(LIBADD_DL)
+libltdlc_la_LIBADD = $(LIBADD_DL) $(LTLIBOBJS)
## These are installed as a subdirectory of pkgdatadir so that
## libtoolize --ltdl can find them later:
ltdldatadir = $(pkgdatadir)/libltdl
-ltdldata_DATA = COPYING.LIB Makefile.am README $(libltdl_la_SOURCES)
+ltdldata_DATA = COPYING.LIB Makefile.am README $(libltdl_la_SOURCES) \
+ memcpy.c memmove.c strchr.c strcmp.c strrchr.c
--- orig/libltdl/ltdl.c
+++ mod/libltdl/ltdl.c
@@ -71,6 +71,7 @@
#include "ltdl.h"
#include "lt__alloc.h"
+#include "lt__pre89.h"
#if defined(HAVE_CLOSEDIR) && defined(HAVE_OPENDIR) && defined(HAVE_READDIR)
&& defined(HAVE_DIRENT_H)
/* We have a fully operational dirent subsystem. */
@@ -141,134 +142,6 @@
-
-/* --- REPLACEMENT FUNCTIONS --- */
-
-
-#if ! HAVE_STRCMP
-
-#undef strcmp
-#define strcmp rpl_strcmp
-
-static int
-strcmp (const char *str1, const char *str2)
-{
- if (str1 == str2)
- return 0;
- if (str1 == 0)
- return -1;
- if (str2 == 0)
- return 1;
-
- for (;*str1 && *str2; ++str1, ++str2)
- {
- if (*str1 != *str2)
- break;
- }
-
- return (int)(*str1 - *str2);
-}
-#endif
-
-
-#if ! HAVE_STRCHR
-
-# if HAVE_INDEX
-# define strchr index
-# else
-# define strchr rpl_strchr
-
-static const char *
-strchr (const char *str, int ch)
-{
- const char *p;
-
- for (p = str; *p != (char)ch && *p != LT_EOS_CHAR; ++p)
- /*NOWORK*/;
-
- return (*p == (char)ch) ? p : 0;
-}
-
-# endif
-#endif /* !HAVE_STRCHR */
-
-
-#if ! HAVE_STRRCHR
-
-# if HAVE_RINDEX
-# define strrchr rindex
-# else
-# define strrchr rpl_strrchr
-
-static const char *
-strrchr (const char *str, int ch)
-{
- const char *p, *q = 0;
-
- for (p = str; *p != LT_EOS_CHAR; ++p)
- {
- if (*p == (char) ch)
- {
- q = p;
- }
- }
-
- return q;
-}
-
-# endif
-#endif
-
-/* NOTE: Neither bcopy nor the memcpy implementation below can
- reliably handle copying in overlapping areas of memory. Use
- memmove (for which there is a fallback implmentation below)
- if you need that behaviour. */
-#if ! HAVE_MEMCPY
-
-# if HAVE_BCOPY
-# define memcpy(dest, src, size) bcopy (src, dest, size)
-# else
-# define memcpy rpl_memcpy
-
-static void *
-memcpy (void *dest, const void *src, size_t size)
-{
- size_t i = 0;
-
- for (i = 0; i < size; ++i)
- {
- dest[i] = src[i];
- }
-
- return dest;
-}
-
-# endif /* !HAVE_BCOPY */
-#endif /* !HAVE_MEMCPY */
-
-#if ! HAVE_MEMMOVE
-# define memmove rpl_memmove
-
-static void *
-memmove (void *dest, const void *src, size_t size)
-{
- size_t i;
-
- if (dest < src)
- for (i = 0; i < size; ++i)
- {
- dest[i] = src[i];
- }
- else if (dest > src)
- for (i = size -1; i >= 0; --i)
- {
- dest[i] = src[i];
- }
-
- return dest;
-}
-
-#endif /* !HAVE_MEMMOVE */
# if LT_USE_WINDOWS_DIRENT_EMULATION
--- orig/m4/ltdl.m4
+++ mod/m4/ltdl.m4
@@ -110,10 +110,23 @@
[], [], [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([string.h strings.h], [break], [], [AC_INCLUDES_DEFAULT])
-AC_CHECK_FUNCS([strchr index], [break])
-AC_CHECK_FUNCS([strrchr rindex], [break])
-AC_CHECK_FUNCS([memcpy bcopy], [break])
-AC_CHECK_FUNCS([memmove strcmp])
+AC_FOREACH([LTDL_Func], [strchr index strrchr rindex memcpy bcopy],
+ [AH_TEMPLATE(AS_TR_CPP(HAVE_[]LTDL_Func),
+ [Define to 1 if you have the `]LTDL_Func[' function.])])
+
+AC_CHECK_FUNC([strchr], [AC_DEFINE([HAVE_STRCHR])],
+ [AC_CHECK_FUNC([index], [AC_DEFINE([HAVE_INDEX])],
+ [AC_LIBOBJ([strchr])])])
+
+AC_CHECK_FUNC([strrchr], [AC_DEFINE([HAVE_STRRCHR])],
+ [AC_CHECK_FUNC([rindex], [AC_DEFINE([HAVE_RINDEX])],
+ [AC_LIBOBJ([strrchr])])])
+
+AC_CHECK_FUNC([memcpy], [AC_DEFINE([HAVE_MEMCPY])],
+ [AC_CHECK_FUNC([bcopy], [AC_DEFINE([HAVE_BCOPY])],
+ [AC_LIBOBJ([memcpy])])])
+
+AC_REPLACE_FUNCS([memmove strcmp])
AC_CHECK_FUNCS([closedir opendir readdir])
])# AC_LIB_LTDL
* added files
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/.arch-ids/lt__pre89.h.id
@@ -0,0 +1 @@
+Gary V. Vaughan <address@hidden> Fri Apr 2 18:38:30 2004 8949.0
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/.arch-ids/memcpy.c.id
@@ -0,0 +1 @@
+Gary V. Vaughan <address@hidden> Fri Apr 2 18:11:41 2004 2304.0
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/.arch-ids/memmove.c.id
@@ -0,0 +1 @@
+Gary V. Vaughan <address@hidden> Fri Apr 2 18:11:41 2004 2304.1
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/.arch-ids/strchr.c.id
@@ -0,0 +1 @@
+Gary V. Vaughan <address@hidden> Fri Apr 2 18:11:41 2004 2304.2
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/.arch-ids/strcmp.c.id
@@ -0,0 +1 @@
+Gary V. Vaughan <address@hidden> Fri Apr 2 18:11:41 2004 2304.3
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/.arch-ids/strrchr.c.id
@@ -0,0 +1 @@
+Gary V. Vaughan <address@hidden> Fri Apr 2 18:11:41 2004 2304.4
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/lt__pre89.h
@@ -0,0 +1,85 @@
+/* lt__pre89.h -- support for pre-c89 libc implementations
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Originally by Gary V. Vaughan <address@hidden>
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#ifndef LT__PREC89_H
+#define LT__PREC89_H 1
+
+#ifdef HAVE_CONFIG_H
+# include HAVE_CONFIG_H
+#endif
+
+#include "lt_system.h"
+
+LT_BEGIN_C_DECLS
+
+#if ! HAVE_STRCMP
+# undef strcmp
+# define strcmp lt__strcmp
+int strcmp (const char *str1, const char *str2);
+#endif
+
+#if ! HAVE_STRCHR
+# if HAVE_INDEX
+# define strchr index
+# else
+# undef strchr
+# define strchr lt__strchr
+const char *strchr (const char *str, int ch);
+# endif
+#endif
+
+#if ! HAVE_STRRCHR
+# if HAVE_RINDEX
+# define strrchr rindex
+# else
+# undef strcmp
+# define strcmp lt__strcmp
+const char *strrchr (const char *str, int ch);
+# endif
+#endif
+
+#if ! HAVE_MEMCPY
+# if HAVE_BCOPY
+# define memcpy(dest, src, size) bcopy((src), (dest), (size))
+# else
+# undef memcpy
+# define memcpy lt__memcpy
+void *memcpy (void *dest, const void *src, size_t size);
+# endif
+#endif
+
+#if ! HAVE_MEMMOVE
+# undef memmove
+# define memmove lt__memmove
+void *memmove (void *dest, const void *src, size_t size);
+#endif
+
+LT_END_C_DECLS
+
+#endif /*!LT__PREC89*/
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/memcpy.c
@@ -0,0 +1,50 @@
+/* memcpy.c -- copy a block of memory for pre-c89 libc
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Originally by Gary V. Vaughan <address@hidden>
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#include "lt__pre89.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+
+/* NOTE: memcpy does not reliably handle copying in overlapping areas
+ of memory. Use memmove if you need that behaviour. */
+
+void *
+memcpy (void *dest, const void *src, size_t size)
+{
+ char *d = dest;
+ const char *s = src;
+
+ while (size-- > 0)
+ {
+ *d++ = *s++;
+ }
+
+ return dest;
+}
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/memmove.c
@@ -0,0 +1,58 @@
+/* memmove.c -- move to a possibly overlapping block of memory for pre-c89 libc
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Originally by Gary V. Vaughan <address@hidden>
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#include "lt__pre89.h"
+
+#include <stddef.h>
+#include <sys/types.h>
+
+void *
+memmove (void * dest, void * src, size_t size)
+{
+ char *d = dest;
+ char *s = src;
+ size_t i;
+
+ if (dest < src)
+ while (size-- > 0)
+ {
+ *d++ = *s++;
+ }
+ else if (dest > src)
+ {
+ d += size;
+ s += size;
+ while (size-- > 0)
+ {
+ *--d = *--s;
+ }
+ }
+
+ return dest;
+}
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/strchr.c
@@ -0,0 +1,41 @@
+/* strchr.c -- scan for a char in a string for pre-c89 libc
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Originally by Gary V. Vaughan <address@hidden>
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#include "lt__pre89.h"
+
+const char *
+strchr (const char *str, int ch)
+{
+ const char *p;
+
+ for (p = str; *p != (char)ch && *p != '\0'; ++p)
+ /*NOWORK*/;
+
+ return (*p == (char)ch) ? p : 0;
+}
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/strcmp.c
@@ -0,0 +1,49 @@
+/* strcmp.c -- compare strings for pre-c89 libc
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Originally by Gary V. Vaughan <address@hidden>
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#include "lt__pre89.h"
+
+int
+strcmp (const char *str1, const char *str2)
+{
+ if (str1 == str2)
+ return 0;
+ if (str1 == 0)
+ return -1;
+ if (str2 == 0)
+ return 1;
+
+ for (;*str1 && *str2; ++str1, ++str2)
+ {
+ if (*str1 != *str2)
+ break;
+ }
+
+ return (int)(*str1 - *str2);
+}
--- /dev/null
+++
/Users/gary/devel/savannah/libtool--gary--1.0/,,address@hidden/new-files-archive/./libltdl/strrchr.c
@@ -0,0 +1,46 @@
+/* strrchr.c -- reverse scan for a char in a string for pre-c89 libc
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ Originally by Gary V. Vaughan <address@hidden>
+
+ NOTE: The canonical source of this file is maintained with the
+ GNU Libtool package. Report bugs to address@hidden
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+As a special exception to the GNU Lesser General Public License,
+if you distribute this file as part of a program or library that
+is built using GNU libtool, you may include it under the same
+distribution terms that you use for the rest of that program.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA
+
+*/
+
+#include "lt__pre89.h"
+
+const char *
+strrchr (const char *str, int ch)
+{
+ const char *p, *q = 0;
+
+ for (p = str; *p != '\0'; ++p)
+ {
+ if (*p == (char) ch)
+ {
+ q = p;
+ }
+ }
+
+ return q;
+}
- FYI: 112-gary-factor-pre89-replacement-funcs.patch,
Gary V. Vaughan <=