Fix by Royce3

svn path=/trunk/; revision=4112
This commit is contained in:
Gé van Geldorp 2003-02-03 16:59:27 +00:00
parent a9b14e9d16
commit 0f7e47f8bd
2 changed files with 23 additions and 10 deletions

View file

@ -4,6 +4,18 @@
void *
_memccpy (void *to, const void *from,int c,size_t count)
{
memcpy(to,from,count);
return memchr(to,c,count);
char t;
size_t i;
char *dst=(char*)to;
const char *src=(const char*)from;
for ( i = 0; i < count; i++ )
{
dst[i] = t = src[i];
if ( t == '\0' )
break;
if ( t == c )
return &dst[i+1];
}
return NULL; /* didn't copy c */
}

View file

@ -2,17 +2,18 @@
char * _strrev(char *s)
{
char *e;
char a;
e=s;
char a, *b, *e;
b=e=s;
while (*e)
e++;
while (s<e) {
a=*s;
*s=*e;
e--; /* start at last char, not NULL char */
while ( b < e )
{
a=*b;
*b=*e;
*e=a;
s++;
b++;
e--;
}
return s;
return s; /* return ptr to beginning of string */
}