typo fixes
[mplayer/greg.git] / osdep / strl.c
blobc548fcdf42e7fa144d91996c10a71a308c4fccdb
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 = 0;
14 if (size > 0) {
15 size--;
16 for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
17 dest[i] = src[i];
19 dest[i] = '\0';
21 while (src[i++]);
23 return i;
25 #endif
27 #ifndef HAVE_STRLCAT
28 unsigned int strlcat (char *dest, const char *src, unsigned int size)
30 register char *d = dest;
32 for (; size > 0 && *d != '\0'; size--, d++);
33 return (d - dest) + strlcpy(d, src, size);
35 #endif