diff --git a/configure b/configure index c3db8a4a22..e0164a2c53 100755 --- a/configure +++ b/configure @@ -3411,8 +3411,10 @@ _strlcpy=no 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 @@ _strlcat=no 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_FTELLO = $_need_ftello 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 diff --git a/osdep/Makefile b/osdep/Makefile index d1fee0ef78..5010091e29 100644 --- a/osdep/Makefile +++ b/osdep/Makefile @@ -3,8 +3,6 @@ include ../config.mak 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_FTELLO) += ftello.c 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 diff --git a/osdep/strl.c b/osdep/strl.c deleted file mode 100644 index c548fcdf42..0000000000 --- a/osdep/strl.c +++ /dev/null @@ -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 - */ - -#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 - diff --git a/osdep/strlcat.c b/osdep/strlcat.c new file mode 100644 index 0000000000..1facc3333d --- /dev/null +++ b/osdep/strlcat.c @@ -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 + */ + +#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); +} + diff --git a/osdep/strlcpy.c b/osdep/strlcpy.c new file mode 100644 index 0000000000..887461abbc --- /dev/null +++ b/osdep/strlcpy.c @@ -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 + */ + +#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; +}