[MPlayer-cvslog] CVS: main/osdep strl.c,1.2,1.3

Richard Felker CVS syncmail at mplayerhq.hu
Tue Oct 25 19:13:22 CEST 2005


CVS change done by Richard Felker CVS

Update of /cvsroot/mplayer/main/osdep
In directory mail:/var2/tmp/cvs-serv17299/osdep

Modified Files:
	strl.c 
Log Message:
fix broken (off-by-one) behavior of our strl* functions (patch by reimar)

Index: strl.c
===================================================================
RCS file: /cvsroot/mplayer/main/osdep/strl.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- strl.c	6 Apr 2005 11:57:10 -0000	1.2
+++ strl.c	25 Oct 2005 17:13:20 -0000	1.3
@@ -11,10 +11,14 @@
 {
 	register unsigned int i;
 
+	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;
 }
@@ -23,26 +27,10 @@
 #ifndef HAVE_STRLCAT
 unsigned int strlcat (char *dest, const char *src, unsigned int size)
 {
-#if 0
-	register unsigned int i, j;
-
-	for(i=0; size > 0 && dest[i] != '\0'; size--, i++);
-	for(j=0; size > 0 && src[j] != '\0'; size--, i++, j++)
-		dest[i] = src[j];
-
-	dest[i] = '\0';
-	return i;
-#else
 	register char *d = dest;
-	register const char *s = src;
 
 	for (; size > 0 && *d != '\0'; size--, d++);
-	for (; size > 0 && *s != '\0'; size--, d++, s++)
-		*d = *s;
-
-	*d = '\0';
-	return (d - dest) + (s - src);
-#endif 
+	return (d - dest) + strlcpy(d, src, size);
 }
 #endif
 




More information about the MPlayer-cvslog mailing list