mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* missing.h, missing/memcmp.c, missing/memmove.c:
ANSI compatible interface. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f44333cbff
commit
c0851c650f
4 changed files with 19 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Oct 27 11:53:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
|
* missing.h, missing/memcmp.c, missing/memmove.c:
|
||||||
|
ANSI compatible interface.
|
||||||
|
|
||||||
Wed Oct 26 09:15:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
Wed Oct 26 09:15:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
* ext/syck/implicit.c (syck_type_id_to_uri): should return
|
* ext/syck/implicit.c (syck_type_id_to_uri): should return
|
||||||
|
|
|
@ -76,12 +76,12 @@ extern int isnan(double);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifndef HAVE_MEMCMP
|
#ifndef HAVE_MEMCMP
|
||||||
extern int memcmp(char *, char *, int);
|
extern int memcmp(const void *, const void *, size_t);
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HAVE_MEMMOVE
|
#ifndef HAVE_MEMMOVE
|
||||||
extern void *memmove(void *, void *, int);
|
extern void *memmove(void *, const void *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
/* public domain rewrite of memcmp(3) */
|
/* public domain rewrite of memcmp(3) */
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
memcmp(s1,s2,len)
|
memcmp(const void *s1, const void *s2, size_t len)
|
||||||
char *s1;
|
|
||||||
char *s2;
|
|
||||||
register int len;
|
|
||||||
{
|
{
|
||||||
register unsigned char *a = (unsigned char*)s1;
|
register unsigned char *a = (unsigned char*)s1;
|
||||||
register unsigned char *b = (unsigned char*)s2;
|
register unsigned char *b = (unsigned char*)s2;
|
||||||
register int tmp;
|
register int tmp;
|
||||||
|
|
||||||
while (len--) {
|
for (; len; --len) {
|
||||||
if (tmp = *a++ - *b++)
|
if (tmp = *a++ - *b++)
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
/* public domain rewrite of memcmp(3) */
|
/* public domain rewrite of memcmp(3) */
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
void *
|
void *
|
||||||
memmove (d, s, n)
|
memmove(void *d, const void *s, size_t n)
|
||||||
void *d, *s;
|
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
char *dst = d;
|
char *dst = (char *)d;
|
||||||
char *src = s;
|
const char *src = (const char *)s;
|
||||||
void *ret = dst;
|
|
||||||
|
|
||||||
if (src < dst) {
|
if (src < dst) {
|
||||||
src += n;
|
src += n;
|
||||||
dst += n;
|
dst += n;
|
||||||
while (n--)
|
for (; n; --n)
|
||||||
*--dst = *--src;
|
*--dst = *--src;
|
||||||
}
|
}
|
||||||
else if (dst < src)
|
else if (dst < src)
|
||||||
while (n--)
|
for (; n; --n)
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
return ret;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue