small warning fix:
[mplayer/glamo.git] / osdep / strl.c
blob8c0949a889edda9fac0dded84dda0125577fc095
1 /* strl(cat|cpy) implementation for systems that do not have it in libc */
2 /* strl.c - strlcpy/strlcat implementation
3 * Time-stamp: <2004-03-14 njk>
4 * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
5 */
7 #include "../config.h"
9 #ifndef HAVE_STRLCPY
10 unsigned int strlcpy (char *dest, const char *src, unsigned int size)
12 register unsigned int i;
14 for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
15 dest[i] = src[i];
17 dest[i] = '\0';
19 return i;
21 #endif
23 #ifndef HAVE_STRLCAT
24 unsigned int strlcat (char *dest, const char *src, unsigned int size)
26 #if 0
27 register unsigned int i, j;
29 for(i=0; size > 0 && dest[i] != '\0'; size--, i++);
30 for(j=0; size > 0 && src[j] != '\0'; size--, i++, j++)
31 dest[i] = src[j];
33 dest[i] = '\0';
34 return i;
35 #else
36 register char *d = dest;
37 register const char *s = src;
39 for (; size > 0 && *d != '\0'; size--, d++);
40 for (; size > 0 && *s != '\0'; size--, d++, s++)
41 *d = *s;
43 *d = '\0';
44 return (d - dest) + (s - src);
45 #endif
47 #endif