changeset 21857:8d9e6b4fbf4d

Split strl.c into strl(cat|cpy).c and move #ifdefs into the build system.
author diego
date Wed, 10 Jan 2007 20:23:24 +0000
parents e268886eb13d
children 1397ed206bff
files configure osdep/Makefile osdep/strl.c osdep/strlcat.c osdep/strlcpy.c
diffstat 5 files changed, 45 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Wed Jan 10 19:35:41 2007 +0000
+++ b/configure	Wed Jan 10 20:23:24 2007 +0000
@@ -3411,8 +3411,10 @@
 cc_check && _strlcpy=yes
 if test "$_strlcpy" = yes ; then
  _def_strlcpy='#define HAVE_STRLCPY 1'
+ _need_strlcpy=no
 else
  _def_strlcpy='#undef HAVE_STRLCPY'
+ _need_strlcpy=yes
 fi
 echores "$_strlcpy"
 
@@ -3425,8 +3427,10 @@
 cc_check && _strlcat=yes
 if test "$_strlcat" = yes ; then
  _def_strlcat='#define HAVE_STRLCAT 1'
+ _need_strlcat=no
 else
  _def_strlcat='#undef HAVE_STRLCAT'
+ _need_strlcat=yes
 fi
 echores "$_strlcat"
 
@@ -7488,6 +7492,8 @@
 NEED_GLOB    = $_need_glob
 NEED_SCANDIR = $_need_scandir
 NEED_SETENV  = $_need_setenv
+NEED_STRLCAT = $_need_strlcat
+NEED_STRLCPY = $_need_strlcpy
 NEED_STRSEP  = $_need_strsep
 NEED_SWAB    = $_need_swab
 NEED_VSSCANF = $_need_vsscanf
--- a/osdep/Makefile	Wed Jan 10 19:35:41 2007 +0000
+++ b/osdep/Makefile	Wed Jan 10 20:23:24 2007 +0000
@@ -3,8 +3,6 @@
 
 LIBNAME = libosdep.a
 
-SRCS= strl.c \
-
 SRCS-$(HAVE_SYS_MMAN_H)       += mmap_anon.c
 SRCS-$(MACOSX_FINDER_SUPPORT) += macosx_finder_args.c
 ifneq ($(TARGET_OS),MINGW32)
@@ -16,6 +14,8 @@
 SRCS-$(NEED_GETTIMEOFDAY)     += gettimeofday.c
 SRCS-$(NEED_SCANDIR)          += scandir.c
 SRCS-$(NEED_SETENV)           += setenv.c
+SRCS-$(NEED_STRLCAT)          += strlcat.c
+SRCS-$(NEED_STRLCPY)          += strlcpy.c
 SRCS-$(NEED_STRSEP)           += strsep.c
 SRCS-$(NEED_SWAB)             += swab.c
 SRCS-$(NEED_VSSCANF)          += vsscanf.c
--- a/osdep/strl.c	Wed Jan 10 19:35:41 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/* strl(cat|cpy) implementation for systems that do not have it in libc */
-/* strl.c - strlcpy/strlcat implementation
- * Time-stamp: <2004-03-14 njk>
- * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
- */
-
-#include "config.h"
-
-#ifndef HAVE_STRLCPY
-unsigned int strlcpy (char *dest, const char *src, unsigned int size)
-{
-	register unsigned int i = 0;
-
-	if (size > 0) {
-	size--;
-	for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
-		dest[i] = src[i];
-
-	dest[i] = '\0';
-	}
-	while (src[i++]);
-
-	return i;
-}
-#endif
-
-#ifndef HAVE_STRLCAT
-unsigned int strlcat (char *dest, const char *src, unsigned int size)
-{
-	register char *d = dest;
-
-	for (; size > 0 && *d != '\0'; size--, d++);
-	return (d - dest) + strlcpy(d, src, size);
-}
-#endif
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/osdep/strlcat.c	Wed Jan 10 20:23:24 2007 +0000
@@ -0,0 +1,15 @@
+/* strlcat implementation for systems that do not have it in libc
+ * Time-stamp: <2004-03-14 njk>
+ * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
+ */
+
+#include "config.h"
+
+unsigned int strlcat (char *dest, const char *src, unsigned int size)
+{
+	register char *d = dest;
+
+	for (; size > 0 && *d != '\0'; size--, d++);
+	return (d - dest) + strlcpy(d, src, size);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/osdep/strlcpy.c	Wed Jan 10 20:23:24 2007 +0000
@@ -0,0 +1,22 @@
+/* strlcpy implementation for systems that do not have it in libc
+ * Time-stamp: <2004-03-14 njk>
+ * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
+ */
+
+#include "config.h"
+
+unsigned int strlcpy (char *dest, const char *src, unsigned int size)
+{
+	register unsigned int i = 0;
+
+	if (size > 0) {
+	size--;
+	for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
+		dest[i] = src[i];
+
+	dest[i] = '\0';
+	}
+	while (src[i++]);
+
+	return i;
+}