mirror of https://github.com/mpv-player/mpv
Split strl.c into strl(cat|cpy).c and move #ifdefs into the build system.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21875 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
7db81061d7
commit
33593191d3
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
36
osdep/strl.c
36
osdep/strl.c
|
@ -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
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue